From 75136cd009ef37b9a5a013200444e149f8461ff5 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 22 Apr 2011 18:00:16 +0900 Subject: [PATCH] Fix language switch preview This change also makes the delay after key preview longer to 60ms. Change-Id: If7cf3b493824bb12e0bf44aa0bc3c186b15b51f6 --- java/res/values/config.xml | 2 +- .../keyboard/KeyboardSwitcher.java | 1 + .../inputmethod/keyboard/LatinKeyboard.java | 19 ++++++++++++------- .../inputmethod/keyboard/PointerTracker.java | 1 - 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 77259b1dc..a1cd70b1b 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -53,7 +53,7 @@ 50 15 0 - 10 + 60 0 100 400 diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index f97d1283a..e163457d8 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -190,6 +190,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha // we should reset the text fade factor. It is also applicable to shortcut key. keyboard.setSpacebarTextFadeFactor(0.0f, null); keyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady(), null); + keyboard.setSpacebarSlidingLanguageSwitchDiff(0); return keyboard; } diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index 5854db656..86b7f7e82 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -64,7 +64,7 @@ public class LatinKeyboard extends Keyboard { private final int mSpacebarTextShadowColor; private float mSpacebarTextFadeFactor = 0.0f; private final int mSpacebarLanguageSwitchThreshold; - private int mSpacebarLanguageSwitchDiff; + private int mSpacebarSlidingLanguageSwitchDiff; private SlidingLocaleDrawable mSlidingLocaleIcon; private final HashMap> mSpaceDrawableCache = new HashMap>(); @@ -323,10 +323,14 @@ public class LatinKeyboard extends Keyboard { return buffer; } + public void setSpacebarSlidingLanguageSwitchDiff(int diff) { + mSpacebarSlidingLanguageSwitchDiff = diff; + } + public void updateSpacebarPreviewIcon(int diff) { - if (mSpacebarLanguageSwitchDiff == diff) + if (mSpacebarSlidingLanguageSwitchDiff == diff) return; - mSpacebarLanguageSwitchDiff = diff; + mSpacebarSlidingLanguageSwitchDiff = diff; if (mSlidingLocaleIcon == null) { final int width = Math.max(mSpaceKey.mWidth, (int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO)); @@ -366,15 +370,16 @@ public class LatinKeyboard extends Keyboard { return false; // The language switcher will be displayed only when the dragging distance is greater // than the threshold. - return shouldTriggerSpacebarSlidingLanguageSwitch(mSpacebarLanguageSwitchDiff); + return shouldTriggerSpacebarSlidingLanguageSwitch(mSpacebarSlidingLanguageSwitchDiff); } public int getLanguageChangeDirection() { - if (mSpaceKey == null || mSubtypeSwitcher.getEnabledKeyboardLocaleCount() <= 1 || Math.abs( - mSpacebarLanguageSwitchDiff) < getMostCommonKeyWidth() * SPACEBAR_DRAG_WIDTH) { + if (mSpaceKey == null || mSubtypeSwitcher.getEnabledKeyboardLocaleCount() <= 1 + || Math.abs(mSpacebarSlidingLanguageSwitchDiff) + < getMostCommonKeyWidth() * SPACEBAR_DRAG_WIDTH) { return 0; // No change } - return mSpacebarLanguageSwitchDiff > 0 ? 1 : -1; + return mSpacebarSlidingLanguageSwitchDiff > 0 ? 1 : -1; } @Override diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index a95c5cd39..42070cb28 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -541,7 +541,6 @@ public class PointerTracker { // This will change keyboard layout. mListener.onCodeInput(code, new int[] {code}, keyX, keyY); } - ((LatinKeyboard)mKeyboard).updateSpacebarPreviewIcon(0); mIsInSlidingLanguageSwitch = false; return; }