From ba9aefcc188b7f8ac99ba6cfef42a032b7d693a4 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 21 Apr 2011 18:24:41 +0900 Subject: [PATCH] Disable key preview of space, return and delete This change also re-orders punctuation mini keyboard. Change-Id: I987ef14fe5956d13439a0a76de367feed825314c --- java/res/values/donottranslate-altchars.xml | 4 +-- .../com/android/inputmethod/keyboard/Key.java | 4 --- .../inputmethod/keyboard/KeyDetector.java | 2 +- .../inputmethod/keyboard/PointerTracker.java | 25 +++++++++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/java/res/values/donottranslate-altchars.xml b/java/res/values/donottranslate-altchars.xml index 883ccb71d..e77957578 100644 --- a/java/res/values/donottranslate-altchars.xml +++ b/java/res/values/donottranslate-altchars.xml @@ -48,8 +48,8 @@ ¢,£,$,¥,₱ ¢,$,€,¥,₱ ":-)|:-) ,:-(|:-( ,;-)|;-) ,:-P|:-P ,=-O|=-O ,:-*|:-* ,:O|:O ,B-)|B-) ,:-$|:-$ ,:-!|:-! ,:-[|:-[ ,O:-)|O:-) ,:-\\\\\\\\|:-\\\\\\\\ ,:\'(|:\'( ,:-D|:-D " - "\?,!,\\,,:,-,\',\",(,),/,;,+,&,\@" - ".,\?,!,\\,,:,-,\',\",(,),/,;,+,&,\@" + "\\,,\?,!,:,-,\',\",(,),/,;,+,&,\@" + ".,\\,,\?,!,:,-,\',\",(,),/,;,+,&,\@" ".com" ".net,.org,.gov,.edu" diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 1b7e8ef21..fb70b3579 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -338,10 +338,6 @@ public class Key { mPressed = false; } - public boolean isInside(int x, int y) { - return mKeyboard.isInside(this, x, y); - } - /** * Detects if a point falls on this key. * @param x the x-coordinate of the point diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 95ec93181..2eeae96b2 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -174,7 +174,7 @@ public class KeyDetector { int primaryIndex = NOT_A_KEY; for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) { final Key key = keys.get(index); - final boolean isInside = key.isInside(touchX, touchY); + final boolean isInside = mKeyboard.isInside(key, touchX, touchY); final int distance = key.squaredDistanceToEdge(touchX, touchY); if (isInside || (mProximityCorrectOn && distance < mProximityThresholdSquare)) { final int insertedPosition = sortNearbyKeys(index, distance); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 249f6648b..1b1aa492c 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -560,15 +560,24 @@ public class PointerTracker { } } - private void showKeyPreview(int keyIndex) { + // The modifier key, such as shift key, should not show its key preview. If accessibility is + // turned on, the modifier key should show its key preview. + private boolean isKeyPreviewNotRequired(int keyIndex) { final Key key = getKey(keyIndex); - if (key != null && !key.mEnabled) - return; - // The modifier key, such as shift key, should not be shown as preview when multi-touch is - // supported. On the other hand, if multi-touch is not supported, the modifier key should - // be shown as preview. If accessibility is turned on, the modifier key should be shown as - // preview. - if (mHasDistinctMultitouch && isModifier() && !mIsAccessibilityEnabled) + if (!key.mEnabled) + return true; + if (mIsAccessibilityEnabled) + return false; + // Such as spacebar sliding language switch. + if (mKeyboard.needSpacebarPreview(keyIndex)) + return false; + final int code = key.mCode; + return isModifierCode(code) || code == Keyboard.CODE_DELETE + || code == Keyboard.CODE_ENTER || code == Keyboard.CODE_SPACE; + } + + private void showKeyPreview(int keyIndex) { + if (isKeyPreviewNotRequired(keyIndex)) return; mProxy.showKeyPreview(keyIndex, this); }