aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-12-18 03:06:20 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-12-18 16:08:28 +0900
commit22b48de11ce6f31a0edf90e1308073e67a7a2adb (patch)
treec2d82e3595b481eba91133885aaaac66cfc18f15 /java/src
parentbc781e963ff51576109aca9626728d09222cfca7 (diff)
downloadlatinime-22b48de11ce6f31a0edf90e1308073e67a7a2adb.tar.gz
latinime-22b48de11ce6f31a0edf90e1308073e67a7a2adb.tar.xz
latinime-22b48de11ce6f31a0edf90e1308073e67a7a2adb.zip
Get rid of Key.needsSpecialPopupHint and related
Change-Id: I28e87ea3af9581f12094770b42f113e9018886c4
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java26
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
6 files changed, 30 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 028e3fda8..8330c3127 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -125,8 +125,6 @@ public class Key {
private boolean mHighlightOn;
/** Key is enabled and responds on press */
private boolean mEnabled = true;
- /** Whether this key needs to show the "..." popup hint for special purposes */
- private boolean mNeedsSpecialPopupHint;
// RTL parenthesis character swapping map.
private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>();
@@ -449,14 +447,6 @@ public class Key {
return (mLabelFlags & LABEL_FLAGS_HAS_POPUP_HINT) != 0;
}
- public void setNeedsSpecialPopupHint(boolean needsSpecialPopupHint) {
- mNeedsSpecialPopupHint = needsSpecialPopupHint;
- }
-
- public boolean needsSpecialPopupHint() {
- return mNeedsSpecialPopupHint;
- }
-
public boolean hasUppercaseLetter() {
return (mLabelFlags & LABEL_FLAGS_HAS_UPPERCASE_LETTER) != 0;
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index c7b600b97..16f27b499 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -165,8 +165,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
// If the cached keyboard had been switched to another keyboard while the language was
// displayed on its spacebar, it might have had arbitrary text fade factor. In such
// case, we should reset the text fade factor. It is also applicable to shortcut key.
+ mKeyboardView.updateSpacebar();
latinKeyboard.updateSpacebarLanguage(0.0f,
- Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale));
latinKeyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index e1c46178a..a174fd98f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -712,8 +712,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
- if ((key.hasPopupHint() && key.mMoreKeys != null && key.mMoreKeys.length > 0)
- || key.needsSpecialPopupHint()) {
+ if (key.hasPopupHint() && key.mMoreKeys != null && key.mMoreKeys.length > 0) {
drawKeyPopupHint(key, canvas, paint, params);
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index 655f16c8e..29791108d 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -55,10 +55,8 @@ public class LatinKeyboard extends Keyboard {
private final int mSpacebarTextShadowColor;
private final HashMap<Integer, BitmapDrawable> mSpaceDrawableCache =
new HashMap<Integer, BitmapDrawable>();
- private final boolean mIsSpacebarTriggeringPopupByLongPress;
private boolean mAutoCorrectionSpacebarLedOn;
- private boolean mMultipleEnabledIMEsOrSubtypes;
private boolean mNeedsToDisplayLanguage;
private float mSpacebarTextFadeFactor = 0.0f;
@@ -83,9 +81,6 @@ public class LatinKeyboard extends Keyboard {
mShortcutKey = getKey(CODE_SHORTCUT);
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
- final int longPressSpaceKeyTimeout =
- mRes.getInteger(R.integer.config_long_press_space_key_timeout);
- mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
@@ -123,10 +118,8 @@ public class LatinKeyboard extends Keyboard {
// TODO: Move this drawing method to LatinKeyboardView.
// TODO: Use Key.keyLabel to draw language name of spacebar.
- public Key updateSpacebarLanguage(float fadeFactor, boolean multipleEnabledIMEsOrSubtypes,
- boolean needsToDisplayLanguage) {
+ public Key updateSpacebarLanguage(float fadeFactor, boolean needsToDisplayLanguage) {
mSpacebarTextFadeFactor = fadeFactor;
- mMultipleEnabledIMEsOrSubtypes = multipleEnabledIMEsOrSubtypes;
mNeedsToDisplayLanguage = needsToDisplayLanguage;
updateSpacebarIcon();
return mSpaceKey;
@@ -173,9 +166,6 @@ public class LatinKeyboard extends Keyboard {
private void updateSpacebarIcon() {
if (mSpaceKey == null) return;
- final boolean shouldShowInputMethodPicker = mIsSpacebarTriggeringPopupByLongPress
- && mMultipleEnabledIMEsOrSubtypes;
- mSpaceKey.setNeedsSpecialPopupHint(shouldShowInputMethodPicker);
if (mNeedsToDisplayLanguage) {
mSpaceKey.setIcon(getSpaceDrawable(mId.mLocale));
} else if (mAutoCorrectionSpacebarLedOn) {
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index a5d928381..55fc5f92a 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Canvas;
+import android.graphics.Paint;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -60,6 +61,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
+ // For drawing spacebar.
+ private final boolean mIsSpacebarTriggeringPopupByLongPress;
+ private boolean mMultipleEnabledIMEsOrSubtypes;
+
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
// Timing constants
@@ -247,6 +252,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
PointerTracker.init(mHasDistinctMultitouch, getContext());
+
+ final int longPressSpaceKeyTimeout =
+ res.getInteger(R.integer.config_long_press_space_key_timeout);
+ mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
}
public void startIgnoringDoubleTap() {
@@ -685,4 +694,21 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
// Reflection doesn't support calling superclass methods.
return false;
}
+
+ public void updateSpacebar() {
+ mMultipleEnabledIMEsOrSubtypes = Utils.hasMultipleEnabledIMEsOrSubtypes(
+ true /* include aux subtypes */);
+ }
+
+ @Override
+ /* package */ void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint,
+ KeyDrawParams params) {
+ super.onDrawKeyTopVisuals(key, canvas, paint, params);
+
+ // Whether space key needs to show the "..." popup hint for special purposes
+ if (key.mCode == Keyboard.CODE_SPACE && mIsSpacebarTriggeringPopupByLongPress
+ && mMultipleEnabledIMEsOrSubtypes) {
+ super.drawKeyPopupHint(key, canvas, paint, params);
+ }
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index f24dc3fe3..64bd506f5 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -344,9 +344,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (inputView == null) return;
final Keyboard keyboard = inputView.getKeyboard();
if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
+ inputView.updateSpacebar();
final Key updatedKey = ((LatinKeyboard)keyboard).updateSpacebarLanguage(
fadeFactor,
- Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
SubtypeSwitcher.getInstance().needsToDisplayLanguage(keyboard.mId.mLocale));
inputView.invalidateKey(updatedKey);
}