From 0e300c83a12f64dbc8668b52bc02ec629abd4ca8 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 9 Sep 2010 11:57:55 +0900 Subject: Avoid a disk write on UI thread bug: 2983837 Change-Id: I4eca20fb4defcf149788032a98fe5894b57e1e19 --- java/src/com/android/inputmethod/latin/LanguageSwitcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java index 578c80526..d898d6830 100644 --- a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java +++ b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java @@ -188,7 +188,7 @@ public class LanguageSwitcher { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mIme); Editor editor = sp.edit(); editor.putString(LatinIME.PREF_INPUT_LANGUAGE, getInputLanguage()); - editor.commit(); + editor.apply(); } static String toTitleCase(String s) { -- cgit v1.2.3-83-g751a From 681b676b0aecb30e644f25550018ce2b6cea3e15 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 9 Sep 2010 01:41:58 +0900 Subject: Keep Keyboard in cache through SoftReference This change also adds final to attributes Change-Id: Ie2b9a1b1f83606b24ad4e35ad72a28d55ed0423e --- .../inputmethod/latin/KeyboardSwitcher.java | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 284b29305..01c099ee8 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -23,6 +23,7 @@ import android.content.res.Resources; import android.preference.PreferenceManager; import android.view.InflateException; +import java.lang.ref.SoftReference; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -76,14 +77,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha KEYBOARDMODE_IM, KEYBOARDMODE_WEB}; - Context mContext; - LatinIME mInputMethodService; + final Context mContext; + final LatinIME mInputMethodService; private KeyboardId mSymbolsId; private KeyboardId mSymbolsShiftedId; private KeyboardId mCurrentId; - private Map mKeyboards; + private final Map> mKeyboards; private int mMode = MODE_NONE; /** One of the MODE_XXX values */ private int mImeOptions; @@ -109,7 +110,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mLayoutId = Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID)); prefs.registerOnSharedPreferenceChangeListener(this); - mKeyboards = new HashMap(); + mKeyboards = new HashMap>(); mSymbolsId = makeSymbolsId(false); mSymbolsShiftedId = makeSymbolsShiftedId(false); mInputMethodService = ims; @@ -157,10 +158,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha * which also serve as a unique identifier for each keyboard type. */ private static class KeyboardId { - public int mXml; - public int mKeyboardMode; /** A KEYBOARDMODE_XXX value */ - public boolean mEnableShiftLock; - public boolean mHasVoice; + // TODO: should have locale and portrait/landscape orientation? + public final int mXml; + public final int mKeyboardMode; /** A KEYBOARDMODE_XXX value */ + public final boolean mEnableShiftLock; + public final boolean mHasVoice; public KeyboardId(int xml, int mode, boolean enableShiftLock, boolean hasVoice) { this.mXml = xml; @@ -178,10 +180,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return other instanceof KeyboardId && equals((KeyboardId) other); } - public boolean equals(KeyboardId other) { - return other.mXml == this.mXml - && other.mKeyboardMode == this.mKeyboardMode - && other.mEnableShiftLock == this.mEnableShiftLock; + private boolean equals(KeyboardId other) { + return other.mXml == this.mXml + && other.mKeyboardMode == this.mKeyboardMode + && other.mEnableShiftLock == this.mEnableShiftLock + && other.mHasVoice == this.mHasVoice; } @Override @@ -245,13 +248,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private LatinKeyboard getKeyboard(KeyboardId id) { - if (!mKeyboards.containsKey(id)) { + SoftReference ref = mKeyboards.get(id); + LatinKeyboard keyboard = (ref == null) ? null : ref.get(); + if (keyboard == null) { Resources orig = mContext.getResources(); Configuration conf = orig.getConfiguration(); Locale saveLocale = conf.locale; conf.locale = mInputLocale; orig.updateConfiguration(conf, null); - LatinKeyboard keyboard = new LatinKeyboard(mContext, id.mXml, id.mKeyboardMode); + keyboard = new LatinKeyboard(mContext, id.mXml, id.mKeyboardMode); keyboard.setVoiceMode(hasVoiceButton(id.mXml == R.xml.kbd_symbols || id.mXml == R.xml.kbd_symbols_black), mHasVoice); keyboard.setLanguageSwitcher(mLanguageSwitcher, mIsAutoCompletionActive, isBlackSym()); @@ -259,12 +264,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha if (id.mEnableShiftLock) { keyboard.enableShiftLock(); } - mKeyboards.put(id, keyboard); + mKeyboards.put(id, new SoftReference(keyboard)); conf.locale = saveLocale; orig.updateConfiguration(conf, null); } - return mKeyboards.get(id); + return keyboard; } private KeyboardId getKeyboardId(int mode, int imeOptions, boolean isSymbols) { -- cgit v1.2.3-83-g751a From efc4a437942f0bccd8815059c5f9d823023cfac1 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 9 Sep 2010 14:43:17 +0900 Subject: Symbol key acts as modifier key On a device that has distinct multi-touch panel, pressing '123?' key will change keyboard layout to symbol mode. While pressing '123?' key, you can press other symbol key to input. Then releasing '123?' key will change keyboard layout back to alphabet mode. Bug: 2973383 Change-Id: I3b069fb19141820def8060db4766a08c7c0a6ff0 --- .../com/android/inputmethod/latin/LatinIME.java | 33 ++++++++++++++-------- .../inputmethod/latin/LatinKeyboardView.java | 3 -- .../android/inputmethod/latin/PointerTracker.java | 27 +++++++++++------- 3 files changed, 38 insertions(+), 25 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ddfcaa9e3..f85206eff 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -229,8 +229,9 @@ public class LatinIME extends InputMethodService private int mDeleteCount; private long mLastKeyTime; - // Shift modifier key state + // Modifier keys state private ModifierKeyState mShiftKeyState = new ModifierKeyState(); + private ModifierKeyState mSymbolKeyState = new ModifierKeyState(); private Tutorial mTutorial; @@ -1133,6 +1134,7 @@ public class LatinIME extends InputMethodService mDeleteCount = 0; } mLastKeyTime = when; + final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch(); switch (primaryCode) { case Keyboard.KEYCODE_DELETE: handleBackspace(); @@ -1141,9 +1143,14 @@ public class LatinIME extends InputMethodService break; case Keyboard.KEYCODE_SHIFT: // Shift key is handled in onPress() when device has distinct multi-touch panel. - if (!mKeyboardSwitcher.hasDistinctMultitouch()) + if (!distinctMultiTouch) handleShift(); break; + case Keyboard.KEYCODE_MODE_CHANGE: + // Symbol key is handled in onPress() when device has distinct multi-touch panel. + if (!distinctMultiTouch) + changeKeyboardMode(); + break; case Keyboard.KEYCODE_CANCEL: if (!isShowingOptionDialog()) { handleClose(); @@ -1161,10 +1168,6 @@ public class LatinIME extends InputMethodService case LatinKeyboardView.KEYCODE_PREV_LANGUAGE: toggleLanguage(false, false); break; - case Keyboard.KEYCODE_MODE_CHANGE: - // TODO: Mode change (symbol key) should be handled in onPress(). - changeKeyboardMode(); - break; case LatinKeyboardView.KEYCODE_VOICE: if (VOICE_INSTALLED) { startListening(false /* was a button press, was not a swipe */); @@ -2210,13 +2213,16 @@ public class LatinIME extends InputMethodService public void onPress(int primaryCode) { vibrate(); playKeyClick(primaryCode); - if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { + final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch(); + if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) { mShiftKeyState.onPress(); handleShift(); - } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { - // TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well. + } else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { + mSymbolKeyState.onPress(); + changeKeyboardMode(); } else { mShiftKeyState.onOtherKeyPressed(); + mSymbolKeyState.onOtherKeyPressed(); } } @@ -2224,12 +2230,15 @@ public class LatinIME extends InputMethodService // Reset any drag flags in the keyboard ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased(); //vibrate(); - if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { + final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch(); + if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) { if (mShiftKeyState.isMomentary()) resetShift(); mShiftKeyState.onRelease(); - } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { - // TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well. + } else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { + if (mSymbolKeyState.isMomentary()) + changeKeyboardMode(); + mSymbolKeyState.onRelease(); } } diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index 8f20a22d0..c17d7c555 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -52,9 +52,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { /** The y coordinate of the last row */ private int mLastRowY; - // This is local working variable for onLongPress(). - private int[] mKeyCodes = new int[1]; - public LatinKeyboardView(Context context, AttributeSet attrs) { super(context, attrs); } diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index 8b1f019d4..e10c9b862 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -111,6 +111,8 @@ public class PointerTracker { throw new IllegalArgumentException(); mKeys = keys; mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel); + // Update current key index because keyboard layout has been changed. + mCurrentKey = mKeyDetector.getKeyIndexAndNearbyCodes(mStartX, mStartY, null); } private boolean isValidKeyIndex(int keyIndex) { @@ -126,8 +128,8 @@ public class PointerTracker { if (key == null) return false; int primaryCode = key.codes[0]; - // TODO: KEYCODE_MODE_CHANGE (symbol) will be also a modifier key - return primaryCode == Keyboard.KEYCODE_SHIFT; + return primaryCode == Keyboard.KEYCODE_SHIFT + || primaryCode == Keyboard.KEYCODE_MODE_CHANGE; } public void updateKey(int keyIndex) { @@ -173,6 +175,8 @@ public class PointerTracker { } public void onDownEvent(int x, int y, long eventTime) { + if (DEBUG) + debugLog("onDownEvent:", x, y); int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); mCurrentKey = keyIndex; mStartX = x; @@ -186,6 +190,8 @@ public class PointerTracker { if (mListener != null) { int primaryCode = isValidKeyIndex(keyIndex) ? mKeys[keyIndex].codes[0] : 0; mListener.onPress(primaryCode); + // This onPress call may have changed keyboard layout and have updated mCurrentKey + keyIndex = mCurrentKey; } if (isValidKeyIndex(keyIndex)) { if (mKeys[keyIndex].repeatable) { @@ -197,11 +203,11 @@ public class PointerTracker { } showKeyPreviewAndUpdateKey(keyIndex); updateMoveDebouncing(x, y); - if (DEBUG) - debugLog("onDownEvent:", x, y); } public void onMoveEvent(int x, int y, long eventTime) { + if (DEBUG_MOVE) + debugLog("onMoveEvent:", x, y); if (mKeyAlreadyProcessed) return; int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); @@ -242,15 +248,13 @@ public class PointerTracker { */ showKeyPreviewAndUpdateKey(isMinorTimeBounce() ? mLastKey : mCurrentKey); updateMoveDebouncing(x, y); - if (DEBUG_MOVE) - debugLog("onMoveEvent:", x, y); } public void onUpEvent(int x, int y, long eventTime) { - if (mKeyAlreadyProcessed) - return; if (DEBUG) debugLog("onUpEvent :", x, y); + if (mKeyAlreadyProcessed) + return; mHandler.cancelKeyTimers(); mHandler.cancelPopupPreview(); int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); @@ -384,8 +388,11 @@ public class PointerTracker { // The modifier key, such as shift key, should not be shown as preview when multi-touch is // supported. On thge other hand, if multi-touch is not supported, the modifier key should // be shown as preview. - if (!isModifier() || !mHasDistinctMultitouch) + if (mHasDistinctMultitouch && isModifier()) { + mProxy.showPreview(NOT_A_KEY, this); + } else { mProxy.showPreview(keyIndex, this); + } } private void detectAndSendKey(int index, int x, int y, long eventTime) { @@ -478,7 +485,7 @@ public class PointerTracker { } private void debugLog(String title, int x, int y) { - Key key = getKey(mCurrentKey); + Key key = getKey(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null)); final String code; if (key == null) { code = "----"; -- cgit v1.2.3-83-g751a From 3de8f34b8c8c7113386b6cd7c9101ef20df6ec7d Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 10 Sep 2010 13:15:45 +0900 Subject: Code cleanup Change-Id: I333693ab8e4088180cc25768d874ad7320d9da8b --- .../inputmethod/latin/LatinKeyboardBaseView.java | 41 +++++++++------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 8f1ec6591..45ecca35e 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -180,7 +180,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private Key[] mKeys; // Key preview popup - private final static boolean PREVIEW_CENTERED = false; private TextView mPreviewText; private PopupWindow mPreviewPopup; private int mPreviewTextSizeLarge; @@ -188,8 +187,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private int mOldPreviewKeyIndex = NOT_A_KEY; private boolean mShowPreview = true; private boolean mShowTouchPoints = true; - private int mPopupPreviewX; - private int mPopupPreviewY; private int mPopupPreviewOffsetX; private int mPopupPreviewOffsetY; private int mWindowY; @@ -869,7 +866,6 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx Key key = tracker.getKey(keyIndex); if (key == null) return; - final PopupWindow previewPopup = mPreviewPopup; if (key.icon != null) { mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon); @@ -895,14 +891,10 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx lp.width = popupWidth; lp.height = popupHeight; } - if (PREVIEW_CENTERED) { - // TODO: Fix this if centering is brought back - mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2; - mPopupPreviewY = - mPreviewText.getMeasuredHeight(); - } else { - mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft(); - mPopupPreviewY = key.y - popupHeight + mPreviewOffset; - } + + int popupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft(); + int popupPreviewY = key.y - popupHeight + mPreviewOffset; + mHandler.cancelDismissPreview(); if (mOffsetInWindow == null) { mOffsetInWindow = new int[2]; @@ -916,29 +908,28 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Set the preview background state mPreviewText.getBackground().setState( key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET); - mPopupPreviewX += mOffsetInWindow[0]; - mPopupPreviewY += mOffsetInWindow[1]; + popupPreviewX += mOffsetInWindow[0]; + popupPreviewY += mOffsetInWindow[1]; // If the popup cannot be shown above the key, put it on the side - if (mPopupPreviewY + mWindowY < 0) { + if (popupPreviewY + mWindowY < 0) { // If the key you're pressing is on the left side of the keyboard, show the popup on // the right, offset by enough to see at least one key to the left/right. if (key.x + key.width <= getWidth() / 2) { - mPopupPreviewX += (int) (key.width * 2.5); + popupPreviewX += (int) (key.width * 2.5); } else { - mPopupPreviewX -= (int) (key.width * 2.5); + popupPreviewX -= (int) (key.width * 2.5); } - mPopupPreviewY += popupHeight; + popupPreviewY += popupHeight; } - if (previewPopup.isShowing()) { - previewPopup.update(mPopupPreviewX, mPopupPreviewY, - popupWidth, popupHeight); + if (mPreviewPopup.isShowing()) { + mPreviewPopup.update(popupPreviewX, popupPreviewY, popupWidth, popupHeight); } else { - previewPopup.setWidth(popupWidth); - previewPopup.setHeight(popupHeight); - previewPopup.showAtLocation(mMiniKeyboardParent, Gravity.NO_GRAVITY, - mPopupPreviewX, mPopupPreviewY); + mPreviewPopup.setWidth(popupWidth); + mPreviewPopup.setHeight(popupHeight); + mPreviewPopup.showAtLocation(mMiniKeyboardParent, Gravity.NO_GRAVITY, + popupPreviewX, popupPreviewY); } mPreviewText.setVisibility(VISIBLE); } -- cgit v1.2.3-83-g751a From f62166c13bdf7fe99092565dd0425d8693a5cec8 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 10 Sep 2010 15:41:55 +0900 Subject: Mini popup keyboard adjustment: Have the leftmost number right above the key. Also fixed an issue when the mini popup keyboard hits the right edge of the view. A few code cleanups as well. bug: 2980864 Change-Id: I95f8392521e57560907d54b662e3483ebaf6f7ce --- .../inputmethod/latin/LatinKeyboardBaseView.java | 48 ++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 45ecca35e..5732cf703 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -989,8 +989,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx if (container == null) throw new NullPointerException(); - mMiniKeyboard = (LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView); - mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() { + LatinKeyboardBaseView miniKeyboard = + (LatinKeyboardBaseView)container.findViewById(R.id.LatinKeyboardBaseView); + miniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() { public void onKey(int primaryCode, int[] keyCodes, int x, int y) { mKeyboardActionListener.onKey(primaryCode, keyCodes, x, y); dismissPopupKeyboard(); @@ -1028,8 +1029,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } else { keyboard = new Keyboard(getContext(), popupKeyboardId); } - mMiniKeyboard.setKeyboard(keyboard); - mMiniKeyboard.setPopupParent(this); + miniKeyboard.setKeyboard(keyboard); + miniKeyboard.setPopupParent(this); container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST)); @@ -1061,17 +1062,38 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mWindowOffset = new int[2]; getLocationInWindow(mWindowOffset); } - int popupX = popupKey.x + popupKey.width + getPaddingLeft(); - int popupY = popupKey.y + getPaddingTop(); - popupX -= container.getMeasuredWidth(); + + // HACK: Have the leftmost number in the popup characters right above the key + boolean isNumberAtLeftmost = false; + if (popupKey.popupCharacters != null && popupKey.popupCharacters.length() > 1) { + char leftmostChar = popupKey.popupCharacters.charAt(0); + isNumberAtLeftmost = leftmostChar >= '0' && leftmostChar <= '9'; + } + + int popupX = popupKey.x + mWindowOffset[0]; + int popupY = popupKey.y + mWindowOffset[1]; + if (isNumberAtLeftmost) { + popupX -= container.getPaddingLeft(); + } else { + popupX += popupKey.width + getPaddingLeft(); + popupX -= container.getMeasuredWidth(); + popupX += container.getPaddingRight(); + } + popupY += getPaddingTop(); popupY -= container.getMeasuredHeight(); - popupX += mWindowOffset[0]; - popupY += mWindowOffset[1]; - final int x = popupX + container.getPaddingRight(); - final int y = popupY + container.getPaddingBottom(); - mMiniKeyboardOriginX = (x < 0 ? 0 : x) + container.getPaddingLeft(); + popupY += container.getPaddingBottom(); + final int x = popupX; + final int y = popupY; + + int adjustedX = x; + if (x < 0) { + adjustedX = 0; + } else if (x > (getMeasuredWidth() - container.getMeasuredWidth())) { + adjustedX = getMeasuredWidth() - container.getMeasuredWidth(); + } + mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft(); mMiniKeyboardOriginY = y + container.getPaddingTop(); - mMiniKeyboard.setPopupOffset((x < 0) ? 0 : x, y); + mMiniKeyboard.setPopupOffset(adjustedX, y); mMiniKeyboard.setShifted(isShifted()); // Mini keyboard needs no pop-up key preview displayed. mMiniKeyboard.setPreviewEnabled(false); -- cgit v1.2.3-83-g751a From aed0122734a6257e17068539950e78957266f35b Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Sun, 12 Sep 2010 19:08:41 +0900 Subject: Fix a bug in y-axis offset for sliding finger key detection for mini popup keyboard. Also, tentatively added key detection allowance for below of the keys in mini popup keyboard. bug: 2979407 Change-Id: I84794969facd929c84df23e0120d46dff71c6efb --- java/res/values/attrs.xml | 3 +++ java/res/values/styles.xml | 1 + .../android/inputmethod/latin/LatinKeyboardBaseView.java | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'java/src') diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index e3171eb33..a8eaab9a3 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -46,6 +46,9 @@ + + + diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 16478c883..6ec428603 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -27,6 +27,7 @@ 14sp @layout/keyboard_popup_keyboard -10dip + 30dip #BB000000 2.75 0.5 diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 5732cf703..610d95423 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -200,6 +200,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private int mMiniKeyboardOriginY; private long mMiniKeyboardPopupTime; private int[] mWindowOffset; + private float mMiniKeyboardSlideAllowance; /** Listener for {@link OnKeyboardActionListener}. */ private OnKeyboardActionListener mKeyboardActionListener; @@ -388,6 +389,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx case R.styleable.LatinKeyboardBaseView_verticalCorrection: mVerticalCorrection = a.getDimensionPixelOffset(attr, 0); break; + case R.styleable.LatinKeyboardBaseView_miniKeyboardSlideAllowance: + mMiniKeyboardSlideAllowance = a.getDimensionPixelOffset(attr, 0); + break; case R.styleable.LatinKeyboardBaseView_keyPreviewLayout: previewLayout = a.getResourceId(attr, 0); break; @@ -1091,8 +1095,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } else if (x > (getMeasuredWidth() - container.getMeasuredWidth())) { adjustedX = getMeasuredWidth() - container.getMeasuredWidth(); } - mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft(); - mMiniKeyboardOriginY = y + container.getPaddingTop(); + mMiniKeyboardOriginX = adjustedX + container.getPaddingLeft() - mWindowOffset[0]; + mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1]; mMiniKeyboard.setPopupOffset(adjustedX, y); mMiniKeyboard.setShifted(isShifted()); // Mini keyboard needs no pop-up key preview displayed. @@ -1116,7 +1120,12 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) { return MotionEvent.obtain(mMiniKeyboardPopupTime, eventTime, action, - x - mMiniKeyboardOriginX, y - mMiniKeyboardOriginY, 0); + x - mMiniKeyboardOriginX, + // TODO: Currently just taking care of "below" of the keys in a mini popup keyboard + // for key detection by sliding finger. Need to take care of left, right, and + // upper of "edge" keys. + y - mMiniKeyboardOriginY - (int)mMiniKeyboardSlideAllowance, + 0); } private PointerTracker getPointerTracker(final int id) { -- cgit v1.2.3-83-g751a From 0ea6270ffbe75eba2a754f8107487f3e0c1485a3 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Sun, 12 Sep 2010 21:05:25 +0900 Subject: More commit -> apply changes with SharedPreferencesCompat. The newly added SharedPreferencesCompat adapter class does apply() when available (Gingerbread+), else do commit(). This change incorporates I4eca20fb and I39f6aa04. bug: 2983837 Change-Id: Iec4e8b69840ad71dbbd6098eeba349934d8248ff --- java/src/com/android/inputmethod/latin/Hints.java | 6 +-- .../inputmethod/latin/InputLanguageSelection.java | 2 +- .../inputmethod/latin/LanguageSwitcher.java | 2 +- .../com/android/inputmethod/latin/LatinIME.java | 4 +- .../inputmethod/latin/SharedPreferencesCompat.java | 54 ++++++++++++++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/Hints.java b/java/src/com/android/inputmethod/latin/Hints.java index 2434d5195..c467365e7 100644 --- a/java/src/com/android/inputmethod/latin/Hints.java +++ b/java/src/com/android/inputmethod/latin/Hints.java @@ -106,7 +106,7 @@ public class Hints { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit(); editor.putLong(PREF_VOICE_INPUT_LAST_TIME_USED, System.currentTimeMillis()); - editor.commit(); + SharedPreferencesCompat.apply(editor); mVoiceResultContainedPunctuation = false; for (CharSequence s : SPEAKABLE_PUNCTUATION.keySet()) { @@ -168,7 +168,7 @@ public class Hints { SharedPreferences.Editor editor = sp.edit(); editor.putInt(PREF_VOICE_HINT_NUM_UNIQUE_DAYS_SHOWN, numUniqueDaysShown + 1); editor.putLong(PREF_VOICE_HINT_LAST_TIME_SHOWN, System.currentTimeMillis()); - editor.commit(); + SharedPreferencesCompat.apply(editor); } if (mDisplay != null) { @@ -181,7 +181,7 @@ public class Hints { int value = sp.getInt(pref, 0); SharedPreferences.Editor editor = sp.edit(); editor.putInt(pref, value + 1); - editor.commit(); + SharedPreferencesCompat.apply(editor); return value; } } diff --git a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java index 7258874c0..e811a2cdd 100644 --- a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java +++ b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java @@ -143,7 +143,7 @@ public class InputLanguageSelection extends PreferenceActivity { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = sp.edit(); editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages); - editor.commit(); + SharedPreferencesCompat.apply(editor); } ArrayList getUniqueLocales() { diff --git a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java index d898d6830..7b5c30491 100644 --- a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java +++ b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java @@ -188,7 +188,7 @@ public class LanguageSwitcher { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mIme); Editor editor = sp.edit(); editor.putString(LatinIME.PREF_INPUT_LANGUAGE, getInputLanguage()); - editor.apply(); + SharedPreferencesCompat.apply(editor); } static String toTitleCase(String s) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f85206eff..50fc4840d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1551,7 +1551,7 @@ public class LatinIME extends InputMethodService SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putBoolean(PREF_HAS_USED_VOICE_INPUT, true); - editor.commit(); + SharedPreferencesCompat.apply(editor); mHasUsedVoiceInput = true; } @@ -1561,7 +1561,7 @@ public class LatinIME extends InputMethodService SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE, true); - editor.commit(); + SharedPreferencesCompat.apply(editor); mHasUsedVoiceInputUnsupportedLocale = true; } diff --git a/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java b/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java new file mode 100644 index 000000000..8364c90fa --- /dev/null +++ b/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin; + +import android.content.SharedPreferences; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Reflection utils to call SharedPreferences$Editor.apply when possible, + * falling back to commit when apply isn't available. + */ +public class SharedPreferencesCompat { + private static final Method sApplyMethod = findApplyMethod(); + + private static Method findApplyMethod() { + try { + Class cls = SharedPreferences.Editor.class; + return cls.getMethod("apply"); + } catch (NoSuchMethodException unused) { + // fall through + } + return null; + } + + public static void apply(SharedPreferences.Editor editor) { + if (sApplyMethod != null) { + try { + sApplyMethod.invoke(editor); + return; + } catch (InvocationTargetException unused) { + // fall through + } catch (IllegalAccessException unused) { + // fall through + } + } + editor.commit(); + } +} -- cgit v1.2.3-83-g751a From eb68036798f53763768e4ab37c7bfab9a2f36025 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 13 Sep 2010 19:26:23 +0900 Subject: Add keyHysteresisDistance xml attribute This change also introduces MiniKeyboardKeyDetector and mini_keyboad_slide_allowance parameter to tune the key detection behavior. Bug: 2993769 Change-Id: I1932b0a382e172cb77b9e098ae182049c834dfe0 --- java/res/layout/keyboard_popup.xml | 2 + java/res/values-land/dimens.xml | 5 +- java/res/values/attrs.xml | 6 +-- java/res/values/dimens.xml | 4 +- java/res/values/styles.xml | 2 +- .../inputmethod/latin/LatinKeyboardBaseView.java | 25 ++++----- .../inputmethod/latin/MiniKeyboardKeyDetector.java | 59 ++++++++++++++++++++++ .../android/inputmethod/latin/PointerTracker.java | 13 +++-- 8 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java (limited to 'java/src') diff --git a/java/res/layout/keyboard_popup.xml b/java/res/layout/keyboard_popup.xml index 1005e7e11..9a52e2cbd 100644 --- a/java/res/layout/keyboard_popup.xml +++ b/java/res/layout/keyboard_popup.xml @@ -33,5 +33,7 @@ android:background="@drawable/keyboard_dark_background" latin:keyBackground="@drawable/btn_keyboard_key_gingerbread_popup" + latin:keyHysteresisDistance="0dip" + latin:verticalCorrection="-20dip" /> diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index 43951552e..4f87b79d2 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -22,4 +22,7 @@ 47dip 38dip 2dip - \ No newline at end of file + + + 79.9dip + diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index a8eaab9a3..995373e84 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -43,12 +43,12 @@ + + + - - - diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 39dce9db0..af8b38110 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -27,5 +27,7 @@ will not go into extract (fullscreen) mode. --> 2.5in 22sp - 0.05in + + + 91.8dip diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 48f0d5e54..258082eb6 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -26,8 +26,8 @@ 80dip 14sp @layout/keyboard_popup + 0.05in -10dip - 40dip #BB000000 2.75 0.5 diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 610d95423..a78e2b869 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -170,6 +170,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private float mShadowRadius; private Drawable mKeyBackground; private float mBackgroundDimAmount; + private float mKeyHysteresisDistance; private float mVerticalCorrection; private int mPreviewOffset; private int mPreviewHeight; @@ -200,14 +201,13 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private int mMiniKeyboardOriginY; private long mMiniKeyboardPopupTime; private int[] mWindowOffset; - private float mMiniKeyboardSlideAllowance; + private final float mMiniKeyboardSlideAllowance; /** Listener for {@link OnKeyboardActionListener}. */ private OnKeyboardActionListener mKeyboardActionListener; private final ArrayList mPointerTrackers = new ArrayList(); private final PointerQueue mPointerQueue = new PointerQueue(); - private final float mDebounceHysteresis; private final boolean mHasDistinctMultitouch; private int mOldPointerCount = 1; @@ -386,12 +386,12 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx case R.styleable.LatinKeyboardBaseView_keyBackground: mKeyBackground = a.getDrawable(attr); break; + case R.styleable.LatinKeyboardBaseView_keyHysteresisDistance: + mKeyHysteresisDistance = a.getDimensionPixelOffset(attr, 0); + break; case R.styleable.LatinKeyboardBaseView_verticalCorrection: mVerticalCorrection = a.getDimensionPixelOffset(attr, 0); break; - case R.styleable.LatinKeyboardBaseView_miniKeyboardSlideAllowance: - mMiniKeyboardSlideAllowance = a.getDimensionPixelOffset(attr, 0); - break; case R.styleable.LatinKeyboardBaseView_keyPreviewLayout: previewLayout = a.getResourceId(attr, 0); break; @@ -473,7 +473,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density); // TODO: Refer frameworks/base/core/res/res/values/config.xml mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation); - mDebounceHysteresis = res.getDimension(R.dimen.key_debounce_hysteresis_distance); + mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance); GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() { @@ -556,7 +556,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mKeys = mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection); for (PointerTracker tracker : mPointerTrackers) { - tracker.setKeyboard(mKeys, mDebounceHysteresis); + tracker.setKeyboard(mKeys, mKeyHysteresisDistance); } requestLayout(); // Hint to reallocate the buffer if the size changed @@ -1025,6 +1025,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mKeyboardActionListener.onRelease(primaryCode); } }); + // Override default ProximityKeyDetector. + miniKeyboard.mKeyDetector = new MiniKeyboardKeyDetector(mMiniKeyboardSlideAllowance); Keyboard keyboard; if (popupKey.popupCharacters != null) { @@ -1120,12 +1122,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) { return MotionEvent.obtain(mMiniKeyboardPopupTime, eventTime, action, - x - mMiniKeyboardOriginX, - // TODO: Currently just taking care of "below" of the keys in a mini popup keyboard - // for key detection by sliding finger. Need to take care of left, right, and - // upper of "edge" keys. - y - mMiniKeyboardOriginY - (int)mMiniKeyboardSlideAllowance, - 0); + x - mMiniKeyboardOriginX, y - mMiniKeyboardOriginY, 0); } private PointerTracker getPointerTracker(final int id) { @@ -1138,7 +1135,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx final PointerTracker tracker = new PointerTracker(i, mHandler, mKeyDetector, this, mHasDistinctMultitouch); if (keys != null) - tracker.setKeyboard(keys, mDebounceHysteresis); + tracker.setKeyboard(keys, mKeyHysteresisDistance); if (listener != null) tracker.setOnKeyboardActionListener(listener); pointers.add(tracker); diff --git a/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java new file mode 100644 index 000000000..709d082be --- /dev/null +++ b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.inputmethod.latin; + +import android.inputmethodservice.Keyboard.Key; + +class MiniKeyboardKeyDetector extends KeyDetector { + private static final int MAX_NEARBY_KEYS = 1; + + private final int mSlideAllowanceSquare; + private final int mSlideAllowanceSquareTop; + + public MiniKeyboardKeyDetector(float slideAllowance) { + super(); + mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance); + // Top slide allowance is slightly longer (sqrt(2) times) than other edges. + mSlideAllowanceSquareTop = mSlideAllowanceSquare * 2; + } + + @Override + protected int getMaxNearbyKeys() { + return MAX_NEARBY_KEYS; + } + + @Override + public int getKeyIndexAndNearbyCodes(int x, int y, int[] allKeys) { + final Key[] keys = getKeys(); + final int touchX = getTouchX(x); + final int touchY = getTouchY(y); + int closestKey = LatinKeyboardBaseView.NOT_A_KEY; + int closestKeyDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare; + final int keyCount = keys.length; + for (int i = 0; i < keyCount; i++) { + final Key key = keys[i]; + int dist = key.squaredDistanceFrom(touchX, touchY); + if (dist < closestKeyDist) { + closestKey = i; + closestKeyDist = dist; + } + } + if (allKeys != null && closestKey != LatinKeyboardBaseView.NOT_A_KEY) + allKeys[0] = closestKey; + return closestKey; + } +} diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index e10c9b862..958e57618 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -55,7 +55,7 @@ public class PointerTracker { private final boolean mHasDistinctMultitouch; private Key[] mKeys; - private int mKeyDebounceThresholdSquared = -1; + private int mKeyHysteresisDistanceSquared = -1; private int mCurrentKey = NOT_A_KEY; private int mStartX; @@ -106,11 +106,11 @@ public class PointerTracker { mListener = listener; } - public void setKeyboard(Key[] keys, float hysteresisPixel) { - if (keys == null || hysteresisPixel < 1.0f) + public void setKeyboard(Key[] keys, float keyHysteresisDistance) { + if (keys == null || keyHysteresisDistance < 0) throw new IllegalArgumentException(); mKeys = keys; - mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel); + mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance); // Update current key index because keyboard layout has been changed. mCurrentKey = mKeyDetector.getKeyIndexAndNearbyCodes(mStartX, mStartY, null); } @@ -335,13 +335,12 @@ public class PointerTracker { } private boolean isMinorMoveBounce(int x, int y, int newKey, int curKey) { - if (mKeys == null || mKeyDebounceThresholdSquared < 0) + if (mKeys == null || mKeyHysteresisDistanceSquared < 0) throw new IllegalStateException("keyboard and/or hysteresis not set"); if (newKey == curKey) { return true; } else if (isValidKeyIndex(curKey)) { - return getSquareDistanceToKeyEdge(x, y, mKeys[curKey]) - < mKeyDebounceThresholdSquared; + return getSquareDistanceToKeyEdge(x, y, mKeys[curKey]) < mKeyHysteresisDistanceSquared; } else { return false; } -- cgit v1.2.3-83-g751a From 12a4e08a6440c95f29dc04efe83515a4ed045487 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 14 Sep 2010 16:22:08 +0900 Subject: Handling multi-character uppercase key input Change-Id: Ie0820a2627e18109036d5f6f286d5a366c9b9f87 --- java/src/com/android/inputmethod/latin/LatinIME.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 50fc4840d..4e8723c76 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1348,14 +1348,21 @@ public class LatinIME extends InputMethodService } } if (mKeyboardSwitcher.getInputView().isShifted()) { - // TODO: This doesn't work with [beta], need to fix it in the next release. if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT || keyCodes[0] > Character.MAX_CODE_POINT) { return; } primaryCode = keyCodes[0]; - if (mKeyboardSwitcher.isAlphabetMode()) { - primaryCode = Character.toUpperCase(primaryCode); + if (mKeyboardSwitcher.isAlphabetMode() && Character.isLowerCase(primaryCode)) { + int upperCaseCode = Character.toUpperCase(primaryCode); + if (upperCaseCode != primaryCode) { + primaryCode = upperCaseCode; + } else { + // Some keys, such as [eszett], have upper case as multi-characters. + String upperCase = new String(new int[] {primaryCode}, 0, 1).toUpperCase(); + onText(upperCase); + return; + } } } if (mPredicting) { -- cgit v1.2.3-83-g751a From 2aa8078df86029dab394d8dd616f4f6decb39035 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 15 Sep 2010 15:02:29 +0900 Subject: All keys should be processed before processing modifier key Bug: 2987077 Change-Id: I971c44be121d8780ec27aa1649fd0925e249fbbc --- .../inputmethod/latin/LatinKeyboardBaseView.java | 36 ++++++++++++++++++---- .../android/inputmethod/latin/PointerTracker.java | 12 ++++++-- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index a78e2b869..3ae2e1c53 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -345,7 +345,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return -1; } - public void releasePointersOlderThan(PointerTracker tracker, long eventTime) { + public void releaseAllPointersOlderThan(PointerTracker tracker, long eventTime) { LinkedList queue = mQueue; int oldestPos = 0; for (PointerTracker t = queue.get(oldestPos); t != tracker; t = queue.get(oldestPos)) { @@ -353,11 +353,24 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx oldestPos++; } else { t.onUpEvent(t.getLastX(), t.getLastY(), eventTime); + t.setAlreadyProcessed(); queue.remove(oldestPos); } } } + public void releaseAllPointersExcept(PointerTracker tracker, long eventTime) { + for (PointerTracker t : mQueue) { + if (t == tracker) + continue; + t.onUpEvent(t.getLastX(), t.getLastY(), eventTime); + t.setAlreadyProcessed(); + } + mQueue.clear(); + if (tracker != null) + mQueue.add(tracker); + } + public void remove(PointerTracker tracker) { mQueue.remove(tracker); } @@ -1246,17 +1259,28 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } private void onDownEvent(PointerTracker tracker, int x, int y, long eventTime) { + if (tracker.isOnModifierKey(x, y)) { + // Before processing a down event of modifier key, all pointers already being tracked + // should be released. + mPointerQueue.releaseAllPointersExcept(null, eventTime); + } tracker.onDownEvent(x, y, eventTime); mPointerQueue.add(tracker); } private void onUpEvent(PointerTracker tracker, int x, int y, long eventTime) { - int index = mPointerQueue.lastIndexOf(tracker); - if (index >= 0) { - mPointerQueue.releasePointersOlderThan(tracker, eventTime); + if (tracker.isModifier()) { + // Before processing an up event of modifier key, all pointers already being tracked + // should be released. + mPointerQueue.releaseAllPointersExcept(tracker, eventTime); } else { - Log.w(TAG, "onUpEvent: corresponding down event not found for pointer " - + tracker.mPointerId); + int index = mPointerQueue.lastIndexOf(tracker); + if (index >= 0) { + mPointerQueue.releaseAllPointersOlderThan(tracker, eventTime); + } else { + Log.w(TAG, "onUpEvent: corresponding down event not found for pointer " + + tracker.mPointerId); + } } tracker.onUpEvent(x, y, eventTime); mPointerQueue.remove(tracker); diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index 958e57618..a612c8eec 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -123,8 +123,8 @@ public class PointerTracker { return isValidKeyIndex(keyIndex) ? mKeys[keyIndex] : null; } - public boolean isModifier() { - Key key = getKey(mCurrentKey); + private boolean isModifierInternal(int keyIndex) { + Key key = getKey(keyIndex); if (key == null) return false; int primaryCode = key.codes[0]; @@ -132,6 +132,14 @@ public class PointerTracker { || primaryCode == Keyboard.KEYCODE_MODE_CHANGE; } + public boolean isModifier() { + return isModifierInternal(mCurrentKey); + } + + public boolean isOnModifierKey(int x, int y) { + return isModifierInternal(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null)); + } + public void updateKey(int keyIndex) { if (mKeyAlreadyProcessed) return; -- cgit v1.2.3-83-g751a From bd1cc1da005fe477bf28afce43d5572e381b4757 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 15 Sep 2010 18:14:07 +0900 Subject: Fix bug that upper case mini-keyboard does not work This issue is introduced by I1932b0a382e172cb77b9e098ae182049c834dfe0 Bug: 2993769 Change-Id: I344d21e046b58b3bb9831605a7425a94c97d8492 --- .../com/android/inputmethod/latin/MiniKeyboardKeyDetector.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java index 709d082be..356e62d48 100644 --- a/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java +++ b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java @@ -41,19 +41,19 @@ class MiniKeyboardKeyDetector extends KeyDetector { final Key[] keys = getKeys(); final int touchX = getTouchX(x); final int touchY = getTouchY(y); - int closestKey = LatinKeyboardBaseView.NOT_A_KEY; + int closestKeyIndex = LatinKeyboardBaseView.NOT_A_KEY; int closestKeyDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare; final int keyCount = keys.length; for (int i = 0; i < keyCount; i++) { final Key key = keys[i]; int dist = key.squaredDistanceFrom(touchX, touchY); if (dist < closestKeyDist) { - closestKey = i; + closestKeyIndex = i; closestKeyDist = dist; } } - if (allKeys != null && closestKey != LatinKeyboardBaseView.NOT_A_KEY) - allKeys[0] = closestKey; - return closestKey; + if (allKeys != null && closestKeyIndex != LatinKeyboardBaseView.NOT_A_KEY) + allKeys[0] = keys[closestKeyIndex].codes[0]; + return closestKeyIndex; } } -- cgit v1.2.3-83-g751a From c1020c3aa65b1eef4c672564750c020d012c4ec2 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 14 Sep 2010 21:03:34 -0700 Subject: Fix : Bouncing Extract Text when correcting multiple lines of text. Bug: 2996887 Override the methods in InputMethodService that hide the candidates view, since it was just an optimization to show more lines of text when editing, which conflicts with the re-correct feature. Change-Id: Ibfed5ccd9efa048d0b69297a5cf8a638a0d00c72 --- .../com/android/inputmethod/latin/LatinIME.java | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4e8723c76..f80ecc6d4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at @@ -262,7 +262,7 @@ public class LatinIME extends InputMethodService List candidates; Map> alternatives; } - + public abstract static class WordAlternatives { protected CharSequence mChosenWord; @@ -795,6 +795,37 @@ public class LatinIME extends InputMethodService } } + /** + * This is called when the user has clicked on the extracted text view, + * when running in fullscreen mode. The default implementation hides + * the candidates view when this happens, but only if the extracted text + * editor has a vertical scroll bar because its text doesn't fit. + * Here we override the behavior due to the possibility that a re-correction could + * cause the candidate strip to disappear and re-appear. + */ + @Override + public void onExtractedTextClicked() { + if (mReCorrectionEnabled && isPredictionOn()) return; + + super.onExtractedTextClicked(); + } + + /** + * This is called when the user has performed a cursor movement in the + * extracted text view, when it is running in fullscreen mode. The default + * implementation hides the candidates view when a vertical movement + * happens, but only if the extracted text editor has a vertical scroll bar + * because its text doesn't fit. + * Here we override the behavior due to the possibility that a re-correction could + * cause the candidate strip to disappear and re-appear. + */ + @Override + public void onExtractedCursorMovement(int dx, int dy) { + if (mReCorrectionEnabled && isPredictionOn()) return; + + super.onExtractedCursorMovement(dx, dy); + } + @Override public void hideWindow() { LatinImeLogger.commit(); -- cgit v1.2.3-83-g751a From 1508c0e84f0cd93ab6f5d46fea5026e833f299bc Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Wed, 15 Sep 2010 13:37:52 +0900 Subject: Add a new preference item to show/hide the settings key. bug: 2998722 Change-Id: Iac1641c338388fd8f85e0cf47e31afdaeb34c0c0 --- java/res/values/donottranslate.xml | 8 + java/res/values/strings.xml | 21 +++ java/res/xml-da/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-da/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-de/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-de/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-fr/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-fr/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-iw/kbd_qwerty.xml | 208 +++++++++++++++++++-- java/res/xml-iw/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-nb/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-nb/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-ru/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-ru/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-sr/kbd_qwerty.xml | 208 +++++++++++++++++++-- java/res/xml-sr/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml-sv/kbd_qwerty.xml | 204 ++++++++++++++++++-- java/res/xml-sv/kbd_qwerty_black.xml | 206 ++++++++++++++++---- java/res/xml/kbd_qwerty.xml | 194 +++++++++++++++++-- java/res/xml/kbd_qwerty_black.xml | 196 +++++++++++++++---- java/res/xml/kbd_symbols.xml | 30 ++- java/res/xml/kbd_symbols_black.xml | 33 +++- java/res/xml/kbd_symbols_shift.xml | 29 ++- java/res/xml/kbd_symbols_shift_black.xml | 32 +++- java/res/xml/prefs.xml | 9 + .../inputmethod/latin/KeyboardSwitcher.java | 106 +++++++++-- .../com/android/inputmethod/latin/LatinIME.java | 13 +- .../inputmethod/latin/LatinIMESettings.java | 13 +- .../android/inputmethod/latin/LatinIMEUtil.java | 8 + .../inputmethod/latin/LatinKeyboardBaseView.java | 2 +- 30 files changed, 3473 insertions(+), 509 deletions(-) (limited to 'java/src') diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 971e22965..936609924 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -24,4 +24,12 @@ .,!?) !?,\u0022\u0027:()-/@_ + + + + 0 + + 1 + + 2 diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index bf8e987c9..56dceef2d 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -91,6 +91,27 @@ Spacebar and punctuation automatically insert highlighted word + + Show settings key + + + @string/settings_key_mode_auto + @string/settings_key_mode_always_show + @string/settings_key_mode_always_hide + + + Automatic + + Always show + + Always hide + + + @string/settings_key_mode_auto_name + @string/settings_key_mode_always_show_name + @string/settings_key_mode_always_hide_name + + Bigram Suggestions diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index 1794d4c86..d9d6a15ac 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -165,6 +165,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:isModifier="true" + android:keyEdgeFlags="left" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:isModifier="true" + android:keyEdgeFlags="left" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:keyLabel="/" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:popupKeyboard="@xml/popup_punctuation" /> + android:iconPreview="@drawable/sym_keyboard_feedback_settings" /> + android:iconPreview="@drawable/sym_keyboard_feedback_mic" /> + android:iconPreview="@drawable/sym_keyboard_feedback_tab" /> + android:popupKeyboard="@xml/popup_punctuation" /> - + + + + + + + + + - + android:isModifier="true"/> + + android:popupKeyboard="@xml/popup_punctuation" android:isModifier="true"/> diff --git a/java/res/xml/kbd_symbols_black.xml b/java/res/xml/kbd_symbols_black.xml index 7eae55481..3bf1397ae 100644 --- a/java/res/xml/kbd_symbols_black.xml +++ b/java/res/xml/kbd_symbols_black.xml @@ -121,22 +121,39 @@ android:isRepeatable="true"/> - + + + + + + + + + - + android:iconPreview="@drawable/sym_keyboard_feedback_settings"/> + + android:popupKeyboard="@xml/popup_punctuation"/> + android:iconPreview="@drawable/sym_keyboard_feedback_return"/> diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml index b0693917e..b72ea50e5 100644 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_symbols_shift.xml @@ -88,18 +88,39 @@ android:isRepeatable="true" android:isModifier="true"/> - + + + + + + + + + - + android:isModifier="true"/> + - + - + + + + + + + + + - + android:iconPreview="@drawable/sym_keyboard_feedback_settings"/> + - + + android:iconPreview="@drawable/sym_keyboard_feedback_return" /> diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 762ada00c..2e6dffaf4 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -59,6 +59,15 @@ android:defaultValue="false" /> + + >(); mSymbolsId = makeSymbolsId(false); mSymbolsShiftedId = makeSymbolsShiftedId(false); - mInputMethodService = ims; } /** @@ -132,11 +163,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private KeyboardId makeSymbolsId(boolean hasVoice) { - return new KeyboardId(KBD_SYMBOLS[getCharColorId()], hasVoice); + return new KeyboardId(KBD_SYMBOLS[getCharColorId()], mHasSettingsKey ? + KEYBOARDMODE_SYMBOLS_WITH_SETTINGS_KEY : KEYBOARDMODE_SYMBOLS, + false, hasVoice); } private KeyboardId makeSymbolsShiftedId(boolean hasVoice) { - return new KeyboardId(KBD_SYMBOLS_SHIFT[getCharColorId()], hasVoice); + return new KeyboardId(KBD_SYMBOLS_SHIFT[getCharColorId()], mHasSettingsKey ? + KEYBOARDMODE_SYMBOLS_WITH_SETTINGS_KEY : KEYBOARDMODE_SYMBOLS, + false, hasVoice); } void makeKeyboards(boolean forceCreate) { @@ -243,20 +278,22 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mInputView.setKeyboard(keyboard); keyboard.setShifted(false); keyboard.setShiftLocked(keyboard.isShiftLocked()); - keyboard.setImeOptions(mContext.getResources(), mMode, imeOptions); + keyboard.setImeOptions(mInputMethodService.getResources(), mMode, imeOptions); keyboard.setColorOfSymbolIcons(mIsAutoCompletionActive, isBlackSym()); + // Update the settings key state because number of enabled IMEs could have been changed + updateSettingsKeyState(PreferenceManager.getDefaultSharedPreferences(mInputMethodService)); } private LatinKeyboard getKeyboard(KeyboardId id) { SoftReference ref = mKeyboards.get(id); LatinKeyboard keyboard = (ref == null) ? null : ref.get(); if (keyboard == null) { - Resources orig = mContext.getResources(); + Resources orig = mInputMethodService.getResources(); Configuration conf = orig.getConfiguration(); Locale saveLocale = conf.locale; conf.locale = mInputLocale; orig.updateConfiguration(conf, null); - keyboard = new LatinKeyboard(mContext, id.mXml, id.mKeyboardMode); + keyboard = new LatinKeyboard(mInputMethodService, id.mXml, id.mKeyboardMode); keyboard.setVoiceMode(hasVoiceButton(id.mXml == R.xml.kbd_symbols || id.mXml == R.xml.kbd_symbols_black), mHasVoice); keyboard.setLanguageSwitcher(mLanguageSwitcher, mIsAutoCompletionActive, isBlackSym()); @@ -281,7 +318,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha if (mode == MODE_PHONE) { return new KeyboardId(KBD_PHONE_SYMBOLS[charColorId], hasVoice); } else { - return new KeyboardId(KBD_SYMBOLS[charColorId], hasVoice); + return new KeyboardId(KBD_SYMBOLS[charColorId], mHasSettingsKey ? + KEYBOARDMODE_SYMBOLS_WITH_SETTINGS_KEY : KEYBOARDMODE_SYMBOLS, + false, hasVoice); } } switch (mode) { @@ -290,19 +329,27 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha "getKeyboardId:" + mode + "," + imeOptions + "," + isSymbols); /* fall through */ case MODE_TEXT: - return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_NORMAL, true, hasVoice); + return new KeyboardId(keyboardRowsResId, mHasSettingsKey ? + KEYBOARDMODE_NORMAL_WITH_SETTINGS_KEY : KEYBOARDMODE_NORMAL, + true, hasVoice); case MODE_SYMBOLS: - return new KeyboardId(KBD_SYMBOLS[charColorId], hasVoice); + return new KeyboardId(KBD_SYMBOLS[charColorId], mHasSettingsKey ? + KEYBOARDMODE_SYMBOLS_WITH_SETTINGS_KEY : KEYBOARDMODE_SYMBOLS, + false, hasVoice); case MODE_PHONE: return new KeyboardId(KBD_PHONE[charColorId], hasVoice); case MODE_URL: - return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_URL, true, hasVoice); + return new KeyboardId(keyboardRowsResId, mHasSettingsKey ? + KEYBOARDMODE_URL_WITH_SETTINGS_KEY : KEYBOARDMODE_URL, true, hasVoice); case MODE_EMAIL: - return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_EMAIL, true, hasVoice); + return new KeyboardId(keyboardRowsResId, mHasSettingsKey ? + KEYBOARDMODE_EMAIL_WITH_SETTINGS_KEY : KEYBOARDMODE_EMAIL, true, hasVoice); case MODE_IM: - return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_IM, true, hasVoice); + return new KeyboardId(keyboardRowsResId, mHasSettingsKey ? + KEYBOARDMODE_IM_WITH_SETTINGS_KEY : KEYBOARDMODE_IM, true, hasVoice); case MODE_WEB: - return new KeyboardId(keyboardRowsResId, KEYBOARDMODE_WEB, true, hasVoice); + return new KeyboardId(keyboardRowsResId, mHasSettingsKey ? + KEYBOARDMODE_WEB_WITH_SETTINGS_KEY : KEYBOARDMODE_WEB, true, hasVoice); } return null; } @@ -351,7 +398,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha // called. symbolsShiftedKeyboard.enableShiftLock(); symbolsShiftedKeyboard.setShiftLocked(true); - symbolsShiftedKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); + symbolsShiftedKeyboard.setImeOptions(mInputMethodService.getResources(), + mMode, mImeOptions); } else if (mCurrentId.equals(mSymbolsShiftedId)) { LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId); mCurrentId = mSymbolsId; @@ -360,7 +408,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha // indicator, we need to call enableShiftLock() and setShiftLocked(false). symbolsKeyboard.enableShiftLock(); symbolsKeyboard.setShifted(false); - symbolsKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); + symbolsKeyboard.setImeOptions(mInputMethodService.getResources(), mMode, mImeOptions); } } @@ -445,11 +493,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha if (PREF_KEYBOARD_LAYOUT.equals(key)) { changeLatinKeyboardView( Integer.valueOf(sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)), false); + } else if (LatinIMESettings.PREF_SETTINGS_KEY.equals(key)) { + updateSettingsKeyState(sharedPreferences); + recreateInputView(); } } public boolean isBlackSym () { - if (mInputView != null && mInputView.getSymbolColorSheme() == 1) { + if (mInputView != null && mInputView.getSymbolColorScheme() == 1) { return true; } return false; @@ -471,4 +522,19 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha .onAutoCompletionStateChanged(isAutoCompletion)); } } + + private void updateSettingsKeyState(SharedPreferences prefs) { + Resources resources = mInputMethodService.getResources(); + final String settingsKeyMode = prefs.getString(LatinIMESettings.PREF_SETTINGS_KEY, + resources.getString(DEFAULT_SETTINGS_KEY_MODE)); + // We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or + // 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system + if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) + || (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO)) + && LatinIMEUtil.hasMultipleEnabledIMEs(mInputMethodService))) { + mHasSettingsKey = true; + } else { + mHasSettingsKey = false; + } + } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f80ecc6d4..ecfd41651 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -356,7 +356,7 @@ public class LatinIME extends InputMethodService final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLanguageSwitcher = new LanguageSwitcher(this); mLanguageSwitcher.loadLocales(prefs); - mKeyboardSwitcher = new KeyboardSwitcher(this, this); + mKeyboardSwitcher = new KeyboardSwitcher(this); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); mLanguageSwitcher.setSystemLocale(conf.locale); @@ -984,7 +984,7 @@ public class LatinIME extends InputMethodService private void reloadKeyboards() { if (mKeyboardSwitcher == null) { - mKeyboardSwitcher = new KeyboardSwitcher(this, this); + mKeyboardSwitcher = new KeyboardSwitcher(this); } mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); if (mKeyboardSwitcher.getInputView() != null @@ -1122,11 +1122,6 @@ public class LatinIME extends InputMethodService } } - private boolean hasMultipleEnabledIMEs() { - return ((InputMethodManager) getSystemService( - INPUT_METHOD_SERVICE)).getEnabledInputMethodList().size() > 1; - } - private void showInputMethodPicker() { ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) .showInputMethodPicker(); @@ -1134,7 +1129,7 @@ public class LatinIME extends InputMethodService private void onOptionKeyPressed() { if (!isShowingOptionDialog()) { - if (hasMultipleEnabledIMEs()) { + if (LatinIMEUtil.hasMultipleEnabledIMEs(this)) { showOptionsMenu(); } else { launchSettings(); @@ -1144,7 +1139,7 @@ public class LatinIME extends InputMethodService private void onOptionKeyLongPressed() { if (!isShowingOptionDialog()) { - if (hasMultipleEnabledIMEs()) { + if (LatinIMEUtil.hasMultipleEnabledIMEs(this)) { showInputMethodPicker(); } else { launchSettings(); diff --git a/java/src/com/android/inputmethod/latin/LatinIMESettings.java b/java/src/com/android/inputmethod/latin/LatinIMESettings.java index 565c1e6e8..f9534d265 100644 --- a/java/src/com/android/inputmethod/latin/LatinIMESettings.java +++ b/java/src/com/android/inputmethod/latin/LatinIMESettings.java @@ -46,6 +46,7 @@ public class LatinIMESettings extends PreferenceActivity private static final String PREDICTION_SETTINGS_KEY = "prediction_settings"; private static final String VOICE_SETTINGS_KEY = "voice_mode"; private static final String DEBUG_MODE_KEY = "debug_mode"; + /* package */ static final String PREF_SETTINGS_KEY = "settings_key"; private static final String TAG = "LatinIMESettings"; @@ -55,6 +56,7 @@ public class LatinIMESettings extends PreferenceActivity private CheckBoxPreference mQuickFixes; private CheckBoxPreference mDebugMode; private ListPreference mVoicePreference; + private ListPreference mSettingsKeyPreference; private boolean mVoiceOn; private VoiceInputLogger mLogger; @@ -68,6 +70,7 @@ public class LatinIMESettings extends PreferenceActivity addPreferencesFromResource(R.xml.prefs); mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY); mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY); + mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY); SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); prefs.registerOnSharedPreferenceChangeListener(this); @@ -93,6 +96,7 @@ public class LatinIMESettings extends PreferenceActivity } else { updateVoiceModeSummary(); } + updateSettingsKeySummary(); } @Override @@ -106,7 +110,7 @@ public class LatinIMESettings extends PreferenceActivity (new BackupManager(this)).dataChanged(); // If turning on voice input, show dialog if (key.equals(VOICE_SETTINGS_KEY) && !mVoiceOn) { - if (! prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff) + if (!prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff) .equals(mVoiceModeOff)) { showVoiceConfirmation(); } @@ -118,6 +122,13 @@ public class LatinIMESettings extends PreferenceActivity } mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff)); updateVoiceModeSummary(); + updateSettingsKeySummary(); + } + + private void updateSettingsKeySummary() { + mSettingsKeyPreference.setSummary( + getResources().getStringArray(R.array.settings_key_modes) + [mSettingsKeyPreference.findIndexOfValue(mSettingsKeyPreference.getValue())]); } private void updateDebugMode() { diff --git a/java/src/com/android/inputmethod/latin/LatinIMEUtil.java b/java/src/com/android/inputmethod/latin/LatinIMEUtil.java index 93ad4072d..34b52845e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIMEUtil.java +++ b/java/src/com/android/inputmethod/latin/LatinIMEUtil.java @@ -16,6 +16,9 @@ package com.android.inputmethod.latin; +import android.view.inputmethod.InputMethodManager; + +import android.content.Context; import android.os.AsyncTask; import android.text.format.DateUtils; import android.util.Log; @@ -72,4 +75,9 @@ public class LatinIMEUtil { } } } + + public static boolean hasMultipleEnabledIMEs(Context context) { + return ((InputMethodManager) context.getSystemService( + Context.INPUT_METHOD_SERVICE)).getEnabledInputMethodList().size() > 1; + } } diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 3ae2e1c53..591235577 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -643,7 +643,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return mShowPreview; } - public int getSymbolColorSheme() { + public int getSymbolColorScheme() { return mSymbolColorScheme; } -- cgit v1.2.3-83-g751a From 749b1eaaaac3a7d051e907c4ae5f07521b3e75a3 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 16 Sep 2010 20:21:30 +0900 Subject: Increase gradient of suggestion bar bug: 3001007 Change-Id: I0f05d62b2a6848f37975b7a15b3ba14a90776d24 --- java/res/layout/candidates.xml | 2 ++ java/res/values-land/dimens.xml | 1 + java/res/values/dimens.xml | 1 + java/src/com/android/inputmethod/latin/CandidateView.java | 1 - 4 files changed, 4 insertions(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/res/layout/candidates.xml b/java/res/layout/candidates.xml index 478e20ba1..b89d44290 100644 --- a/java/res/layout/candidates.xml +++ b/java/res/layout/candidates.xml @@ -31,6 +31,8 @@ android:layout_width="wrap_content" android:layout_height="@dimen/candidate_strip_height" android:layout_weight="1" + android:fadingEdge="horizontal" + android:fadingEdgeLength="@dimen/candidate_strip_fading_edge_length" /> diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index 4f87b79d2..ac0e030d4 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -21,6 +21,7 @@ 47dip 38dip + 63dip 2dip diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index af8b38110..b399af489 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -22,6 +22,7 @@ 54dip 22dip 42dip + 63dip 4dip diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index bd73c6fb8..b84417b43 100755 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -186,7 +186,6 @@ public class CandidateView extends View { return true; } }); - setHorizontalFadingEdgeEnabled(true); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); -- cgit v1.2.3-83-g751a From 1476988ebbecbb44088423573a8311c97e4449dd Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 17 Sep 2010 11:31:38 +0900 Subject: Default puctuation suggestions have same color Bug: 3000978 Change-Id: Iedb3d4619ada8bd3ccc301ca2a8fb16fba6580c0 --- java/src/com/android/inputmethod/latin/CandidateView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index b84417b43..0f5b43009 100755 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -247,7 +247,9 @@ public class CandidateView extends View { paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setColor(mColorRecommended); existsAutoCompletion = true; - } else if (i != 0) { + } else if (i != 0 || (suggestion.length() == 1 && count > 1)) { + // HACK: even if i == 0, we use mColorOther when this suggestion's length is 1 and + // there are multiple suggestions, such as the default punctuation list. paint.setColor(mColorOther); } final int wordWidth; -- cgit v1.2.3-83-g751a From 08f664fa6502c578d8793df1e4eb5fa6de84b04f Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 16 Sep 2010 19:28:14 +0900 Subject: Use the phone keyboard for NUMBER and DATETIME until we get a dedicated number entry keypad. bug: 2992459 Change-Id: Ie597a68aa394c48e08a5d3fda19a0b613795b47b --- java/src/com/android/inputmethod/latin/LatinIME.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ecfd41651..d9cd7276b 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -598,9 +598,10 @@ public class LatinIME extends InputMethodService switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) { case EditorInfo.TYPE_CLASS_NUMBER: case EditorInfo.TYPE_CLASS_DATETIME: - mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS, - attribute.imeOptions, enableVoiceButton); - break; + // fall through + // NOTE: For now, we use the phone keyboard for NUMBER and DATETIME until we get + // a dedicated number entry keypad. + // TODO: Use a dedicated number entry keypad here when we get one. case EditorInfo.TYPE_CLASS_PHONE: mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE, attribute.imeOptions, enableVoiceButton); -- cgit v1.2.3-83-g751a From 4a3ffcbf32c21bdb553bf9aed894350ab07f47d8 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sat, 18 Sep 2010 01:48:03 +0900 Subject: Longer popup preview residual time (150ms) Bug: 3004787 Change-Id: Ia63662a549481d18046a46ef8292c0a4438b5588 --- java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 591235577..e75ec54e9 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -153,7 +153,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Timing constants private static final int DELAY_BEFORE_PREVIEW = 0; - private static final int DELAY_AFTER_PREVIEW = 70; + private static final int DELAY_AFTER_PREVIEW = 150; private static final int REPEAT_INTERVAL = PointerTracker.REPEAT_INTERVAL; // Miscellaneous constants -- cgit v1.2.3-83-g751a From 7763b36d6d95d78df49c5144291972d95ff7b4f6 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 17 Sep 2010 11:55:26 +0900 Subject: Align key preview and mini-keyboard positions Bug: 3004793 Change-Id: I1839e6ff3c8c66a576bfb3db9391c146ed225451 --- java/res/values/styles.xml | 2 +- .../inputmethod/latin/LatinKeyboardBaseView.java | 26 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'java/src') diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 258082eb6..60fffe873 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -22,7 +22,7 @@ @dimen/key_text_size #FFFFFFFF @layout/key_preview - 5dip + 0dip 80dip 14sp @layout/keyboard_popup diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index e75ec54e9..51c96e124 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -48,6 +48,7 @@ import android.widget.TextView; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import java.util.Map; /** @@ -191,6 +192,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private int mPopupPreviewOffsetX; private int mPopupPreviewOffsetY; private int mWindowY; + private int mPopupPreviewDisplayedY; // Popup mini keyboard private PopupWindow mMiniKeyboardPopup; @@ -918,9 +920,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx getLocationInWindow(mOffsetInWindow); mOffsetInWindow[0] += mPopupPreviewOffsetX; // Offset may be zero mOffsetInWindow[1] += mPopupPreviewOffsetY; // Offset may be zero - int[] mWindowLocation = new int[2]; - getLocationOnScreen(mWindowLocation); - mWindowY = mWindowLocation[1]; + int[] windowLocation = new int[2]; + getLocationOnScreen(windowLocation); + mWindowY = windowLocation[1]; } // Set the preview background state mPreviewText.getBackground().setState( @@ -948,6 +950,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mPreviewPopup.showAtLocation(mMiniKeyboardParent, Gravity.NO_GRAVITY, popupPreviewX, popupPreviewY); } + // Record popup preview position to display mini-keyboard later at the same positon + mPopupPreviewDisplayedY = popupPreviewY; mPreviewText.setVisibility(VISIBLE); } @@ -1057,6 +1061,19 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return container; } + private static boolean isOneRowKeyboard(Keyboard keyboard) { + final List keys = keyboard.getKeys(); + if (keys.size() == 0) return false; + final int edgeFlags = keys.get(0).edgeFlags; + // HACK: The first key of mini keyboard which was inflated from xml and has multiple rows, + // does not have both top and bottom edge flags on at the same time. On the other hand, + // the first key of mini keyboard that was created with popupCharacters must have both top + // and bottom edge flags on. + // When you want to use one row mini-keyboard from xml file, make sure that the row has + // both top and bottom edge flags set. + return (edgeFlags & Keyboard.EDGE_TOP) != 0 && (edgeFlags & Keyboard.EDGE_BOTTOM) != 0; + } + /** * Called when a key is long pressed. By default this will open any popup keyboard associated * with this key through the attributes popupLayout and popupCharacters. @@ -1102,7 +1119,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx popupY -= container.getMeasuredHeight(); popupY += container.getPaddingBottom(); final int x = popupX; - final int y = popupY; + final int y = isOneRowKeyboard(mMiniKeyboard.getKeyboard()) + ? mPopupPreviewDisplayedY : popupY; int adjustedX = x; if (x < 0) { -- cgit v1.2.3-83-g751a From 4da43a25cb5826e96729c24a555111c7e390fbdd Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 21 Sep 2010 11:59:12 +0900 Subject: Shorten popup preview residual time (100ms) The residual time was formerly 150ms by Ia63662a549481d18046a46ef8292c0a4438b5588, and originally was 70ms. Bug: 3004787 Change-Id: If60a74c51e9a68f008711cca2423094e8204755f --- java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 51c96e124..5ec5eb9d9 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -154,7 +154,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Timing constants private static final int DELAY_BEFORE_PREVIEW = 0; - private static final int DELAY_AFTER_PREVIEW = 150; + private static final int DELAY_AFTER_PREVIEW = 100; private static final int REPEAT_INTERVAL = PointerTracker.REPEAT_INTERVAL; // Miscellaneous constants -- cgit v1.2.3-83-g751a From aaa163b2b7fa9be6c43ace5ce8ccd2e70f3893fd Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 21 Sep 2010 13:00:13 +0900 Subject: Space key will no longer auto-repeat Bug: 3014225 Change-Id: I94d4904726985d5e17b665d4042c873ea07221f1 --- java/res/xml-da/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-da/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-de/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-de/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-fr/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-fr/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-iw/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-iw/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-nb/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-nb/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-ru/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-ru/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-sr/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-sr/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml-sv/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml-sv/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml/kbd_phone.xml | 3 +-- java/res/xml/kbd_phone_black.xml | 3 +-- java/res/xml/kbd_phone_symbols.xml | 3 +-- java/res/xml/kbd_phone_symbols_black.xml | 3 +-- java/res/xml/kbd_qwerty.xml | 30 ++++++++-------------- java/res/xml/kbd_qwerty_black.xml | 30 ++++++++-------------- java/res/xml/kbd_symbols.xml | 6 ++--- java/res/xml/kbd_symbols_black.xml | 6 ++--- java/res/xml/kbd_symbols_shift.xml | 6 ++--- java/res/xml/kbd_symbols_shift_black.xml | 6 ++--- .../android/inputmethod/latin/LatinKeyboard.java | 2 -- 27 files changed, 192 insertions(+), 386 deletions(-) (limited to 'java/src') diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index d9d6a15ac..a17d604bf 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -184,8 +184,7 @@ android:keyIcon="@drawable/sym_keyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" android:keyWidth="40%p" - android:isModifier="true" - android:isRepeatable="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -208,8 +207,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -236,8 +234,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -266,8 +263,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -296,8 +292,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -367,8 +361,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -399,8 +392,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -433,8 +425,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -467,8 +458,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -187,8 +186,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -215,8 +213,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -245,8 +242,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -275,8 +271,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -346,8 +340,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -378,8 +371,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -412,8 +404,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -446,8 +437,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -188,8 +187,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -216,8 +214,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -246,8 +243,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -276,8 +272,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -347,8 +341,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -379,8 +372,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -413,8 +405,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -447,8 +438,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -146,8 +145,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -174,8 +172,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -204,8 +201,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -234,8 +230,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -305,8 +299,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -337,8 +330,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -371,8 +363,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -405,8 +396,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -208,8 +207,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -236,8 +234,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -266,8 +263,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -296,8 +292,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -367,8 +361,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -399,8 +392,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -433,8 +425,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -467,8 +458,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -186,8 +185,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -214,8 +212,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -244,8 +241,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -274,8 +270,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -345,8 +339,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -377,8 +370,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -411,8 +403,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -445,8 +436,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -179,8 +178,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -207,8 +205,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -237,8 +234,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -267,8 +263,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -338,8 +332,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -370,8 +363,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -404,8 +396,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -438,8 +429,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -210,8 +209,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -238,8 +236,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -268,8 +265,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -298,8 +294,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -369,8 +363,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -401,8 +394,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -435,8 +427,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -469,8 +460,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:iconPreview="@drawable/sym_keyboard_feedback_space" /> + android:iconPreview="@drawable/sym_keyboard_feedback_space" /> + android:iconPreview="@drawable/sym_keyboard_feedback_space" /> + android:iconPreview="@drawable/sym_keyboard_feedback_space" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -185,8 +184,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -212,8 +210,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -241,8 +238,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> @@ -270,8 +266,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" - android:isRepeatable="true" /> + android:keyWidth="20%p" /> + android:keyWidth="30%p" /> @@ -339,8 +333,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -370,8 +363,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -403,8 +395,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> @@ -436,8 +427,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> + android:isModifier="true" /> + android:isModifier="true" /> + android:keyWidth="40%p" /> @@ -187,8 +186,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="30%p" - android:isRepeatable="true" /> + android:keyWidth="30%p" /> diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml index 01c2beabf..21cbb7132 100644 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_symbols_shift.xml @@ -139,8 +139,7 @@ android:keyIcon="@drawable/sym_keyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" android:keyWidth="40%p" - android:isModifier="true" - android:isRepeatable="true" /> + android:isModifier="true" /> @@ -175,8 +174,7 @@ android:keyIcon="@drawable/sym_keyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" android:keyWidth="30%p" - android:isModifier="true" - android:isRepeatable="true" /> + android:isModifier="true" /> diff --git a/java/res/xml/kbd_symbols_shift_black.xml b/java/res/xml/kbd_symbols_shift_black.xml index 73b59c9a6..d5d49ce0d 100644 --- a/java/res/xml/kbd_symbols_shift_black.xml +++ b/java/res/xml/kbd_symbols_shift_black.xml @@ -135,8 +135,7 @@ android:codes="@integer/key_space" android:keyIcon="@drawable/sym_bkeyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="40%p" - android:isRepeatable="true" /> + android:keyWidth="40%p" /> + android:keyWidth="30%p" /> Date: Tue, 21 Sep 2010 18:29:20 +0900 Subject: Fix mini keyboard display position when preview is disabled Bug: 3021082 Change-Id: I2cfb462c89b222449ee2ba5559462a9f5d2306ed --- java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 5ec5eb9d9..a2db12979 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -1119,7 +1119,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx popupY -= container.getMeasuredHeight(); popupY += container.getPaddingBottom(); final int x = popupX; - final int y = isOneRowKeyboard(mMiniKeyboard.getKeyboard()) + final int y = mShowPreview && isOneRowKeyboard(mMiniKeyboard.getKeyboard()) ? mPopupPreviewDisplayedY : popupY; int adjustedX = x; -- cgit v1.2.3-83-g751a From 31ff846e8c502e515139421dd0c9af28bce0336b Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 21 Sep 2010 22:53:12 +0900 Subject: Draw language label on space key of symbol+alt mode Bug: 3003888 Change-Id: I0bafcd13f3e5e5c69c65ed72580d108f2745e004 --- .../android/inputmethod/latin/LatinKeyboard.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 1414626db..4e139e849 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -56,8 +56,8 @@ public class LatinKeyboard extends Keyboard { private Drawable mMicPreviewIcon; private Drawable m123MicIcon; private Drawable m123MicPreviewIcon; - private Drawable mButtonArrowLeftIcon; - private Drawable mButtonArrowRightIcon; + private final Drawable mButtonArrowLeftIcon; + private final Drawable mButtonArrowRightIcon; private Key mShiftKey; private Key mEnterKey; private Key mF1Key; @@ -66,15 +66,15 @@ public class LatinKeyboard extends Keyboard { private int mSpaceKeyIndex = -1; private int mSpaceDragStartX; private int mSpaceDragLastDiff; - /* package */ Locale mLocale; + private Locale mLocale; private LanguageSwitcher mLanguageSwitcher; - private Resources mRes; - private Context mContext; + private final Resources mRes; + private final Context mContext; // Whether this keyboard has voice icon on it private boolean mHasVoiceButton; // Whether voice icon is enabled at all private boolean mVoiceEnabled; - private boolean mIsAlphaKeyboard; + private final boolean mIsAlphaKeyboard; private CharSequence m123Label; private boolean mCurrentlyInSpace; private SlidingLocaleDrawable mSlidingLocaleIcon; @@ -97,7 +97,7 @@ public class LatinKeyboard extends Keyboard { private static final float OVERLAP_PERCENTAGE_LOW_PROB = 0.70f; private static final float OVERLAP_PERCENTAGE_HIGH_PROB = 0.85f; - static int sSpacebarVerticalCorrection; + private static int sSpacebarVerticalCorrection; public LatinKeyboard(Context context, int xmlLayoutResId) { this(context, xmlLayoutResId, 0); @@ -131,11 +131,6 @@ public class LatinKeyboard extends Keyboard { mSpaceKeyIndex = indexOf(' '); } - public LatinKeyboard(Context context, int layoutTemplateResId, - CharSequence characters, int columns, int horizontalPadding) { - super(context, layoutTemplateResId, characters, columns, horizontalPadding); - } - @Override protected Key createKeyFromXml(Resources res, Row parent, int x, int y, XmlResourceParser parser) { @@ -482,9 +477,8 @@ public class LatinKeyboard extends Keyboard { .equalsIgnoreCase(locale.getLanguage())) { locale = null; } - setColorOfSymbolIcons(isAutoCompletion, isBlackSym); - if (mLocale != null && mLocale.equals(locale)) return; mLocale = locale; + setColorOfSymbolIcons(isAutoCompletion, isBlackSym); } boolean isCurrentlyInSpace() { -- cgit v1.2.3-83-g751a From 75c23ced94979a6b3f7c59e95dd46385e9702e2d Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Mon, 20 Sep 2010 18:10:54 +0900 Subject: Add lightweight visual indication for numbers. This change adds lightweight visual hints of alternate numeric characters on the top row - e.g. having a light gray '1' on the upper right corner of letter 'q' Note that MDPI resources are tentative (the same as HDPI for now, until we get fixed MDPI visual assets). bug: 3004632 Change-Id: I7a25cf90b702433a844c88f5c47bf914706af9bc --- java/res/drawable-hdpi/keyboard_hint_0.9.png | Bin 0 -> 379 bytes java/res/drawable-hdpi/keyboard_hint_1.9.png | Bin 0 -> 301 bytes java/res/drawable-hdpi/keyboard_hint_2.9.png | Bin 0 -> 404 bytes java/res/drawable-hdpi/keyboard_hint_3.9.png | Bin 0 -> 413 bytes java/res/drawable-hdpi/keyboard_hint_4.9.png | Bin 0 -> 341 bytes java/res/drawable-hdpi/keyboard_hint_5.9.png | Bin 0 -> 388 bytes java/res/drawable-hdpi/keyboard_hint_6.9.png | Bin 0 -> 413 bytes java/res/drawable-hdpi/keyboard_hint_7.9.png | Bin 0 -> 367 bytes java/res/drawable-hdpi/keyboard_hint_8.9.png | Bin 0 -> 417 bytes java/res/drawable-hdpi/keyboard_hint_9.9.png | Bin 0 -> 417 bytes java/res/drawable-mdpi/keyboard_hint_0.9.png | Bin 0 -> 379 bytes java/res/drawable-mdpi/keyboard_hint_1.9.png | Bin 0 -> 301 bytes java/res/drawable-mdpi/keyboard_hint_2.9.png | Bin 0 -> 404 bytes java/res/drawable-mdpi/keyboard_hint_3.9.png | Bin 0 -> 413 bytes java/res/drawable-mdpi/keyboard_hint_4.9.png | Bin 0 -> 341 bytes java/res/drawable-mdpi/keyboard_hint_5.9.png | Bin 0 -> 388 bytes java/res/drawable-mdpi/keyboard_hint_6.9.png | Bin 0 -> 413 bytes java/res/drawable-mdpi/keyboard_hint_7.9.png | Bin 0 -> 367 bytes java/res/drawable-mdpi/keyboard_hint_8.9.png | Bin 0 -> 417 bytes java/res/drawable-mdpi/keyboard_hint_9.9.png | Bin 0 -> 417 bytes .../android/inputmethod/latin/LatinKeyboard.java | 44 ++++++++++++++ .../inputmethod/latin/LatinKeyboardBaseView.java | 63 +++++++++++++++++---- .../inputmethod/latin/LatinKeyboardView.java | 3 +- 23 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 java/res/drawable-hdpi/keyboard_hint_0.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_1.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_2.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_3.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_4.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_5.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_6.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_7.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_8.9.png create mode 100644 java/res/drawable-hdpi/keyboard_hint_9.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_0.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_1.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_2.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_3.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_4.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_5.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_6.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_7.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_8.9.png create mode 100644 java/res/drawable-mdpi/keyboard_hint_9.9.png (limited to 'java/src') diff --git a/java/res/drawable-hdpi/keyboard_hint_0.9.png b/java/res/drawable-hdpi/keyboard_hint_0.9.png new file mode 100644 index 000000000..271264e92 Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_0.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_1.9.png b/java/res/drawable-hdpi/keyboard_hint_1.9.png new file mode 100644 index 000000000..eaf374262 Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_1.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_2.9.png b/java/res/drawable-hdpi/keyboard_hint_2.9.png new file mode 100644 index 000000000..8a1657117 Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_2.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_3.9.png b/java/res/drawable-hdpi/keyboard_hint_3.9.png new file mode 100644 index 000000000..34b501109 Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_3.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_4.9.png b/java/res/drawable-hdpi/keyboard_hint_4.9.png new file mode 100644 index 000000000..d4cc250dd Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_4.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_5.9.png b/java/res/drawable-hdpi/keyboard_hint_5.9.png new file mode 100644 index 000000000..6a054b42f Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_5.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_6.9.png b/java/res/drawable-hdpi/keyboard_hint_6.9.png new file mode 100644 index 000000000..66e91400a Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_6.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_7.9.png b/java/res/drawable-hdpi/keyboard_hint_7.9.png new file mode 100644 index 000000000..5eae24f4f Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_7.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_8.9.png b/java/res/drawable-hdpi/keyboard_hint_8.9.png new file mode 100644 index 000000000..ea7f512fd Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_8.9.png differ diff --git a/java/res/drawable-hdpi/keyboard_hint_9.9.png b/java/res/drawable-hdpi/keyboard_hint_9.9.png new file mode 100644 index 000000000..0bf85de93 Binary files /dev/null and b/java/res/drawable-hdpi/keyboard_hint_9.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_0.9.png b/java/res/drawable-mdpi/keyboard_hint_0.9.png new file mode 100644 index 000000000..271264e92 Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_0.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_1.9.png b/java/res/drawable-mdpi/keyboard_hint_1.9.png new file mode 100644 index 000000000..eaf374262 Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_1.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_2.9.png b/java/res/drawable-mdpi/keyboard_hint_2.9.png new file mode 100644 index 000000000..8a1657117 Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_2.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_3.9.png b/java/res/drawable-mdpi/keyboard_hint_3.9.png new file mode 100644 index 000000000..34b501109 Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_3.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_4.9.png b/java/res/drawable-mdpi/keyboard_hint_4.9.png new file mode 100644 index 000000000..d4cc250dd Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_4.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_5.9.png b/java/res/drawable-mdpi/keyboard_hint_5.9.png new file mode 100644 index 000000000..6a054b42f Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_5.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_6.9.png b/java/res/drawable-mdpi/keyboard_hint_6.9.png new file mode 100644 index 000000000..66e91400a Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_6.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_7.9.png b/java/res/drawable-mdpi/keyboard_hint_7.9.png new file mode 100644 index 000000000..5eae24f4f Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_7.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_8.9.png b/java/res/drawable-mdpi/keyboard_hint_8.9.png new file mode 100644 index 000000000..ea7f512fd Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_8.9.png differ diff --git a/java/res/drawable-mdpi/keyboard_hint_9.9.png b/java/res/drawable-mdpi/keyboard_hint_9.9.png new file mode 100644 index 000000000..0bf85de93 Binary files /dev/null and b/java/res/drawable-mdpi/keyboard_hint_9.9.png differ diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 4e139e849..8b89f3900 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -63,6 +63,9 @@ public class LatinKeyboard extends Keyboard { private Key mF1Key; private Key mSpaceKey; private Key m123Key; + private final int NUMBER_HINT_COUNT = 10; + private Key[] mNumberHintKeys; + private Drawable[] mNumberHintIcons = new Drawable[NUMBER_HINT_COUNT]; private int mSpaceKeyIndex = -1; private int mSpaceDragStartX; private int mSpaceDragLastDiff; @@ -129,6 +132,21 @@ public class LatinKeyboard extends Keyboard { mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black; mSpaceKeyIndex = indexOf(' '); + initializeNumberHintResources(context); + } + + private void initializeNumberHintResources(Context context) { + final Resources res = context.getResources(); + mNumberHintIcons[0] = res.getDrawable(R.drawable.keyboard_hint_0); + mNumberHintIcons[1] = res.getDrawable(R.drawable.keyboard_hint_1); + mNumberHintIcons[2] = res.getDrawable(R.drawable.keyboard_hint_2); + mNumberHintIcons[3] = res.getDrawable(R.drawable.keyboard_hint_3); + mNumberHintIcons[4] = res.getDrawable(R.drawable.keyboard_hint_4); + mNumberHintIcons[5] = res.getDrawable(R.drawable.keyboard_hint_5); + mNumberHintIcons[6] = res.getDrawable(R.drawable.keyboard_hint_6); + mNumberHintIcons[7] = res.getDrawable(R.drawable.keyboard_hint_7); + mNumberHintIcons[8] = res.getDrawable(R.drawable.keyboard_hint_8); + mNumberHintIcons[9] = res.getDrawable(R.drawable.keyboard_hint_9); } @Override @@ -150,6 +168,23 @@ public class LatinKeyboard extends Keyboard { m123Label = key.label; break; } + + // For number hints on the upper-right corner of key + if (mNumberHintKeys == null) { + // NOTE: This protected method is being called from the base class constructor before + // mNumberHintKeys gets initialized. + mNumberHintKeys = new Key[NUMBER_HINT_COUNT]; + } + int hintNumber = -1; + if (LatinKeyboardBaseView.isNumberAtLeftmostPopupChar(key)) { + hintNumber = key.popupCharacters.charAt(0) - '0'; + } else if (LatinKeyboardBaseView.isNumberAtRightmostPopupChar(key)) { + hintNumber = key.popupCharacters.charAt(key.popupCharacters.length() - 1) - '0'; + } + if (hintNumber >= 0 && hintNumber <= 9) { + mNumberHintKeys[hintNumber] = key; + } + return key; } @@ -293,6 +328,7 @@ public class LatinKeyboard extends Keyboard { if (mSpaceKey != null) { updateSpaceBarForLocale(isAutoCompletion, isBlack); } + updateNumberHintKeys(); } private void setDefaultBounds(Drawable drawable) { @@ -340,6 +376,14 @@ public class LatinKeyboard extends Keyboard { return mSpaceKey; } + private void updateNumberHintKeys() { + for (int i = 0; i < mNumberHintKeys.length; ++i) { + if (mNumberHintKeys[i] != null) { + mNumberHintKeys[i].icon = mNumberHintIcons[i]; + } + } + } + private void updateSpaceBarForLocale(boolean isAutoCompletion, boolean isBlack) { // If application locales are explicitly selected. if (mLocale != null) { diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index a2db12979..26b3c0581 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -797,6 +797,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx canvas.translate(key.x + kbdPaddingLeft, key.y + kbdPaddingTop); keyBackground.draw(canvas); + boolean shouldDrawIcon = true; if (label != null) { // For characters, use large font. For labels like "Done", use small font. if (label.length() > 1 && key.codes.length < 2) { @@ -817,14 +818,24 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx paint); // Turn off drop shadow paint.setShadowLayer(0, 0, 0, 0); - } else if (key.icon != null) { + + // Usually don't draw icon if label is not null, but we draw icon for the number + // hint. + shouldDrawIcon = isNumberAtEdgeOfPopupChars(key); + } + if (key.icon != null && shouldDrawIcon) { + // Special handing for the upper-right number hint icons + final int drawableWidth = isNumberAtEdgeOfPopupChars(key) ? + key.width : key.icon.getIntrinsicWidth(); + final int drawableHeight = isNumberAtEdgeOfPopupChars(key) ? + key.height : key.icon.getIntrinsicHeight(); + final int drawableX = (key.width - padding.left - padding.right - - key.icon.getIntrinsicWidth()) / 2 + padding.left; + - drawableWidth) / 2 + padding.left; final int drawableY = (key.height - padding.top - padding.bottom - - key.icon.getIntrinsicHeight()) / 2 + padding.top; + - drawableHeight) / 2 + padding.top; canvas.translate(drawableX, drawableY); - key.icon.setBounds(0, 0, - key.icon.getIntrinsicWidth(), key.icon.getIntrinsicHeight()); + key.icon.setBounds(0, 0, drawableWidth, drawableHeight); key.icon.draw(canvas); canvas.translate(-drawableX, -drawableY); } @@ -885,7 +896,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx Key key = tracker.getKey(keyIndex); if (key == null) return; - if (key.icon != null) { + // Should not draw number hint icons + if (key.icon != null && !isNumberAtEdgeOfPopupChars(key)) { mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon); mPreviewText.setText(null); @@ -1100,12 +1112,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } // HACK: Have the leftmost number in the popup characters right above the key - boolean isNumberAtLeftmost = false; - if (popupKey.popupCharacters != null && popupKey.popupCharacters.length() > 1) { - char leftmostChar = popupKey.popupCharacters.charAt(0); - isNumberAtLeftmost = leftmostChar >= '0' && leftmostChar <= '9'; - } - + boolean isNumberAtLeftmost = + hasMultiplePopupChars(popupKey) && isNumberAtLeftmostPopupChar(popupKey); int popupX = popupKey.x + mWindowOffset[0]; int popupY = popupKey.y + mWindowOffset[1]; if (isNumberAtLeftmost) { @@ -1151,6 +1159,37 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return true; } + private static boolean hasMultiplePopupChars(Key key) { + if (key.popupCharacters != null && key.popupCharacters.length() > 1) { + return true; + } + return false; + } + + private static boolean isNumberAtEdgeOfPopupChars(Key key) { + return isNumberAtLeftmostPopupChar(key) || isNumberAtRightmostPopupChar(key); + } + + /* package */ static boolean isNumberAtLeftmostPopupChar(Key key) { + if (key.popupCharacters != null && key.popupCharacters.length() > 0 + && isAsciiDigit(key.popupCharacters.charAt(0))) { + return true; + } + return false; + } + + /* package */ static boolean isNumberAtRightmostPopupChar(Key key) { + if (key.popupCharacters != null && key.popupCharacters.length() > 0 + && isAsciiDigit(key.popupCharacters.charAt(key.popupCharacters.length() - 1))) { + return true; + } + return false; + } + + private static boolean isAsciiDigit(char c) { + return (c < 0x80) && Character.isDigit(c); + } + private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) { return MotionEvent.obtain(mMiniKeyboardPopupTime, eventTime, action, x - mMiniKeyboardOriginX, y - mMiniKeyboardOriginY, 0); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index c17d7c555..a45bb21e9 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -24,6 +24,7 @@ import android.inputmethodservice.Keyboard.Key; import android.os.Handler; import android.os.Message; import android.os.SystemClock; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.MotionEvent; @@ -101,7 +102,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { if (keyboard.isShifted() && keyboard instanceof LatinKeyboard && ((LatinKeyboard) keyboard).isAlphaKeyboard() - && label != null && label.length() < 3 + && !TextUtils.isEmpty(label) && label.length() < 3 && Character.isLowerCase(label.charAt(0))) { label = label.toString().toUpperCase(); } -- cgit v1.2.3-83-g751a From 3a2896c80475094f751ef447fc9c97028bfc2265 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 21 Sep 2010 16:55:18 +0900 Subject: Fix issue space key preview remains on screen and would not dismiss The space key preview should be displayed one of the following case. - Popup preview is enabled - Language switcher is in action, whether popup preview is enabled or not. For phone number keyboard, popup preview is never displayed even if popup preview is enabled. Bug: 3006612 Bug: 3021091 Change-Id: I5385c776d0e8e3981fc8d8851db9140d92599ce5 --- .../inputmethod/latin/KeyboardSwitcher.java | 44 +++++++++------------- .../android/inputmethod/latin/LatinKeyboard.java | 6 ++- .../inputmethod/latin/LatinKeyboardBaseView.java | 13 ++++++- .../inputmethod/latin/LatinKeyboardView.java | 10 +++++ .../android/inputmethod/latin/PointerTracker.java | 5 +++ 5 files changed, 48 insertions(+), 30 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 0ccb7d98d..ebf2f4e60 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -16,7 +16,6 @@ package com.android.inputmethod.latin; -import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; @@ -87,7 +86,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static final int SYMBOLS_MODE_STATE_BEGIN = 1; private static final int SYMBOLS_MODE_STATE_SYMBOL = 2; - LatinKeyboardView mInputView; + private LatinKeyboardView mInputView; private static final int[] ALPHABET_MODES = { KEYBOARDMODE_NORMAL, KEYBOARDMODE_URL, @@ -100,7 +99,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha KEYBOARDMODE_IM_WITH_SETTINGS_KEY, KEYBOARDMODE_WEB_WITH_SETTINGS_KEY }; - final LatinIME mInputMethodService; + private final LatinIME mInputMethodService; private KeyboardId mSymbolsId; private KeyboardId mSymbolsShiftedId; @@ -120,7 +119,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; // Indicates whether or not we have the settings key - boolean mHasSettingsKey; + private boolean mHasSettingsKey; private static final int SETTINGS_KEY_MODE_AUTO = R.string.settings_key_mode_auto; private static final int SETTINGS_KEY_MODE_ALWAYS_SHOW = R.string.settings_key_mode_always_show; // NOTE: No need to have SETTINGS_KEY_MODE_ALWAYS_HIDE here because it's not being referred to @@ -134,7 +133,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private int mLayoutId; - KeyboardSwitcher(LatinIME ims) { + public KeyboardSwitcher(LatinIME ims) { mInputMethodService = ims; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ims); @@ -153,15 +152,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha * @param locale the current input locale, or null for default locale with no locale * button. */ - void setLanguageSwitcher(LanguageSwitcher languageSwitcher) { + public void setLanguageSwitcher(LanguageSwitcher languageSwitcher) { mLanguageSwitcher = languageSwitcher; mInputLocale = mLanguageSwitcher.getInputLocale(); } - void setInputView(LatinKeyboardView inputView) { - mInputView = inputView; - } - private KeyboardId makeSymbolsId(boolean hasVoice) { return new KeyboardId(KBD_SYMBOLS[getCharColorId()], mHasSettingsKey ? KEYBOARDMODE_SYMBOLS_WITH_SETTINGS_KEY : KEYBOARDMODE_SYMBOLS, @@ -174,7 +169,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha false, hasVoice); } - void makeKeyboards(boolean forceCreate) { + public void makeKeyboards(boolean forceCreate) { mSymbolsId = makeSymbolsId(mHasVoice && !mVoiceOnPrimary); mSymbolsShiftedId = makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary); @@ -229,7 +224,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } - void setVoiceMode(boolean enableVoice, boolean voiceOnPrimary) { + public void setVoiceMode(boolean enableVoice, boolean voiceOnPrimary) { if (enableVoice != mHasVoice || voiceOnPrimary != mVoiceOnPrimary) { mKeyboards.clear(); } @@ -238,11 +233,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha setKeyboardMode(mMode, mImeOptions, mHasVoice, mIsSymbols); } - boolean hasVoiceButton(boolean isSymbols) { + private boolean hasVoiceButton(boolean isSymbols) { return mHasVoice && (isSymbols != mVoiceOnPrimary); } - void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) { + public void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) { mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; mPreferSymbols = mode == MODE_SYMBOLS; if (mode == MODE_SYMBOLS) { @@ -255,7 +250,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } - void setKeyboardMode(int mode, int imeOptions, boolean enableVoice, boolean isSymbols) { + private void setKeyboardMode(int mode, int imeOptions, boolean enableVoice, boolean isSymbols) { if (mInputView == null) return; mMode = mode; mImeOptions = imeOptions; @@ -271,7 +266,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha if (mode == MODE_PHONE) { mInputView.setPhoneKeyboard(keyboard); - mInputView.setPreviewEnabled(false); } mCurrentId = id; @@ -354,15 +348,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return null; } - int getKeyboardMode() { + public int getKeyboardMode() { return mMode; } - boolean isTextMode() { - return mMode == MODE_TEXT; - } - - boolean isAlphabetMode() { + public boolean isAlphabetMode() { if (mCurrentId == null) { return false; } @@ -375,19 +365,19 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return false; } - void setShifted(boolean shifted) { + public void setShifted(boolean shifted) { if (mInputView != null) { mInputView.setShifted(shifted); } } - void setShiftLocked(boolean shiftLocked) { + public void setShiftLocked(boolean shiftLocked) { if (mInputView != null) { mInputView.setShiftLocked(shiftLocked); } } - void toggleShift() { + public void toggleShift() { if (mCurrentId.equals(mSymbolsId)) { LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId); mCurrentId = mSymbolsShiftedId; @@ -412,7 +402,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } - void toggleSymbols() { + public void toggleSymbols() { setKeyboardMode(mMode, mImeOptions, mHasVoice, !mIsSymbols); if (mIsSymbols && !mPreferSymbols) { mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN; @@ -429,7 +419,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha * Updates state machine to figure out when to automatically switch back to alpha mode. * Returns true if the keyboard needs to switch back */ - boolean onKey(int key) { + public boolean onKey(int key) { // Switch back to alpha mode if user types one or more non-space/enter characters // followed by a space/enter switch (mSymbolsModeState) { diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 8b89f3900..d39766d53 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -131,7 +131,7 @@ public class LatinKeyboard extends Keyboard { R.dimen.spacebar_vertical_correction); mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black; - mSpaceKeyIndex = indexOf(' '); + mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE); initializeNumberHintResources(context); } @@ -384,6 +384,10 @@ public class LatinKeyboard extends Keyboard { } } + public boolean isLanguageSwitchEnabled() { + return mLocale != null; + } + private void updateSpaceBarForLocale(boolean isAutoCompletion, boolean isBlack) { // If application locales are explicitly selected. if (mLocale != null) { diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 26b3c0581..fd25d7521 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -881,8 +881,17 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx public void showPreview(int keyIndex, PointerTracker tracker) { int oldKeyIndex = mOldPreviewKeyIndex; mOldPreviewKeyIndex = keyIndex; - // If key changed and preview is on ... - if (oldKeyIndex != keyIndex && mShowPreview) { + final boolean isLanguageSwitchEnabled = (mKeyboard instanceof LatinKeyboard) + && ((LatinKeyboard)mKeyboard).isLanguageSwitchEnabled(); + // We should re-draw popup preview when 1) we need to hide the preview, 2) we will show + // the space key preview and 3) pointer moves off the space key to other letter key, we + // should hide the preview of the previous key. + final boolean hidePreviewOrShowSpaceKeyPreview = (tracker == null) + || tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex); + // If key changed and preview is on or the key is space (language switch is enabled) + if (oldKeyIndex != keyIndex + && (mShowPreview + || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) { if (keyIndex == NOT_A_KEY) { mHandler.cancelPopupPreview(); mHandler.dismissPreview(DELAY_AFTER_PREVIEW); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index a45bb21e9..2872f6b46 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -65,6 +65,16 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { mPhoneKeyboard = phoneKeyboard; } + @Override + public void setPreviewEnabled(boolean previewEnabled) { + if (getKeyboard() == mPhoneKeyboard) { + // Phone keyboard never shows popup preview (except language switch). + super.setPreviewEnabled(false); + } else { + super.setPreviewEnabled(previewEnabled); + } + } + @Override public void setKeyboard(Keyboard k) { super.setKeyboard(k); diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index a612c8eec..cb717cbe7 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -140,6 +140,11 @@ public class PointerTracker { return isModifierInternal(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null)); } + public boolean isSpaceKey(int keyIndex) { + Key key = getKey(keyIndex); + return key != null && key.codes[0] == LatinIME.KEYCODE_SPACE; + } + public void updateKey(int keyIndex) { if (mKeyAlreadyProcessed) return; -- cgit v1.2.3-83-g751a From 8243c7a5e52d4b03bb456b591be6af43363f0831 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 17 Sep 2010 20:25:13 +0900 Subject: Choose smaller or shorter language name for space bar To fit a language name to the space bar or the language switcher, this change chooses smaller text size or shorter language name appropriately. This change also tunes the vertical position of a language name in the space bar by parameter SPACEBAR_LANGUAGE_BASELINE. Bug: 3004640 Bug: 3001021 Change-Id: Idb3adcb6fac1a23836510912d35312fa11b4f259 --- .../android/inputmethod/latin/LatinKeyboard.java | 210 ++++++++++++--------- .../inputmethod/latin/LatinKeyboardBaseView.java | 2 +- 2 files changed, 126 insertions(+), 86 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index d39766d53..9067023ff 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -99,6 +99,13 @@ public class LatinKeyboard extends Keyboard { private static final float SPACEBAR_DRAG_THRESHOLD = 0.8f; private static final float OVERLAP_PERCENTAGE_LOW_PROB = 0.70f; private static final float OVERLAP_PERCENTAGE_HIGH_PROB = 0.85f; + // Minimum width of space key preview (proportional to keyboard width) + private static final float SPACEBAR_POPUP_MIN_RATIO = 0.4f; + // Height in space key the language name will be drawn. (proportional to space key height) + private static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f; + // If the full language name needs to be smaller than this value to be drawn on space key, + // its short language name will be used instead. + private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f; private static int sSpacebarVerticalCorrection; @@ -405,43 +412,94 @@ public class LatinKeyboard extends Keyboard { } } + // Compute width of text with specified text size using paint. + private static int getTextWidth(Paint paint, String text, float textSize, Rect bounds) { + paint.setTextSize(textSize); + paint.getTextBounds(text, 0, text.length(), bounds); + return bounds.width(); + } + + // Layout local language name and left and right arrow on space bar. + private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow, + Drawable rArrow, int width, int height, float origTextSize, + boolean allowVariableTextSize) { + final float arrowWidth = lArrow.getIntrinsicWidth(); + final float arrowHeight = lArrow.getIntrinsicHeight(); + final float maxTextWidth = width - (arrowWidth + arrowWidth); + final Rect bounds = new Rect(); + + // Estimate appropriate language name text size to fit in maxTextWidth. + String language = LanguageSwitcher.toTitleCase(locale.getDisplayLanguage(locale)); + int textWidth = getTextWidth(paint, language, origTextSize, bounds); + // Assuming text width and text size are proportional to each other. + float textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f); + + final boolean useShortName; + if (allowVariableTextSize) { + textWidth = getTextWidth(paint, language, textSize, bounds); + // If text size goes too small or text does not fit, use short name + useShortName = textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME + || textWidth > maxTextWidth; + } else { + useShortName = textWidth > maxTextWidth; + textSize = origTextSize; + } + if (useShortName) { + language = LanguageSwitcher.toTitleCase(locale.getLanguage()); + textWidth = getTextWidth(paint, language, origTextSize, bounds); + textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f); + } + paint.setTextSize(textSize); + + // Place left and right arrow just before and after language text. + final float baseline = height * SPACEBAR_LANGUAGE_BASELINE; + final int top = (int)(baseline - arrowHeight); + final float remains = (width - textWidth) / 2; + lArrow.setBounds((int)(remains - arrowWidth), top, (int)remains, (int)baseline); + rArrow.setBounds((int)(remains + textWidth), top, (int)(remains + textWidth + arrowWidth), + (int)baseline); + + return language; + } + private Bitmap drawSpaceBar(int opacity, boolean isAutoCompletion, boolean isBlack) { - int width = mSpaceKey.width; - int height = mSpaceIcon.getIntrinsicHeight(); - Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(buffer); + final int width = mSpaceKey.width; + final int height = mSpaceIcon.getIntrinsicHeight(); + final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + final Canvas canvas = new Canvas(buffer); canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); + // If application locales are explicitly selected. if (mLocale != null) { - Paint paint = new Paint(); - paint.setAntiAlias(true); + final Paint paint = new Paint(); paint.setAlpha(opacity); - // Get the text size from the theme - paint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14)); + paint.setAntiAlias(true); paint.setTextAlign(Align.CENTER); - final String language = getInputLanguage(mSpaceKey.width, paint); - final int ascent = (int) -paint.ascent(); - - int shadowColor = isBlack ? - mRes.getColor(R.color.latinkeyboard_bar_language_shadow_black) - : mRes.getColor(R.color.latinkeyboard_bar_language_shadow_white); + final boolean allowVariableTextSize = true; + final String language = layoutSpaceBar(paint, mLanguageSwitcher.getInputLocale(), + mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height, + getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14), + allowVariableTextSize); + + // Draw language text with shadow + final int shadowColor = mRes.getColor(isBlack + ? R.color.latinkeyboard_bar_language_shadow_black + : R.color.latinkeyboard_bar_language_shadow_white); + final float baseline = height * SPACEBAR_LANGUAGE_BASELINE; + final float descent = paint.descent(); paint.setColor(shadowColor); - canvas.drawText(language, width / 2, ascent - 1, paint); + canvas.drawText(language, width / 2, baseline - descent - 1, paint); paint.setColor(mRes.getColor(R.color.latinkeyboard_bar_language_text)); - canvas.drawText(language, width / 2, ascent, paint); - // Put arrows on either side of the text + canvas.drawText(language, width / 2, baseline - descent, paint); + + // Put arrows that are already layed out on either side of the text if (mLanguageSwitcher.getLocaleCount() > 1) { - Rect bounds = new Rect(); - paint.getTextBounds(language, 0, language.length(), bounds); - drawButtonArrow(mButtonArrowLeftIcon, canvas, - (mSpaceKey.width - bounds.right) / 2 - - mButtonArrowLeftIcon.getIntrinsicWidth(), - (int) paint.getTextSize()); - drawButtonArrow(mButtonArrowRightIcon, canvas, - (mSpaceKey.width + bounds.right) / 2, (int) paint.getTextSize()); + mButtonArrowLeftIcon.draw(canvas); + mButtonArrowRightIcon.draw(canvas); } } + // Draw the spacebar icon at the bottom if (isAutoCompletion) { final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100; @@ -461,38 +519,13 @@ public class LatinKeyboard extends Keyboard { return buffer; } - private void drawButtonArrow(Drawable arrow, Canvas canvas, int x, int bottomY) { - arrow.setBounds(x, bottomY - arrow.getIntrinsicHeight(), x + arrow.getIntrinsicWidth(), - bottomY); - arrow.draw(canvas); - } - - private String getInputLanguage(int widthAvail, Paint paint) { - return chooseDisplayName(mLanguageSwitcher.getInputLocale(), widthAvail, paint); - } - - private String getNextInputLanguage(int widthAvail, Paint paint) { - return chooseDisplayName(mLanguageSwitcher.getNextInputLocale(), widthAvail, paint); - } - - private String getPrevInputLanguage(int widthAvail, Paint paint) { - return chooseDisplayName(mLanguageSwitcher.getPrevInputLocale(), widthAvail, paint); - } - - private String chooseDisplayName(Locale locale, int widthAvail, Paint paint) { - if (widthAvail < (int) (.35 * getMinWidth())) { - return LanguageSwitcher.toTitleCase(locale.getLanguage().substring(0, 2)); - } else { - return LanguageSwitcher.toTitleCase(locale.getDisplayLanguage(locale)); - } - } - private void updateLocaleDrag(int diff) { if (mSlidingLocaleIcon == null) { - mSlidingLocaleIcon = new SlidingLocaleDrawable(mSpacePreviewIcon, mSpaceKey.width, - mSpacePreviewIcon.getIntrinsicHeight()); - mSlidingLocaleIcon.setBounds(0, 0, mSpaceKey.width, - mSpacePreviewIcon.getIntrinsicHeight()); + final int width = Math.max(mSpaceKey.width, + (int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO)); + final int height = mSpacePreviewIcon.getIntrinsicHeight(); + mSlidingLocaleIcon = new SlidingLocaleDrawable(mSpacePreviewIcon, width, height); + mSlidingLocaleIcon.setBounds(0, 0, width, height); mSpaceKey.iconPreview = mSlidingLocaleIcon; } mSlidingLocaleIcon.setDiff(diff); @@ -777,17 +810,16 @@ public class LatinKeyboard extends Keyboard { */ class SlidingLocaleDrawable extends Drawable { - private int mWidth; - private int mHeight; - private Drawable mBackground; + private final int mWidth; + private final int mHeight; + private final Drawable mBackground; + private final TextPaint mTextPaint; + private final int mMiddleX; + private final Drawable mLeftDrawable; + private final Drawable mRightDrawable; + private final int mThreshold; private int mDiff; - private TextPaint mTextPaint; - private int mMiddleX; - private int mAscent; - private Drawable mLeftDrawable; - private Drawable mRightDrawable; private boolean mHitThreshold; - private int mThreshold; private String mCurrentLanguage; private String mNextLanguage; private String mPrevLanguage; @@ -799,26 +831,20 @@ public class LatinKeyboard extends Keyboard { mWidth = width; mHeight = height; mTextPaint = new TextPaint(); - int textSize = getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18); - mTextPaint.setTextSize(textSize); + mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); mTextPaint.setColor(R.color.latinkeyboard_transparent); mTextPaint.setTextAlign(Align.CENTER); mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE); mTextPaint.setAntiAlias(true); - mAscent = (int) mTextPaint.ascent(); mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; mLeftDrawable = mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left); mRightDrawable = mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right); - mLeftDrawable.setBounds(0, 0, - mLeftDrawable.getIntrinsicWidth(), mLeftDrawable.getIntrinsicHeight()); - mRightDrawable.setBounds(mWidth - mRightDrawable.getIntrinsicWidth(), 0, - mWidth, mRightDrawable.getIntrinsicHeight()); mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop(); } - void setDiff(int diff) { + private void setDiff(int diff) { if (diff == Integer.MAX_VALUE) { mHitThreshold = false; mCurrentLanguage = null; @@ -831,25 +857,39 @@ public class LatinKeyboard extends Keyboard { invalidateSelf(); } + private String getLanguageName(Locale locale) { + return LanguageSwitcher.toTitleCase(locale.getDisplayLanguage(locale)); + } + @Override public void draw(Canvas canvas) { canvas.save(); if (mHitThreshold) { - mTextPaint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text)); - canvas.clipRect(0, 0, mWidth, mHeight); + Paint paint = mTextPaint; + final int width = mWidth; + final int height = mHeight; + final int diff = mDiff; + final Drawable lArrow = mLeftDrawable; + final Drawable rArrow = mRightDrawable; + canvas.clipRect(0, 0, width, height); if (mCurrentLanguage == null) { - mCurrentLanguage = getInputLanguage(mWidth, mTextPaint); - mNextLanguage = getNextInputLanguage(mWidth, mTextPaint); - mPrevLanguage = getPrevInputLanguage(mWidth, mTextPaint); + final LanguageSwitcher languageSwitcher = mLanguageSwitcher; + mCurrentLanguage = getLanguageName(languageSwitcher.getInputLocale()); + mNextLanguage = getLanguageName(languageSwitcher.getNextInputLocale()); + mPrevLanguage = getLanguageName(languageSwitcher.getPrevInputLocale()); } - canvas.drawText(mCurrentLanguage, - mWidth / 2 + mDiff, -mAscent + 4, mTextPaint); - canvas.drawText(mNextLanguage, - mDiff - mWidth / 2, -mAscent + 4, mTextPaint); - canvas.drawText(mPrevLanguage, - mDiff + mWidth + mWidth / 2, -mAscent + 4, mTextPaint); - mLeftDrawable.draw(canvas); - mRightDrawable.draw(canvas); + // Draw language text with shadow + final float baseline = mHeight * SPACEBAR_LANGUAGE_BASELINE - paint.descent(); + paint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text)); + canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint); + canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint); + canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint); + + lArrow.setBounds(0, 0, lArrow.getIntrinsicWidth(), lArrow.getIntrinsicHeight()); + rArrow.setBounds(width - rArrow.getIntrinsicWidth(), 0, width, + rArrow.getIntrinsicHeight()); + lArrow.draw(canvas); + rArrow.draw(canvas); } if (mBackground != null) { canvas.translate(mMiddleX, 0); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index fd25d7521..dafbb669e 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -932,7 +932,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx lp.height = popupHeight; } - int popupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft(); + int popupPreviewX = key.x - (popupWidth - key.width) / 2; int popupPreviewY = key.y - popupHeight + mPreviewOffset; mHandler.cancelDismissPreview(); -- cgit v1.2.3-83-g751a From 8493e43148e1ec7b004e624f5f79183e167fad1d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 22 Sep 2010 18:29:19 +0900 Subject: Use constant for keycode. This is follow up change of Idb3adcb6fac1a23836510912d35312fa11b4f259 Change-Id: I130e381b0d5ac01176a746a4a915e2fc9d54587b --- java/src/com/android/inputmethod/latin/LatinKeyboard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 9067023ff..14a503bc3 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -161,13 +161,13 @@ public class LatinKeyboard extends Keyboard { XmlResourceParser parser) { Key key = new LatinKey(res, parent, x, y, parser); switch (key.codes[0]) { - case 10: + case LatinIME.KEYCODE_ENTER: mEnterKey = key; break; case LatinKeyboardView.KEYCODE_F1: mF1Key = key; break; - case 32: + case LatinIME.KEYCODE_SPACE: mSpaceKey = key; break; case KEYCODE_MODE_CHANGE: -- cgit v1.2.3-83-g751a