diff options
Diffstat (limited to 'java/src')
16 files changed, 281 insertions, 203 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index 4bc82d2ec..cc10a4ed2 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -18,14 +18,12 @@ package com.android.inputmethod.compat; import android.content.Context; import android.os.IBinder; -import android.util.Log; -import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; +import com.android.inputmethod.latin.ImfUtils; + import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; // TODO: Override this class with the concrete implementation if we need to take care of the // performance. @@ -44,41 +42,20 @@ public class InputMethodManagerCompatWrapper { } public static InputMethodManagerCompatWrapper getInstance() { - if (sInstance.mImm == null) - Log.w(TAG, "getInstance() is called before initialization"); + if (sInstance.mImm == null) { + throw new RuntimeException(TAG + ".getInstance() is called before initialization"); + } return sInstance; } public static void init(Context context) { - sInstance.mImm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); - } - - public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) { - mImm.setAdditionalInputMethodSubtypes(imiId, subtypes); - } - - public InputMethodSubtype getCurrentInputMethodSubtype() { - return mImm.getCurrentInputMethodSubtype(); + sInstance.mImm = ImfUtils.getInputMethodManager(context); } public InputMethodSubtype getLastInputMethodSubtype() { return mImm.getLastInputMethodSubtype(); } - public List<InputMethodSubtype> getEnabledInputMethodSubtypeList( - InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { - return mImm.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes); - } - - public Map<InputMethodInfo, List<InputMethodSubtype>> getShortcutInputMethodsAndSubtypes() { - return mImm.getShortcutInputMethodsAndSubtypes(); - } - - // We don't call this method when we switch between subtypes within this IME. - public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { - mImm.setInputMethodAndSubtype(token, id, subtype); - } - public boolean switchToLastInputMethod(IBinder token) { return mImm.switchToLastInputMethod(token); } @@ -88,18 +65,7 @@ public class InputMethodManagerCompatWrapper { onlyCurrentIme); } - public List<InputMethodInfo> getInputMethodList() { - if (mImm == null) return null; - return mImm.getInputMethodList(); - } - - public List<InputMethodInfo> getEnabledInputMethodList() { - if (mImm == null) return null; - return mImm.getEnabledInputMethodList(); - } - public void showInputMethodPicker() { - if (mImm == null) return; mImm.showInputMethodPicker(); } } diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index fa7ec5cbf..68858e5bf 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -275,7 +275,7 @@ public class Key { additionalMoreKeys = style.getStringArray( keyAttr, R.styleable.Keyboard_Key_additionalMoreKeys); } - moreKeys = KeySpecParser.insertAddtionalMoreKeys(moreKeys, additionalMoreKeys); + moreKeys = KeySpecParser.insertAdditionalMoreKeys(moreKeys, additionalMoreKeys); if (moreKeys != null) { actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; mMoreKeys = new MoreKeySpec[moreKeys.length]; diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index d54acf715..fca8f56c8 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -197,14 +197,6 @@ public class Keyboard { return null; } - // TODO: Remove this method. - public boolean isShiftedOrShiftLocked() { - // Alphabet mode have unshifted, manual shifted, automatic shifted, shift locked, and - // shift lock shifted element. So that unshifed element is the only one that is NOT in - // shifted or shift locked state. - return mId.isAlphabetKeyboard() && mId.mElementId != KeyboardId.ELEMENT_ALPHABET; - } - public static boolean isLetterCode(int code) { return code >= MINIMUM_LETTER_CODE; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 2d587ada1..38e6d5a1d 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -109,7 +109,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { // Drawing /** True if the entire keyboard needs to be dimmed. */ - private boolean mNeedsToDimBackground; + private boolean mNeedsToDimEntireKeyboard; /** Whether the keyboard bitmap buffer needs to be redrawn before it's blitted. **/ private boolean mBufferNeedsUpdate; /** True if all keys should be drawn */ @@ -455,13 +455,16 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { final KeyDrawParams params = mKeyDrawParams; if (mInvalidateAllKeys || mInvalidatedKeys.isEmpty()) { - mInvalidatedKeysRect.set(0, 0, getWidth(), getHeight()); + mInvalidatedKeysRect.set(0, 0, width, height); canvas.clipRect(mInvalidatedKeysRect, Op.REPLACE); canvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR); // Draw all keys. for (final Key key : mKeyboard.mKeys) { onDrawKey(key, canvas, paint, params); } + if (mNeedsToDimEntireKeyboard) { + drawDimRectangle(canvas, mInvalidatedKeysRect, mBackgroundDimAlpha, paint); + } } else { // Draw invalidated keys. for (final Key key : mInvalidatedKeys) { @@ -471,24 +474,20 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { canvas.clipRect(mInvalidatedKeysRect, Op.REPLACE); canvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR); onDrawKey(key, canvas, paint, params); + if (mNeedsToDimEntireKeyboard) { + drawDimRectangle(canvas, mInvalidatedKeysRect, mBackgroundDimAlpha, paint); + } } } - // Overlay a dark rectangle to dim the entire keyboard - if (mNeedsToDimBackground) { - paint.setColor(Color.BLACK); - paint.setAlpha(mBackgroundDimAlpha); - canvas.drawRect(0, 0, width, height, paint); - } - mInvalidatedKeys.clear(); mInvalidatedKeysRect.setEmpty(); mInvalidateAllKeys = false; } public void dimEntireKeyboard(boolean dimmed) { - final boolean needsRedrawing = mNeedsToDimBackground != dimmed; - mNeedsToDimBackground = dimmed; + final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed; + mNeedsToDimEntireKeyboard = dimmed; if (needsRedrawing) { invalidateAllKeys(); } @@ -809,6 +808,13 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { canvas.translate(-x, -y); } + // Overlay a dark rectangle to dim. + private static void drawDimRectangle(Canvas canvas, Rect rect, int alpha, Paint paint) { + paint.setColor(Color.BLACK); + paint.setAlpha(alpha); + canvas.drawRect(rect, paint); + } + public Paint newDefaultLabelPaint() { final Paint paint = new Paint(); paint.setAntiAlias(true); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 341d9bc7a..efb0d77ea 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -42,13 +42,13 @@ import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; +import com.android.inputmethod.latin.ImfUtils; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.ResearchLogger; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.SubtypeLocale; -import com.android.inputmethod.latin.SubtypeUtils; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; import com.android.inputmethod.latin.define.ProductionFlag; @@ -790,10 +790,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke return false; } - public boolean handleBack() { - return dismissMoreKeysPanel(); - } - @Override public void draw(Canvas c) { Utils.GCUtils.getInstance().reset(); @@ -881,13 +877,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Whether space key needs to show the "..." popup hint for special purposes if (mIsSpacebarTriggeringPopupByLongPress - && SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes( - true /* include aux subtypes */)) { + && ImfUtils.hasMultipleEnabledIMEsOrSubtypes( + getContext(), true /* include aux subtypes */)) { drawKeyPopupHint(key, canvas, paint, params); } } else if (key.mCode == Keyboard.CODE_LANGUAGE_SWITCH) { super.onDrawKeyTopVisuals(key, canvas, paint, params); - if (SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) { + if (ImfUtils.hasMultipleEnabledIMEsOrSubtypes( + getContext(), true /* include aux subtypes */)) { drawKeyPopupHint(key, canvas, paint, params); } } else { diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index 2981a8e5c..9bbd3a280 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -267,7 +267,7 @@ public class KeySpecParser { } } - public static String[] insertAddtionalMoreKeys(String[] moreKeySpecs, + public static String[] insertAdditionalMoreKeys(String[] moreKeySpecs, String[] additionalMoreKeySpecs) { final String[] moreKeys = filterOutEmptyString(moreKeySpecs); final String[] additionalMoreKeys = filterOutEmptyString(additionalMoreKeySpecs); diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtype.java b/java/src/com/android/inputmethod/latin/AdditionalSubtype.java index deb247860..5e42ad6c5 100644 --- a/java/src/com/android/inputmethod/latin/AdditionalSubtype.java +++ b/java/src/com/android/inputmethod/latin/AdditionalSubtype.java @@ -19,7 +19,6 @@ package com.android.inputmethod.latin; import android.view.inputmethod.InputMethodSubtype; import java.util.HashMap; -import java.util.Locale; public class AdditionalSubtype { public static final String QWERTY = "qwerty"; @@ -43,14 +42,14 @@ public class AdditionalSubtype { return subtype.containsExtraValueKey(SUBTYPE_EXTRA_VALUE_IS_ADDITIONAL_SUBTYPE); } - public static InputMethodSubtype createAddtionalSubtype( - Locale locale, String keyboardLayoutSet) { + public static InputMethodSubtype createAdditionalSubtype( + String localeString, String keyboardLayoutSet) { final String extraValue = String.format( "%s=%s,%s", LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET, keyboardLayoutSet, SUBTYPE_EXTRA_VALUE_IS_ADDITIONAL_SUBTYPE); Integer nameId = sKeyboardLayoutToNameIdsMap.get(keyboardLayoutSet); if (nameId == null) nameId = R.string.subtype_generic; return new InputMethodSubtype(nameId, R.drawable.ic_subtype_keyboard, - locale.toString(), SUBTYPE_MODE_KEYBOARD, extraValue, false, false); + localeString, SUBTYPE_MODE_KEYBOARD, extraValue, false, false); } } diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index f4c8e61ed..9429ef411 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -85,8 +85,8 @@ public class BinaryDictionary extends Dictionary { private native void closeNative(long dict); private native boolean isValidWordNative(long dict, char[] word, int wordLength); private native int getSuggestionsNative(long dict, long proximityInfo, int[] xCoordinates, - int[] yCoordinates, int[] inputCodes, int codesSize, boolean useFullEditDistance, - char[] outputChars, int[] scores); + int[] yCoordinates, int[] inputCodes, int codesSize, int[] prevWordForBigrams, + boolean useFullEditDistance, char[] outputChars, int[] scores); private native int getBigramsNative(long dict, char[] prevWord, int prevWordLength, int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores, int maxWordLength, int maxBigrams); @@ -177,11 +177,14 @@ public class BinaryDictionary extends Dictionary { Arrays.fill(outputChars, (char) 0); Arrays.fill(scores, 0); + final int[] prevWordCodePointArray = null == prevWordForBigrams + ? null : StringUtils.toCodePointArray(prevWordForBigrams.toString()); + // TODO: pass the previous word to native code return getSuggestionsNative( mNativeDict, proximityInfo.getNativeProximityInfo(), codes.getXCoordinates(), codes.getYCoordinates(), mInputCodes, codesSize, - mUseFullEditDistance, outputChars, scores); + prevWordCodePointArray, mUseFullEditDistance, outputChars, scores); } public static double calcNormalizedScore(String before, String after, int score) { diff --git a/java/src/com/android/inputmethod/latin/SubtypeUtils.java b/java/src/com/android/inputmethod/latin/ImfUtils.java index 4d0f1c262..bd7d89fe7 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeUtils.java +++ b/java/src/com/android/inputmethod/latin/ImfUtils.java @@ -18,25 +18,52 @@ package com.android.inputmethod.latin; import android.content.Context; import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; - import java.util.Collections; import java.util.List; -import java.util.Locale; -public class SubtypeUtils { - private SubtypeUtils() { +/** + * Utility class for Input Method Framework + */ +public class ImfUtils { + private ImfUtils() { // This utility class is not publicly instantiable. } - // TODO: Cache my InputMethodInfo and/or InputMethodSubtype list. - public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) { - final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance(); - if (imm == null) return false; + private static InputMethodManager sInputMethodManager; + + public static InputMethodManager getInputMethodManager(Context context) { + if (sInputMethodManager == null) { + sInputMethodManager = (InputMethodManager)context.getSystemService( + Context.INPUT_METHOD_SERVICE); + } + return sInputMethodManager; + } + + private static InputMethodInfo sInputMethodInfoOfThisIme; + + public static InputMethodInfo getInputMethodInfoOfThisIme(Context context) { + if (sInputMethodInfoOfThisIme == null) { + final InputMethodManager imm = getInputMethodManager(context); + final String packageName = context.getPackageName(); + for (final InputMethodInfo imi : imm.getInputMethodList()) { + if (imi.getPackageName().equals(packageName)) + return imi; + } + throw new RuntimeException("Can not find input method id for " + packageName); + } + return sInputMethodInfoOfThisIme; + } + + public static String getInputMethodIdOfThisIme(Context context) { + return getInputMethodInfoOfThisIme(context).getId(); + } - final InputMethodInfo myImi = getInputMethodInfo(context.getPackageName()); + public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) { + final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context); + final InputMethodManager imm = getInputMethodManager(context); final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(myImi, true); for (final InputMethodSubtype subtype : subtypes) { if (subtype.equals(ims)) { @@ -46,26 +73,23 @@ public class SubtypeUtils { return false; } - public static boolean hasMultipleEnabledIMEsOrSubtypes( + public static boolean hasMultipleEnabledIMEsOrSubtypes(Context context, final boolean shouldIncludeAuxiliarySubtypes) { - final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance(); - if (imm == null) return false; - + final InputMethodManager imm = getInputMethodManager(context); final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList(); - return hasMultipleEnabledSubtypes(shouldIncludeAuxiliarySubtypes, enabledImis); + return hasMultipleEnabledSubtypes(context, shouldIncludeAuxiliarySubtypes, enabledImis); } public static boolean hasMultipleEnabledSubtypesInThisIme(Context context, final boolean shouldIncludeAuxiliarySubtypes) { - final InputMethodInfo myImi = getInputMethodInfo(context.getPackageName()); + final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context); final List<InputMethodInfo> imiList = Collections.singletonList(myImi); - return hasMultipleEnabledSubtypes(shouldIncludeAuxiliarySubtypes, imiList); + return hasMultipleEnabledSubtypes(context, shouldIncludeAuxiliarySubtypes, imiList); } - private static boolean hasMultipleEnabledSubtypes(final boolean shouldIncludeAuxiliarySubtypes, - List<InputMethodInfo> imiList) { - final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance(); - if (imm == null) return false; + private static boolean hasMultipleEnabledSubtypes(Context context, + final boolean shouldIncludeAuxiliarySubtypes, List<InputMethodInfo> imiList) { + final InputMethodManager imm = getInputMethodManager(context); // Number of the filtered IMEs int filteredImisCount = 0; @@ -114,36 +138,26 @@ public class SubtypeUtils { return keyboardCount > 1; } - public static String getInputMethodId(String packageName) { - return getInputMethodInfo(packageName).getId(); - } - - public static InputMethodInfo getInputMethodInfo(String packageName) { - final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance(); - if (imm == null) { - throw new RuntimeException("Input method manager not found"); - } - - for (final InputMethodInfo imi : imm.getInputMethodList()) { - if (imi.getPackageName().equals(packageName)) - return imi; - } - throw new RuntimeException("Can not find input method id for " + packageName); - } - public static InputMethodSubtype findSubtypeByLocaleAndKeyboardLayoutSet( - Context context, Locale locale, String keyoardLayoutSet) { - final String localeString = locale.toString(); - final InputMethodInfo imi = getInputMethodInfo(context.getPackageName()); + Context context, String localeString, String keyboardLayoutSetName) { + final InputMethodInfo imi = getInputMethodInfoOfThisIme(context); final int count = imi.getSubtypeCount(); for (int i = 0; i < count; i++) { final InputMethodSubtype subtype = imi.getSubtypeAt(i); - final String layout = SubtypeLocale.getKeyboardLayoutSetName(subtype); - if (localeString.equals(subtype.getLocale()) && keyoardLayoutSet.equals(layout)) { + final String layoutName = SubtypeLocale.getKeyboardLayoutSetName(subtype); + if (localeString.equals(subtype.getLocale()) + && keyboardLayoutSetName.equals(layoutName)) { return subtype; } } throw new RuntimeException("Can't find subtype for locale " + localeString - + " and keyboard layout " + keyoardLayoutSet); + + " and keyboard layout " + keyboardLayoutSetName); + } + + public static void setAdditionalInputMethodSubtypes(Context context, + InputMethodSubtype[] subtypes) { + final InputMethodManager imm = getInputMethodManager(context); + final String imiId = getInputMethodIdOfThisIme(context); + imm.setAdditionalInputMethodSubtypes(imiId, subtypes); } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b30d1e35c..aea6add56 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -40,7 +40,6 @@ import android.text.TextUtils; import android.util.Log; import android.util.PrintWriterPrinter; import android.util.Printer; -import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; @@ -442,9 +441,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen loadSettings(); - mImm.setAdditionalInputMethodSubtypes( - SubtypeUtils.getInputMethodId(getPackageName()), - mSettingsValues.getPrefefinedAdditionalSubtypes()); + ImfUtils.setAdditionalInputMethodSubtypes( + this, mSettingsValues.getPrefefinedAdditionalSubtypes()); // TODO: remove the following when it's not needed by updateCorrectionMode() any more mInputAttributes = new InputAttributes(null, false /* isFullscreenMode */); @@ -1010,50 +1008,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mKeyPreviewBackingView.setVisibility(isFullscreenMode() ? View.GONE : View.VISIBLE); } - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_BACK: - if (event.getRepeatCount() == 0) { - if (mSuggestionsView != null && mSuggestionsView.handleBack()) { - return true; - } - final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView(); - if (keyboardView != null && keyboardView.handleBack()) { - return true; - } - } - break; - } - return super.onKeyDown(keyCode, event); - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_DOWN: - case KeyEvent.KEYCODE_DPAD_UP: - case KeyEvent.KEYCODE_DPAD_LEFT: - case KeyEvent.KEYCODE_DPAD_RIGHT: - final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView(); - final Keyboard keyboard = mKeyboardSwitcher.getKeyboard(); - // Enable shift key and DPAD to do selections - if ((keyboardView != null && keyboardView.isShown()) - && (keyboard != null && keyboard.isShiftedOrShiftLocked())) { - KeyEvent newEvent = new KeyEvent(event.getDownTime(), event.getEventTime(), - event.getAction(), event.getKeyCode(), event.getRepeatCount(), - event.getDeviceId(), event.getScanCode(), - KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); - final InputConnection ic = getCurrentInputConnection(); - if (ic != null) - ic.sendKeyEvent(newEvent); - return true; - } - break; - } - return super.onKeyUp(keyCode, event); - } - // This will reset the whole input state to the starting state. It will clear // the composing word, reset the last composed word, tell the inputconnection // and the composingStateManager about it. @@ -1081,6 +1035,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen separatorCode); if (ic != null) { ic.commitText(typedWord, 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(typedWord); + } } addToUserHistoryDictionary(typedWord); } @@ -1105,7 +1062,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == Keyboard.CODE_SPACE) { ic.deleteSurroundingText(2, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(2); + } ic.commitText(lastTwo.charAt(1) + " ", 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_swapSwapperAndSpaceWhileInBatchEdit(); + } mKeyboardSwitcher.updateShiftState(); } } @@ -1122,6 +1085,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mHandler.cancelDoubleSpacesTimer(); ic.deleteSurroundingText(2, 0); ic.commitText(". ", 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_doubleSpaceAutoPeriod(); + } mKeyboardSwitcher.updateShiftState(); return true; } @@ -1135,6 +1101,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (lastOne != null && lastOne.length() == 1 && lastOne.charAt(0) == Keyboard.CODE_SPACE) { ic.deleteSurroundingText(1, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(1); + } } } @@ -1165,7 +1134,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (isShowingOptionDialog()) return false; switch (requestCode) { case CODE_SHOW_INPUT_METHOD_PICKER: - if (SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) { + if (ImfUtils.hasMultipleEnabledIMEsOrSubtypes( + this, true /* include aux subtypes */)) { mImm.showInputMethodPicker(); return true; } @@ -1189,6 +1159,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.performEditorAction(actionId); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_performEditorAction(actionId); + } } } @@ -1197,7 +1170,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final IBinder token = getWindow().getWindow().getAttributes().token; if (mShouldSwitchToLastSubtype) { final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype(); - final boolean lastSubtypeBelongsToThisIme = SubtypeUtils.checkIfSubtypeBelongsToThisIme( + final boolean lastSubtypeBelongsToThisIme = ImfUtils.checkIfSubtypeBelongsToThisIme( this, lastSubtype); if ((includesOtherImes || lastSubtypeBelongsToThisIme) && mImm.switchToLastInputMethod(token)) { @@ -1223,6 +1196,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (ic != null) { final String text = new String(new int[] { code }, 0, 1); ic.commitText(text, text.length()); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_sendKeyCodePoint(code); + } } } @@ -1322,6 +1298,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen sendKeyCodePoint(Keyboard.CODE_SPACE); } ic.commitText(text, 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(text); + } ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT); @@ -1373,7 +1352,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Cancel multi-character input: remove the text we just entered. // This is triggered on backspace after a key that inputs multiple characters, // like the smiley key or the .com key. - ic.deleteSurroundingText(mEnteredText.length(), 0); + final int length = mEnteredText.length(); + ic.deleteSurroundingText(length, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(length); + } // If we have mEnteredText, then we know that mHasUncommittedTypedChars == false. // In addition we know that spaceState is false, and that we should not be // reverting any autocorrect at this point. So we can safely return. @@ -1396,6 +1379,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } else { ic.deleteSurroundingText(1, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(1); + } } } else { if (mLastComposedWord.canRevertCommit()) { @@ -1423,6 +1409,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int lengthToDelete = mLastSelectionEnd - mLastSelectionStart; ic.setSelection(mLastSelectionEnd, mLastSelectionEnd); ic.deleteSurroundingText(lengthToDelete, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(lengthToDelete); + } } else { // There is no selection, just delete one character. if (NOT_A_CURSOR_POSITION == mLastSelectionEnd) { @@ -1430,8 +1419,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen Log.e(TAG, "Backspace when we don't know the selection position"); } ic.deleteSurroundingText(1, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(1); + } if (mDeleteCount > DELETE_ACCELERATE_AT) { ic.deleteSurroundingText(1, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(1); + } } } if (isSuggestionsRequested()) { @@ -1799,7 +1794,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorCodePoint); if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.LatinIME_commitCurrentAutoCorrection(typedWord, + ResearchLogger.latinIME_commitCurrentAutoCorrection(typedWord, autoCorrection.toString()); } mExpectingUpdateSelection = true; @@ -1928,8 +1923,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( this, bestWord, suggestedWords, mSubtypeSwitcher.isDictionaryAvailable()), 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(bestWord); + } } else { ic.commitText(bestWord, 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(bestWord); + } } } // TODO: figure out here if this is an auto-correct or if the best word is actually @@ -2078,7 +2079,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void restartSuggestionsOnWordBeforeCursor(final InputConnection ic, final CharSequence word) { mWordComposer.setComposingWord(word, mKeyboardSwitcher.getKeyboard()); - ic.deleteSurroundingText(word.length(), 0); + final int length = word.length(); + ic.deleteSurroundingText(length, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(length); + } ic.setComposingText(word, 1); mHandler.postUpdateSuggestions(); } @@ -2091,12 +2096,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int separatorLength = LastComposedWord.getSeparatorLength( mLastComposedWord.mSeparatorCode); // TODO: should we check our saved separator against the actual contents of the text view? + final int deleteLength = cancelLength + separatorLength; if (DEBUG) { if (mWordComposer.isComposingWord()) { throw new RuntimeException("revertCommit, but we are composing a word"); } final String wordBeforeCursor = - ic.getTextBeforeCursor(cancelLength + separatorLength, 0) + ic.getTextBeforeCursor(deleteLength, 0) .subSequence(0, cancelLength).toString(); if (!TextUtils.equals(committedWord, wordBeforeCursor)) { throw new RuntimeException("revertCommit check failed: we thought we were " @@ -2104,7 +2110,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen + "\", but before the cursor we found \"" + wordBeforeCursor + "\""); } } - ic.deleteSurroundingText(cancelLength + separatorLength, 0); + ic.deleteSurroundingText(deleteLength, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(deleteLength); + } if (0 == separatorLength || mLastComposedWord.didCommitTypedWord()) { // This is the case when we cancel a manual pick. // We should restart suggestion on the word right away. @@ -2116,6 +2125,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen sendKeyCodePoint(mLastComposedWord.mSeparatorCode); Utils.Stats.onSeparator(mLastComposedWord.mSeparatorCode, WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_revertCommit(originallyTypedWord); + } // Don't restart suggestion yet. We'll restart if the user deletes the // separator. } @@ -2139,7 +2151,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return false; } ic.deleteSurroundingText(2, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(2); + } ic.commitText(" ", 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_revertDoubleSpaceWhileInBatchEdit(); + } return true; } @@ -2160,7 +2178,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } ic.beginBatchEdit(); ic.deleteSurroundingText(2, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(2); + } ic.commitText(" " + textBeforeCursor.subSequence(0, 1), 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_revertSwapPunctuation(); + } ic.endBatchEdit(); return true; } @@ -2276,6 +2300,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen getString(R.string.language_selection_title), getString(R.string.english_ime_settings), }; + final Context context = this; final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int position) { @@ -2283,7 +2308,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen switch (position) { case 0: Intent intent = CompatUtils.getInputLanguageSelectionIntent( - SubtypeUtils.getInputMethodId(getPackageName()), + ImfUtils.getInputMethodIdOfThisIme(context), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/java/src/com/android/inputmethod/latin/ResearchLogger.java b/java/src/com/android/inputmethod/latin/ResearchLogger.java index 27f2e2a59..7072dda23 100644 --- a/java/src/com/android/inputmethod/latin/ResearchLogger.java +++ b/java/src/com/android/inputmethod/latin/ResearchLogger.java @@ -355,9 +355,24 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final boolean KEYBOARDSTATE_TOGGLEALPHABETANDSYMBOLS_ENABLED = DEFAULT_ENABLED; private static final boolean LATINIME_COMMITCURRENTAUTOCORRECTION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_COMMITTEXT_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_DELETESURROUNDINGTEXT_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_DOUBLESPACEAUTOPERIOD_ENABLED = DEFAULT_ENABLED; private static final boolean LATINIME_ONDISPLAYCOMPLETIONS_ENABLED = DEFAULT_ENABLED; private static final boolean LATINIME_ONSTARTINPUTVIEWINTERNAL_ENABLED = DEFAULT_ENABLED; private static final boolean LATINIME_ONUPDATESELECTION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_PERFORMEDITORACTION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED + = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKSUGGESTIONMANUALLY_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_REVERTCOMMIT_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_REVERTDOUBLESPACEWHILEINBATCHEDIT_ENABLED + = DEFAULT_ENABLED; + private static final boolean LATINIME_REVERTSWAPPUNCTUATION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_SENDKEYCODEPOINT_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_SWAPSWAPPERANDSPACEWHILEINBATCHEDIT_ENABLED + = DEFAULT_ENABLED; private static final boolean LATINIME_SWITCHTOKEYBOARDVIEW_ENABLED = DEFAULT_ENABLED; private static final boolean LATINKEYBOARDVIEW_ONLONGPRESS_ENABLED = DEFAULT_ENABLED; private static final boolean LATINKEYBOARDVIEW_ONPROCESSMOTIONEVENT_ENABLED @@ -375,10 +390,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final boolean SUDDENJUMPINGTOUCHEVENTHANDLER_ONTOUCHEVENT_ENABLED = DEFAULT_ENABLED; private static final boolean SUGGESTIONSVIEW_SETSUGGESTIONS_ENABLED = DEFAULT_ENABLED; - private static final boolean LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED - = DEFAULT_ENABLED; - private static final boolean LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED = DEFAULT_ENABLED; - private static final boolean LATINIME_PICKSUGGESTIONMANUALLY_ENABLED = DEFAULT_ENABLED; } public static void logUnstructured(String logGroup, final String details) { @@ -579,7 +590,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } } - public static void LatinIME_commitCurrentAutoCorrection(final String typedWord, + public static void latinIME_commitCurrentAutoCorrection(final String typedWord, final String autoCorrection) { if (UnsLogGroup.LATINIME_COMMITCURRENTAUTOCORRECTION_ENABLED) { if (typedWord.equals(autoCorrection)) { @@ -590,6 +601,24 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } } + public static void latinIME_commitText(final CharSequence typedWord) { + if (UnsLogGroup.LATINIME_COMMITTEXT_ENABLED) { + logUnstructured("LatinIME_commitText", typedWord.toString()); + } + } + + public static void latinIME_deleteSurroundingText(final int length) { + if (UnsLogGroup.LATINIME_DELETESURROUNDINGTEXT_ENABLED) { + logUnstructured("LatinIME_deleteSurroundingText", String.valueOf(length)); + } + } + + public static void latinIME_doubleSpaceAutoPeriod() { + if (UnsLogGroup.LATINIME_DOUBLESPACEAUTOPERIOD_ENABLED) { + logUnstructured("LatinIME_doubleSpaceAutoPeriod", ""); + } + } + public static void latinIME_onDisplayCompletions( final CompletionInfo[] applicationSpecifiedCompletions) { if (UnsLogGroup.LATINIME_ONDISPLAYCOMPLETIONS_ENABLED) { @@ -637,11 +666,17 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } } + public static void latinIME_performEditorAction(final int imeActionNext) { + if (UnsLogGroup.LATINIME_PERFORMEDITORACTION_ENABLED) { + logUnstructured("LatinIME_performEditorAction", String.valueOf(imeActionNext)); + } + } + public static void latinIME_pickApplicationSpecifiedCompletion(final int index, final CharSequence text, int x, int y) { if (UnsLogGroup.LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED) { final String s = String.valueOf(index) + '\t' + text + '\t' + x + '\t' + y; - logUnstructured("latinIME_pickApplicationSpecifiedCompletion", s); + logUnstructured("LatinIME_pickApplicationSpecifiedCompletion", s); } } @@ -649,7 +684,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang final int index, CharSequence suggestion, int x, int y) { if (UnsLogGroup.LATINIME_PICKSUGGESTIONMANUALLY_ENABLED) { final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y; - logUnstructured("latinIME_pickSuggestionManually", s); + logUnstructured("LatinIME_pickSuggestionManually", s); } } @@ -657,7 +692,31 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang final CharSequence suggestion, int x, int y) { if (UnsLogGroup.LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED) { final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y; - logUnstructured("latinIME_pickPunctuationSuggestion", s); + logUnstructured("LatinIME_pickPunctuationSuggestion", s); + } + } + + public static void latinIME_revertDoubleSpaceWhileInBatchEdit() { + if (UnsLogGroup.LATINIME_REVERTDOUBLESPACEWHILEINBATCHEDIT_ENABLED) { + logUnstructured("LatinIME_revertDoubleSpaceWhileInBatchEdit", ""); + } + } + + public static void latinIME_revertSwapPunctuation() { + if (UnsLogGroup.LATINIME_REVERTSWAPPUNCTUATION_ENABLED) { + logUnstructured("LatinIME_revertSwapPunctuation", ""); + } + } + + public static void latinIME_sendKeyCodePoint(final int code) { + if (UnsLogGroup.LATINIME_SENDKEYCODEPOINT_ENABLED) { + logUnstructured("LatinIME_sendKeyCodePoint", String.valueOf(code)); + } + } + + public static void latinIME_swapSwapperAndSpaceWhileInBatchEdit() { + if (UnsLogGroup.LATINIME_SWAPSWAPPERANDSPACEWHILEINBATCHEDIT_ENABLED) { + logUnstructured("latinIME_swapSwapperAndSpaceWhileInBatchEdit", ""); } } @@ -686,6 +745,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } } + public static void latinIME_revertCommit(final String originallyTypedWord) { + if (UnsLogGroup.LATINIME_REVERTCOMMIT_ENABLED) { + logUnstructured("LatinIME_revertCommit", originallyTypedWord); + } + } + public static void pointerTracker_callListenerOnCancelInput() { final String s = "onCancelInput"; if (UnsLogGroup.POINTERTRACKER_CALLLISTENERONCANCELINPUT_ENABLED) { diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 8ff644fc5..539ac5963 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -150,10 +150,10 @@ public class SettingsValues { mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain); // Predefined additional subtypes - final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAddtionalSubtype( - Locale.GERMAN, AdditionalSubtype.QWERTY); - final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAddtionalSubtype( - Locale.FRENCH, AdditionalSubtype.QWERTZ); + final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype( + Locale.GERMAN.toString(), AdditionalSubtype.QWERTY); + final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype( + Locale.FRENCH.toString(), AdditionalSubtype.QWERTZ); mPredefinedAdditionalSubtypes = new InputMethodSubtype[] { DE_QWERTY, FR_QWERTZ, @@ -306,9 +306,10 @@ public class SettingsValues { return false; } if (mIncludesOtherImesInLanguageSwitchList) { - return SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes(/* include aux subtypes */false); + return ImfUtils.hasMultipleEnabledIMEsOrSubtypes( + context, /* include aux subtypes */false); } else { - return SubtypeUtils.hasMultipleEnabledSubtypesInThisIme( + return ImfUtils.hasMultipleEnabledSubtypesInThisIme( context, /* include aux subtypes */false); } } diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java index 649cd650a..a599933d8 100644 --- a/java/src/com/android/inputmethod/latin/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/StringUtils.java @@ -166,4 +166,19 @@ public class StringUtils { // - It also does not work with unicode surrogate code points. return s.toUpperCase(locale).charAt(0) + s.substring(1); } + + public static int[] toCodePointArray(final String string) { + final char[] characters = string.toCharArray(); + final int length = characters.length; + final int[] codePoints = new int[Character.codePointCount(characters, 0, length)]; + int codePoint = Character.codePointAt(characters, 0); + int dsti = 0; + for (int srci = Character.charCount(codePoint); + srci < length; srci += Character.charCount(codePoint), ++dsti) { + codePoints[dsti] = codePoint; + codePoint = Character.codePointAt(characters, srci); + } + codePoints[dsti] = codePoint; + return codePoints; + } } diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java index 03780419e..37f46fc79 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java +++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java @@ -25,8 +25,7 @@ import java.util.Locale; public class SubtypeLocale { // Special language code to represent "no language". - private static final String NO_LANGUAGE = "zz"; - public static final Locale LOCALE_NO_LANGUAGE = new Locale(NO_LANGUAGE); + public static final String NO_LANGUAGE = "zz"; // Exceptional locales to display name map. private static final HashMap<String, String> sExceptionalDisplayNamesMap = diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 3bb3ab4ba..cf95a7e1a 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -28,9 +28,9 @@ import android.os.IBinder; import android.text.TextUtils; import android.util.Log; import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.keyboard.KeyboardSwitcher; import java.util.ArrayList; @@ -52,7 +52,7 @@ public class SubtypeSwitcher { private static final SubtypeSwitcher sInstance = new SubtypeSwitcher(); private /* final */ LatinIME mService; - private /* final */ InputMethodManagerCompatWrapper mImm; + private /* final */ InputMethodManager mImm; private /* final */ Resources mResources; private /* final */ ConnectivityManager mConnectivityManager; private final ArrayList<InputMethodSubtype> mEnabledKeyboardSubtypesOfCurrentInputMethod = @@ -94,7 +94,7 @@ public class SubtypeSwitcher { private void initialize(LatinIME service) { mService = service; mResources = service.getResources(); - mImm = InputMethodManagerCompatWrapper.getInstance(); + mImm = ImfUtils.getInputMethodManager(service); mConnectivityManager = (ConnectivityManager) service.getSystemService( Context.CONNECTIVITY_SERVICE); mEnabledKeyboardSubtypesOfCurrentInputMethod.clear(); @@ -104,8 +104,8 @@ public class SubtypeSwitcher { mInputLocaleStr = null; mCurrentSubtype = mImm.getCurrentInputMethodSubtype(); mAllEnabledSubtypesOfCurrentInputMethod = null; - mNoLanguageSubtype = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet( - service, SubtypeLocale.LOCALE_NO_LANGUAGE, AdditionalSubtype.QWERTY); + mNoLanguageSubtype = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet( + service, SubtypeLocale.NO_LANGUAGE, AdditionalSubtype.QWERTY); final NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); mIsNetworkConnected = (info != null && info.isConnected()); @@ -277,7 +277,7 @@ public class SubtypeSwitcher { if (token == null) { return; } - final InputMethodManagerCompatWrapper imm = mImm; + final InputMethodManager imm = mImm; new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { @@ -333,7 +333,7 @@ public class SubtypeSwitcher { } public boolean needsToDisplayLanguage(Locale keyboardLocale) { - if (keyboardLocale.equals(SubtypeLocale.LOCALE_NO_LANGUAGE)) { + if (keyboardLocale.toString().equals(SubtypeLocale.NO_LANGUAGE)) { return true; } if (!keyboardLocale.equals(mInputLocale)) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index 4e1410415..a17371396 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -746,10 +746,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, return false; } - public boolean handleBack() { - return dismissMoreSuggestions(); - } - @Override public boolean onLongClick(View view) { return showMoreSuggestions(); |