From f172be448c0787fb67612afe05c2a30f944dab77 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 22 Apr 2011 18:49:15 +0900 Subject: [PATCH 1/6] Clear spacebar sliding language switch diff Change-Id: If82540b6632476e049fa9c4b3122e9c053227d6e --- java/src/com/android/inputmethod/keyboard/PointerTracker.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 42070cb28..d975b39b9 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -542,6 +542,7 @@ public class PointerTracker { mListener.onCodeInput(code, new int[] {code}, keyX, keyY); } mIsInSlidingLanguageSwitch = false; + ((LatinKeyboard)mKeyboard).setSpacebarSlidingLanguageSwitchDiff(0); return; } if (!mIsRepeatableKey) { From 61393a88b048cda18f475ec5f8bd23e12ff0b63c Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 22 Apr 2011 19:50:08 +0900 Subject: [PATCH 2/6] Fix the spacebar language switcher Change-Id: I54711ff2014facefe3afd22e536045cd0ffe4955 --- .../deprecated/languageswitcher/LanguageSwitcher.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java b/java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java index e4b2e035c..1a606eaaf 100644 --- a/java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java +++ b/java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java @@ -83,6 +83,7 @@ public class LanguageSwitcher { String currentLanguage = sp.getString(Settings.PREF_INPUT_LANGUAGE, null); if (TextUtils.isEmpty(selectedLanguages)) { mSelectedLanguageArray = EMPTY_STIRNG_ARRAY; + mSelectedLanguages = null; loadDefaults(); if (mLocales.size() == 0) { return false; From d63135c148eb51e08d05f2efaf94d9fa8c13b94c Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 22 Apr 2011 20:34:56 +0900 Subject: [PATCH 3/6] Fix arabic layout for phone Change-Id: I2b71f44e27f95ba3949e2e2c150696045f3c28b3 --- java/res/xml/kbd_ar_rows.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/res/xml/kbd_ar_rows.xml b/java/res/xml/kbd_ar_rows.xml index d5264fd2d..b2ea45701 100644 --- a/java/res/xml/kbd_ar_rows.xml +++ b/java/res/xml/kbd_ar_rows.xml @@ -87,7 +87,7 @@ latin:keyEdgeFlags="right" /> From a0537fb4c73dff8beecc328720830af9719d0277 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 22 Apr 2011 21:05:30 +0900 Subject: [PATCH 4/6] Fix repeat key behavior Change-Id: Ia7e5b2e9579aa0e5050857cdb14f16fa05a33621 --- java/res/values/config.xml | 4 +-- .../inputmethod/keyboard/KeyboardView.java | 22 ++++++++----- .../inputmethod/keyboard/PointerTracker.java | 32 +++++++++++++------ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/java/res/values/config.xml b/java/res/values/config.xml index a1cd70b1b..4651de785 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -49,9 +49,9 @@ false - -1 + 1200 50 - 15 + 50 0 60 0 diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 95ecb3bc9..c36895258 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -139,6 +139,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { private final boolean mHasDistinctMultitouch; private int mOldPointerCount = 1; + private int mOldKeyIndex; // Accessibility private boolean mIsAccessibilityEnabled; @@ -202,7 +203,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { break; case MSG_REPEAT_KEY: { final PointerTracker tracker = (PointerTracker)msg.obj; - tracker.repeatKey(msg.arg1); + tracker.onRepeatKey(msg.arg1); startKeyRepeatTimer(mKeyRepeatInterval, msg.arg1, tracker); break; } @@ -1270,10 +1271,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { } if (mHandler.isInKeyRepeat()) { - // It will keep being in the key repeating mode while the key is being pressed. - if (action == MotionEvent.ACTION_MOVE) { - return true; - } final PointerTracker tracker = getPointerTracker(id); // Key repeating timer will be canceled if 2 or more keys are in action, and current // event (UP or DOWN) is non-modifier key. @@ -1291,12 +1288,21 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { PointerTracker tracker = getPointerTracker(0); if (pointerCount == 1 && oldPointerCount == 2) { // Multi-touch to single touch transition. - // Send a down event for the latest pointer. - tracker.onDownEvent(x, y, eventTime, null); + // Send a down event for the latest pointer if the key is different from the + // previous key. + final int newKeyIndex = tracker.getKeyIndexOn(x, y); + if (mOldKeyIndex != newKeyIndex) { + tracker.onDownEvent(x, y, eventTime, null); + if (action == MotionEvent.ACTION_UP) + tracker.onUpEvent(x, y, eventTime, null); + } } else if (pointerCount == 2 && oldPointerCount == 1) { // Single-touch to multi-touch transition. // Send an up event for the last pointer. - tracker.onUpEvent(tracker.getLastX(), tracker.getLastY(), eventTime, null); + final int lastX = tracker.getLastX(); + final int lastY = tracker.getLastY(); + mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY); + tracker.onUpEvent(lastX, lastY, eventTime, null); } else if (pointerCount == 1 && oldPointerCount == 1) { tracker.onTouchEvent(action, x, y, eventTime, null); } else { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index d975b39b9..e3161f610 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -251,6 +251,10 @@ public class PointerTracker { return key != null && key.mCode == Keyboard.CODE_SHIFT; } + public int getKeyIndexOn(int x, int y) { + return mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); + } + public boolean isSpaceKey(int keyIndex) { Key key = getKey(keyIndex); return key != null && key.mCode == Keyboard.CODE_SPACE; @@ -355,14 +359,7 @@ public class PointerTracker { if (callListenerOnPressAndCheckKeyboardLayoutChange(getKey(keyIndex), false)) keyIndex = mKeyState.onDownKey(x, y, eventTime); - // Accessibility disables key repeat because users may need to pause on a key to hear - // its spoken description. - final Key key = getKey(keyIndex); - if (key != null && key.mRepeatable && !mIsAccessibilityEnabled) { - repeatKey(keyIndex); - mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this); - mIsRepeatableKey = true; - } + startRepeatKey(keyIndex); startLongPressTimer(keyIndex); showKeyPreview(keyIndex); setPressedKeyGraphics(keyIndex); @@ -414,7 +411,8 @@ public class PointerTracker { setReleasedKeyGraphics(oldKeyIndex); callListenerOnRelease(oldKey, oldKey.mCode, true); startSlidingKeyInput(oldKey); - mHandler.cancelLongPressTimers(); + mHandler.cancelKeyTimers(); + startRepeatKey(keyIndex); if (mIsAllowedSlidingKeyInput) { // This onPress call may have changed keyboard layout. Those cases are detected // at {@link #setKeyboard}. In those cases, we should update keyIndex according @@ -576,7 +574,21 @@ public class PointerTracker { mIsInSlidingKeyInput = false; } - public void repeatKey(int keyIndex) { + private void startRepeatKey(int keyIndex) { + // Accessibility disables key repeat because users may need to pause on a key to hear + // its spoken description. + final Key key = getKey(keyIndex); + if (key != null && key.mRepeatable && !mIsAccessibilityEnabled) { + dismissKeyPreview(); + onRepeatKey(keyIndex); + mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this); + mIsRepeatableKey = true; + } else { + mIsRepeatableKey = false; + } + } + + public void onRepeatKey(int keyIndex) { Key key = getKey(keyIndex); if (key != null) { detectAndSendKey(keyIndex, key.mX, key.mY); From 608469c5ab41f7bc4aaba3829b83148fe9f1bd97 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 22 Apr 2011 21:31:22 +0900 Subject: [PATCH 5/6] Release the previous key if multi touch input is started Change-Id: Ib1205e67e900353976150e5ad58abfc92c3dfc21 --- .../com/android/inputmethod/keyboard/PointerTrackerQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java index 42089d5ea..68de8df8a 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java @@ -35,7 +35,7 @@ public class PointerTrackerQueue { if (t.isModifier()) { oldestPos++; } else { - t.onPhantomUpEvent(t.getLastX(), t.getLastY(), eventTime, false); + t.onPhantomUpEvent(t.getLastX(), t.getLastY(), eventTime, true); queue.remove(oldestPos); } } From d0f3f907898290f4b4553c02b5d0bc7b7a3a6a75 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 22 Apr 2011 23:20:22 +0900 Subject: [PATCH 6/6] Narrower the language switch threshold to key width x 1.25 Change-Id: I4ea9553bce34bc3783f03d1615c34b6abb153077 --- java/src/com/android/inputmethod/keyboard/LatinKeyboard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index 86b7f7e82..a1d0607bf 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -131,8 +131,8 @@ public class LatinKeyboard extends Keyboard { mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led); mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left); mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); - // The threshold is "key width" x 1.5 - mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 3) / 2; + // The threshold is "key width" x 1.25 + mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4; } public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) {