aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java55
1 files changed, 50 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index aca361905..a4253bb3b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -59,6 +59,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardId;
@@ -79,6 +80,7 @@ import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.CompletionInfoUtils;
+import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
@@ -203,7 +205,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
case MSG_RESUME_SUGGESTIONS:
latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor(
latinIme.mSettings.getCurrent(),
- false /* includeResumedWordInSuggestions */, latinIme.mKeyboardSwitcher);
+ false /* includeResumedWordInSuggestions */);
break;
case MSG_REOPEN_DICTIONARIES:
latinIme.initSuggest();
@@ -217,10 +219,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
(SuggestedWords) msg.obj, latinIme.mKeyboardSwitcher);
break;
case MSG_RESET_CACHES:
- latinIme.mInputLogic.retryResetCaches(latinIme.mSettings.getCurrent(),
+ final SettingsValues settingsValues = latinIme.mSettings.getCurrent();
+ if (latinIme.mInputLogic.retryResetCachesAndReturnSuccess(settingsValues,
msg.arg1 == 1 /* tryResumeSuggestions */,
- msg.arg2 /* remainingTries */,
- latinIme.mKeyboardSwitcher, this);
+ msg.arg2 /* remainingTries */, this /* handler */)) {
+ // If we were able to reset the caches, then we can reload the keyboard.
+ // Otherwise, we'll do it when we can.
+ latinIme.mKeyboardSwitcher.loadKeyboard(latinIme.getCurrentInputEditorInfo(),
+ settingsValues);
+ }
break;
}
}
@@ -1194,6 +1201,30 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return mSubtypeSwitcher.getCurrentSubtypeLocale();
}
+ /**
+ * @param codePoints code points to get coordinates for.
+ * @return x,y coordinates for this keyboard, as a flattened array.
+ */
+ public int[] getCoordinatesForCurrentKeyboard(final int[] codePoints) {
+ return getCoordinatesForKeyboard(codePoints, mKeyboardSwitcher.getKeyboard());
+ }
+
+ public static int[] getCoordinatesForKeyboard(final int[] codePoints, final Keyboard keyboard) {
+ final int length = codePoints.length;
+ final int[] coordinates = CoordinateUtils.newCoordinateArray(length);
+ Key key;
+ for (int i = 0; i < length; ++i) {
+ if (keyboard != null && (key = keyboard.getKey(codePoints[i])) != null) {
+ CoordinateUtils.setXYInArray(coordinates, i,
+ key.getX() + key.getWidth() / 2, key.getY() + key.getHeight() / 2);
+ } else {
+ CoordinateUtils.setXYInArray(coordinates, i,
+ Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
+ }
+ }
+ return coordinates;
+ }
+
// Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is
// pressed.
@Override
@@ -1255,8 +1286,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// this transformation, it should be done already before calling onCodeInput.
final int keyX = mainKeyboardView.getKeyX(x);
final int keyY = mainKeyboardView.getKeyY(y);
- mInputLogic.onCodeInput(codePoint, keyX, keyY, mHandler, mKeyboardSwitcher,
+ final int codeToSend;
+ if (Constants.CODE_SHIFT == codePoint) {
+ // TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
+ // alphabetic shift and shift while in symbol layout.
+ final Keyboard currentKeyboard = mKeyboardSwitcher.getKeyboard();
+ if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
+ codeToSend = codePoint;
+ } else {
+ codeToSend = Constants.CODE_SYMBOL_SHIFT;
+ }
+ } else {
+ codeToSend = codePoint;
+ }
+ mInputLogic.onCodeInput(codeToSend, keyX, keyY, mHandler, mKeyboardSwitcher,
mSubtypeSwitcher);
+ mKeyboardSwitcher.onCodeInput(codePoint);
}
// Called from PointerTracker through the KeyboardActionListener interface