aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2010-10-25 18:34:19 +0900
committerKen Wakasa <kwakasa@google.com>2010-10-25 19:55:06 +0900
commit29ff343f77365e8a11a9b26a0e16a9dc5b7d72d7 (patch)
treed247d185388960535dee68626d7600cd248c6663 /java/src/com/android/inputmethod
parent55952c9868e5bdd61c7356f0ccf9168b36a4e9d6 (diff)
downloadlatinime-29ff343f77365e8a11a9b26a0e16a9dc5b7d72d7.tar.gz
latinime-29ff343f77365e8a11a9b26a0e16a9dc5b7d72d7.tar.xz
latinime-29ff343f77365e8a11a9b26a0e16a9dc5b7d72d7.zip
Remove LatinKeyboardBaseView.isShifted() and setShifted() for refactoring
Change-Id: I9a1106b679a9ffb3ae959d90377eef096e5af842
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/KeyboardSwitcher.java5
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java44
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java35
3 files changed, 42 insertions, 42 deletions
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 3a54904d3..a5a262ec7 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -392,7 +392,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
public void setShifted(boolean shifted) {
if (mInputView != null) {
- mInputView.setShifted(shifted);
+ LatinKeyboard latinKeyboard = mInputView.getLatinKeyboard();
+ if (latinKeyboard != null && latinKeyboard.setShifted(shifted)) {
+ mInputView.invalidateAllKeys();
+ }
}
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 0a39ab8de..07df7eda8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -993,7 +993,8 @@ public class LatinIME extends InputMethodService
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
// Enable shift key and DPAD to do selections
if (inputView != null && inputView.isShown()
- && inputView.isShifted()) {
+ && inputView.getLatinKeyboard() != null
+ && inputView.getLatinKeyboard().isShifted()) {
event = new KeyEvent(event.getDownTime(), event.getEventTime(),
event.getAction(), event.getKeyCode(), event.getRepeatCount(),
event.getDeviceId(), event.getScanCode(),
@@ -1372,7 +1373,10 @@ public class LatinIME extends InputMethodService
mCapsLock = false;
switcher.setShifted(false);
} else if (inputView != null) {
- switcher.setShifted(!inputView.isShifted());
+ LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
+ if (latinKeyboard != null) {
+ switcher.setShifted(!latinKeyboard.isShifted());
+ }
}
} else {
switcher.toggleShift();
@@ -1425,7 +1429,8 @@ public class LatinIME extends InputMethodService
mWord.reset();
}
}
- if (mKeyboardSwitcher.getInputView().isShifted()) {
+ LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
+ if (latinKeyboard != null && latinKeyboard.isShifted()) {
if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT
|| keyCodes[0] > Character.MAX_CODE_POINT) {
return;
@@ -1444,7 +1449,7 @@ public class LatinIME extends InputMethodService
}
}
if (mPredicting) {
- if (mKeyboardSwitcher.getInputView().isShifted()
+ if (latinKeyboard != null && latinKeyboard.isShifted()
&& mKeyboardSwitcher.isAlphabetMode()
&& mComposing.length() == 0) {
mWord.setFirstCharCapitalized(true);
@@ -1739,7 +1744,8 @@ public class LatinIME extends InputMethodService
final List<CharSequence> nBest = new ArrayList<CharSequence>();
boolean capitalizeFirstWord = preferCapitalization()
|| (mKeyboardSwitcher.isAlphabetMode()
- && mKeyboardSwitcher.getInputView().isShifted());
+ && mKeyboardSwitcher.getInputView().getLatinKeyboard() != null
+ && mKeyboardSwitcher.getInputView().getLatinKeyboard().isShifted());
for (String c : mVoiceResults.candidates) {
if (capitalizeFirstWord) {
c = Character.toUpperCase(c.charAt(0)) + c.substring(1, c.length());
@@ -1791,7 +1797,10 @@ public class LatinIME extends InputMethodService
private void updateSuggestions() {
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
- inputView.getLatinKeyboard().setPreferredLetters(null);
+ LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
+ if (latinKeyboard != null) {
+ latinKeyboard.setPreferredLetters(null);
+ }
// Check if we have a suggestion engine attached.
if ((mSuggest == null || !isPredictionOn()) && !mVoiceInputHighlighted) {
@@ -1813,7 +1822,10 @@ public class LatinIME extends InputMethodService
private void showCorrections(WordAlternatives alternatives) {
List<CharSequence> stringList = alternatives.getAlternatives();
- mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(null);
+ LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
+ if (latinKeyboard != null) {
+ latinKeyboard.setPreferredLetters(null);
+ }
showSuggestions(stringList, alternatives.getOriginalWord(), false, false);
}
@@ -1829,8 +1841,10 @@ public class LatinIME extends InputMethodService
int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
- mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(
- nextLettersFrequencies);
+ LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
+ if (latinKeyboard != null) {
+ latinKeyboard.setPreferredLetters(nextLettersFrequencies);
+ }
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
//|| mCorrectionMode == mSuggest.CORRECTION_FULL;
@@ -2002,11 +2016,12 @@ public class LatinIME extends InputMethodService
*/
private void pickSuggestion(CharSequence suggestion, boolean correcting) {
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
+ LatinKeyboard latinKeyboard = inputView.getLatinKeyboard();
if (mCapsLock) {
suggestion = suggestion.toString().toUpperCase();
} else if (preferCapitalization()
|| (mKeyboardSwitcher.isAlphabetMode()
- && inputView.isShifted())) {
+ && latinKeyboard != null && latinKeyboard.isShifted())) {
suggestion = suggestion.toString().toUpperCase().charAt(0)
+ suggestion.subSequence(1, suggestion.length()).toString();
}
@@ -2018,7 +2033,9 @@ public class LatinIME extends InputMethodService
saveWordInHistory(suggestion);
mPredicting = false;
mCommittedLength = suggestion.length();
- inputView.getLatinKeyboard().setPreferredLetters(null);
+ if (latinKeyboard != null) {
+ latinKeyboard.setPreferredLetters(null);
+ }
// If we just corrected a word, then don't show punctuations
if (!correcting) {
setNextSuggestions();
@@ -2321,7 +2338,10 @@ public class LatinIME extends InputMethodService
public void onRelease(int primaryCode) {
// Reset any drag flags in the keyboard
- mKeyboardSwitcher.getInputView().getLatinKeyboard().keyReleased();
+ LatinKeyboard latinKeyboard = mKeyboardSwitcher.getInputView().getLatinKeyboard();
+ if (latinKeyboard != null) {
+ latinKeyboard.keyReleased();
+ }
//vibrate();
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) {
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 2bf70bf82..b2635ad9c 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -639,34 +639,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
}
/**
- * Sets the state of the shift key of the keyboard, if any.
- * @param shifted whether or not to enable the state of the shift key
- * @return true if the shift key state changed, false if there was no change
- */
- public boolean setShifted(boolean shifted) {
- if (mKeyboard != null) {
- if (mKeyboard.setShifted(shifted)) {
- // The whole keyboard probably needs to be redrawn
- invalidateAllKeys();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the state of the shift key of the keyboard, if any.
- * @return true if the shift is in a pressed state, false otherwise. If there is
- * no shift key on the keyboard or there is no keyboard attached, it returns false.
- */
- public boolean isShifted() {
- if (mKeyboard != null) {
- return mKeyboard.isShifted();
- }
- return false;
- }
-
- /**
* Enables or disables the key feedback popup. This is a popup that shows a magnified
* version of the depressed key. By default the preview is enabled.
* @param previewEnabled whether or not to enable the key feedback popup
@@ -1247,7 +1219,12 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft() - mWindowOffset[0];
mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1];
mMiniKeyboard.setPopupOffset(adjustedX, y);
- mMiniKeyboard.setShifted(isShifted());
+ // TODO: change the below line to use getLatinKeyboard() instead of getKeyboard()
+ BaseKeyboard baseMiniKeyboard = mMiniKeyboard.getKeyboard();
+ if (baseMiniKeyboard != null && baseMiniKeyboard.setShifted(mKeyboard == null
+ ? false : mKeyboard.isShifted())) {
+ mMiniKeyboard.invalidateAllKeys();
+ }
// Mini keyboard needs no pop-up key preview displayed.
mMiniKeyboard.setPreviewEnabled(false);
mMiniKeyboardPopup.setContentView(container);