From a8d9702fc4782206ea45c53109132138f9e04c18 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Sun, 5 Sep 2010 21:59:43 +0900 Subject: [PATCH 1/7] Fix layout issue of the bottom row in web entry mode bug: 2977061 Change-Id: I76e0f4a21480d10f79fd5dcbe58c63cc3516d5d7 --- java/res/xml-da/kbd_qwerty.xml | 6 +++--- java/res/xml-da/kbd_qwerty_black.xml | 6 +++--- java/res/xml-de/kbd_qwerty.xml | 6 +++--- java/res/xml-de/kbd_qwerty_black.xml | 6 +++--- java/res/xml-fr/kbd_qwerty.xml | 6 +++--- java/res/xml-fr/kbd_qwerty_black.xml | 6 +++--- java/res/xml-iw/kbd_qwerty.xml | 6 +++--- java/res/xml-iw/kbd_qwerty_black.xml | 6 +++--- java/res/xml-nb/kbd_qwerty.xml | 6 +++--- java/res/xml-nb/kbd_qwerty_black.xml | 6 +++--- java/res/xml-ru/kbd_qwerty.xml | 6 +++--- java/res/xml-ru/kbd_qwerty_black.xml | 6 +++--- java/res/xml-sr/kbd_qwerty.xml | 6 +++--- java/res/xml-sr/kbd_qwerty_black.xml | 6 +++--- java/res/xml-sv/kbd_qwerty.xml | 6 +++--- java/res/xml-sv/kbd_qwerty_black.xml | 6 +++--- java/res/xml/kbd_qwerty.xml | 6 +++--- java/res/xml/kbd_qwerty_black.xml | 6 +++--- 18 files changed, 54 insertions(+), 54 deletions(-) diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index fb8d062ee..967fda851 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -188,7 +188,7 @@ + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -197,10 +197,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -196,10 +196,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -177,10 +177,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -177,10 +177,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -179,10 +179,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -179,10 +179,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -151,10 +151,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -151,10 +151,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -195,10 +195,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -195,10 +195,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -163,10 +163,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -163,10 +163,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -159,10 +159,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -159,10 +159,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -199,10 +199,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -199,10 +199,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> @@ -205,10 +205,10 @@ android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left"/> @@ -202,10 +202,10 @@ android:keyWidth="10%p"/> + android:keyWidth="30%p" android:isRepeatable="true"/> + android:keyWidth="10%p"/> Date: Mon, 6 Sep 2010 14:26:46 +0900 Subject: [PATCH 2/7] Support multi-touch only when device has distinct multi-touch panel Bug: 2973373 Change-Id: I9871c09ec8c1c2aa945d97392e61ee1ec585baef --- .../inputmethod/latin/KeyboardSwitcher.java | 4 ++ .../android/inputmethod/latin/LatinIME.java | 10 ++-- .../latin/LatinKeyboardBaseView.java | 51 ++++++++++++++++++- .../inputmethod/latin/PointerTracker.java | 34 +++++++++++-- 4 files changed, 90 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 2919e9b56..3fb74b238 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -365,6 +365,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } + public boolean hasDistinctMultitouch() { + return mInputView != null && mInputView.hasDistinctMultitouch(); + } + /** * Updates state machine to figure out when to automatically switch back to alpha mode. * Returns true if the keyboard needs to switch back diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ea8c93934..2cff232a6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1135,7 +1135,9 @@ public class LatinIME extends InputMethodService LatinImeLogger.logOnDelete(); break; case Keyboard.KEYCODE_SHIFT: - // Shift key is handled in onPress(). + // Shift key is handled in onPress() when device has distinct multi-touch panel. + if (!mKeyboardSwitcher.hasDistinctMultitouch()) + handleShift(); break; case Keyboard.KEYCODE_CANCEL: if (!isShowingOptionDialog()) { @@ -1935,7 +1937,7 @@ public class LatinIME extends InputMethodService List suggestions = mWordToSuggestions.get(selectedWord); // If the first letter of touching is capitalized, make all the suggestions // start with a capital letter. - if (Character.isUpperCase((char) touching.word.charAt(0))) { + if (Character.isUpperCase(touching.word.charAt(0))) { for (int i = 0; i < suggestions.size(); i++) { String origSugg = (String) suggestions.get(i); String capsSugg = origSugg.toUpperCase().charAt(0) @@ -2196,7 +2198,7 @@ public class LatinIME extends InputMethodService public void onPress(int primaryCode) { vibrate(); playKeyClick(primaryCode); - if (primaryCode == Keyboard.KEYCODE_SHIFT) { + if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { mShiftKeyState.onPress(); handleShift(); } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { @@ -2210,7 +2212,7 @@ public class LatinIME extends InputMethodService // Reset any drag flags in the keyboard ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased(); //vibrate(); - if (primaryCode == Keyboard.KEYCODE_SHIFT) { + if (mKeyboardSwitcher.hasDistinctMultitouch() && primaryCode == Keyboard.KEYCODE_SHIFT) { if (mShiftKeyState.isMomentary()) resetShift(); mShiftKeyState.onRelease(); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index c449b36e7..51bdc2c0c 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -204,6 +205,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private final ArrayList mPointerTrackers = new ArrayList(); private final PointerQueue mPointerQueue = new PointerQueue(); private final float mDebounceHysteresis; + private final boolean mHasDistinctMultitouch; + private int mOldPointerCount = 1; protected KeyDetector mKeyDetector = new ProximityKeyDetector(); @@ -508,6 +511,9 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx final boolean ignoreMultitouch = true; mGestureDetector = new GestureDetector(getContext(), listener, null, ignoreMultitouch); mGestureDetector.setIsLongpressEnabled(false); + + mHasDistinctMultitouch = context.getPackageManager() + .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT); } public void setOnKeyboardActionListener(OnKeyboardActionListener listener) { @@ -563,6 +569,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return mKeyboard; } + /** + * Return whether the device has distinct multi-touch panel. + * @return true if the device has distinct multi-touch panel. + */ + public boolean hasDistinctMultitouch() { + return mHasDistinctMultitouch; + } + /** * Sets the state of the shift key of the keyboard, if any. * @param shifted whether or not to enable the state of the shift key @@ -1090,7 +1104,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Create pointer trackers until we can get 'id+1'-th tracker, if needed. for (int i = pointers.size(); i <= id; i++) { final PointerTracker tracker = - new PointerTracker(i, mHandler, mKeyDetector, this); + new PointerTracker(i, mHandler, mKeyDetector, this, mHasDistinctMultitouch); if (keys != null) tracker.setKeyboard(keys, mDebounceHysteresis); if (listener != null) @@ -1107,6 +1121,13 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx final int action = me.getActionMasked(); final long eventTime = me.getEventTime(); + // TODO: cleanup this code into a multi-touch to single-touch event converter class? + // If the device does not have distinct multi-touch support panel, ignore all multi-touch + // events except a transition from/to single-touch. + if (!mHasDistinctMultitouch && pointerCount > 1 && mOldPointerCount > 1) { + return true; + } + // Track the last few movements to look for spurious swipes. mSwipeTracker.addMovement(me); @@ -1138,6 +1159,34 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Up event will pass through. } + // TODO: cleanup this code into a multi-touch to single-touch event converter class? + // Translate mutli-touch event to single-touch events on the device that has no distinct + // multi-touch panel. + if (!mHasDistinctMultitouch) { + // Use only main (id=0) pointer tracker. + PointerTracker tracker = getPointerTracker(0); + int index = me.getActionIndex(); + int x = (int)me.getX(index); + int y = (int)me.getY(index); + int oldPointerCount = mOldPointerCount; + if (pointerCount == 1 && oldPointerCount == 2) { + // Multi-touch to single touch transition. + // Send a down event for the latest pointer. + tracker.onDownEvent(x, y, eventTime); + } else if (pointerCount == 2 && oldPointerCount == 1) { + // Single-touch to multi-touch transition. + // Send an up event for the last pointer. + tracker.onUpEvent(tracker.getLastX(), tracker.getLastY(), eventTime); + } else if (pointerCount == 1 && oldPointerCount == 1) { + tracker.onTouchEvent(action, x, y, eventTime); + } else { + Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount + + " (old " + oldPointerCount + ")"); + } + mOldPointerCount = pointerCount; + return true; + } + if (action == MotionEvent.ACTION_MOVE) { for (int index = 0; index < pointerCount; index++) { int x = (int)me.getX(index); diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index 2685e87c6..1f6005621 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -22,12 +22,13 @@ import com.android.inputmethod.latin.LatinKeyboardBaseView.UIHandler; import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard.Key; import android.util.Log; +import android.view.MotionEvent; import android.view.ViewConfiguration; public class PointerTracker { private static final String TAG = "PointerTracker"; private static final boolean DEBUG = false; - private static final boolean DEBUG_MOVE = DEBUG && true; + private static final boolean DEBUG_MOVE = false; public interface UIProxy { public void invalidateKey(Key key); @@ -51,6 +52,7 @@ public class PointerTracker { private final UIHandler mHandler; private final KeyDetector mKeyDetector; private OnKeyboardActionListener mListener; + private final boolean mHasDistinctMultitouch; private Key[] mKeys; private int mKeyDebounceThresholdSquared = -1; @@ -85,13 +87,15 @@ public class PointerTracker { // pressed key private int mPreviousKey = NOT_A_KEY; - public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector, UIProxy proxy) { + public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector, UIProxy proxy, + boolean hasDistinctMultitouch) { if (proxy == null || handler == null || keyDetector == null) throw new NullPointerException(); mPointerId = id; mProxy = proxy; mHandler = handler; mKeyDetector = keyDetector; + mHasDistinctMultitouch = hasDistinctMultitouch; resetMultiTap(); } @@ -146,6 +150,25 @@ public class PointerTracker { mKeyAlreadyProcessed = true; } + public void onTouchEvent(int action, int x, int y, long eventTime) { + switch (action) { + case MotionEvent.ACTION_MOVE: + onMoveEvent(x, y, eventTime); + break; + case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_POINTER_DOWN: + onDownEvent(x, y, eventTime); + break; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_POINTER_UP: + onUpEvent(x, y, eventTime); + break; + case MotionEvent.ACTION_CANCEL: + onCancelEvent(x, y, eventTime); + break; + } + } + public void onDownEvent(int x, int y, long eventTime) { int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); mCurrentKey = keyIndex; @@ -242,7 +265,7 @@ public class PointerTracker { showKeyPreviewAndUpdateKey(NOT_A_KEY); // If we're not on a repeating key (which sends on a DOWN event) if (!wasInKeyRepeat) { - detectAndSendKey(mCurrentKey, (int)x, (int)y, eventTime); + detectAndSendKey(mCurrentKey, x, y, eventTime); } if (isValidKeyIndex(keyIndex)) mProxy.invalidateKey(mKeys[keyIndex]); @@ -355,7 +378,10 @@ public class PointerTracker { private void showKeyPreviewAndUpdateKey(int keyIndex) { updateKey(keyIndex); - if (!isModifier()) + // 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) mProxy.showPreview(keyIndex, this); } From 532471e3574308b33ff380b5d917d4eccf6159f4 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 6 Sep 2010 18:12:10 +0900 Subject: [PATCH 3/7] Fix an asset for the feedback of delete key bug: 2977026 Change-Id: I4cdaaf49644d214b03a514a9104144250a024574 --- .../sym_keyboard_feedback_delete.png | Bin 1453 -> 2150 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/java/res/drawable-hdpi/sym_keyboard_feedback_delete.png b/java/res/drawable-hdpi/sym_keyboard_feedback_delete.png index f13a523658edc21e02271d8482cb8be8d505453f..28dca5a15da341ee0e9dcf8fe80d630d4c1bb05e 100755 GIT binary patch delta 1467 zcmZ3>{Y+qjCu7=1FLlPrvlvq*XEADK6!`jD`4?rTXXYj5xa237=BDPAc)HjsRpb`v zrDUd9nORy`xEfiw88{i4n^_ndI=Z>JSQr}`m|9x8n!B1iD=7d~0?ojt*T~%5(8R>q z+0n_+W%4~HvB^42Qan&WC%E7rM*Yc)ne=1KU7XBZOr4z#42>+X+f-ZoGgkyKcETfq{W#nx~6nNX4x;v;KPr2Z|i1H9mD}ZON>#W!@WRPMBuJtvZow?SU3G z3y%P=KZ>53Tum(X8msm%uyc_U|G@qWkqJ?Hm6zgK;3=i?f?_>QPUg>xR+9lTX9zG)@*%|(X}NJuazC-C$% z8XB-2gK%cYSkx^N_gJ(eGBtVw{{=1Pdj$sfxEDpgXY6I}y>Q{|-Uaava~H^66kINK zq({-Eq^|B?==R&TuP;ZWrKdkX5ZCpjo0ZvZK@US|Zd%&0x6$m13CFjTxVChiICpMe zKz#iF6B#CM_2tzElzZSAYCRk2oc&#i9M{`IBmugagfSF(;3Ty=l;!~IRJL=rMdw1`OACZD{m<(EsR8&-AWMpOkIxNgFyX~9N zFIsFbQ`oX-_pJvH9!PVkvt7M*?OW5gmv7$G@a49jtX{#DW-!y|xx1U&y~T?C$3L%K zvgC`(3LYgNrIIo!V@87@cP61vAmOL=<3F7r);i<3v8{+SO zUfWP(X+luJD#y--qX&I#mj@g@dbHnjhKSa+c*U5Ul9CeMb&+;g4jnple#(?7R!RB~ zuDGvQTwYamt5<$ovqQmZb;iw6k&4HvmH~lL!S{lH;)#ig)>2YZIU5$vD70K58KCgJ5t@4CwKaqo+!@}Vg}+Wv%Sl4huAs|36bQTyxJiVb(5RA zySj|TMMP32?ow7yyv#p+-n@BTURfHmrm$2PZ5k{0_wW5RcQ2n3-7m9UHS7BxlOyrjC029Son;XFa#a59`M+;- z6dX4NZem%xQ9IB2ru5nWkNKinqtE&lUp-yNcMz>4xDhtdo{5LSWLxc4u8$qZ7=Xaj L)z4*}Q$iB}(nX7T delta 777 zcmaDRu$Fs*C!^9vFLlPrcNmo>XEA0^-o>Olxtd8@!PL~;&C$`wz|qmr$~)nPup~6e!VPYu)Xz zNP%aOK+gjWju@pS52a*UN+z&LHwi>#Wfm1?ZZ$mQTVS@mfMbr#tWAzf9JLAseVk4y zD(}5szesV`bIqz>a{t-w%jXoG@BjYi{{MTj?i?34cElam&}d6SLG>U$4{v2SL%UM$ zhr=(vm09%7ZhCF1%d$W>w~9w9N|fcGqWsGLi_NNX`J6adn8cR`y_7vyK5Krj(UrbM zj_r$XW^LUy>EsjJOor<&vyO@>m^B}Kkh(MGpNj4Uoist$j|y}B>?hSP2+R>o(w53Y!fNodS(~a$$DuG5udB}s_%?>*ZSq) zj-ykw`coHQ)NoOn7`*%LyGNDx3=X8|W*JNkQ~V^be(ydD=8bi1B3!LDGYg)uuXklw>geYC z@4t(7A2qkQpXRh?=|a)TCsU^PKNflHw#89+P5bLhJIb0OYeNO+Z@aM5zopr0A;W{vH$=8 From 12659d4c0ce04aaf3d8479e44f9230881b964000 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 6 Sep 2010 14:50:50 +0900 Subject: [PATCH 4/7] Fix ALT key light behavior This change also cleanups some imports, unnecessary cast and null check. Bug: 2977256 Change-Id: I81b9e539ff8a13ae0cc1eb5c4fb2246732cca3e9 --- .../inputmethod/latin/KeyboardSwitcher.java | 25 +++++++++++-------- .../inputmethod/latin/LatinKeyboard.java | 10 ++++---- .../inputmethod/latin/LatinKeyboardView.java | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 3fb74b238..284b29305 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -16,10 +16,6 @@ package com.android.inputmethod.latin; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; @@ -27,6 +23,10 @@ import android.content.res.Resources; import android.preference.PreferenceManager; import android.view.InflateException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener { public static final int MODE_NONE = 0; @@ -197,8 +197,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } mHasVoice = enableVoice; mVoiceOnPrimary = voiceOnPrimary; - setKeyboardMode(mMode, mImeOptions, mHasVoice, - mIsSymbols); + setKeyboardMode(mMode, mImeOptions, mHasVoice, mIsSymbols); } boolean hasVoiceButton(boolean isSymbols) { @@ -338,19 +337,23 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha void toggleShift() { if (mCurrentId.equals(mSymbolsId)) { - LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId); LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId); - symbolsKeyboard.setShifted(true); mCurrentId = mSymbolsShiftedId; mInputView.setKeyboard(symbolsShiftedKeyboard); - symbolsShiftedKeyboard.setShifted(true); + // Symbol shifted keyboard has an ALT key that has a caps lock style indicator. To + // enable the indicator, we need to call enableShiftLock() and setShiftLocked(true). + // Thus we can keep the ALT key's Key.on value true while LatinKey.onRelease() is + // called. + symbolsShiftedKeyboard.enableShiftLock(); + symbolsShiftedKeyboard.setShiftLocked(true); symbolsShiftedKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); } else if (mCurrentId.equals(mSymbolsShiftedId)) { LatinKeyboard symbolsKeyboard = getKeyboard(mSymbolsId); - LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId); - symbolsShiftedKeyboard.setShifted(false); mCurrentId = mSymbolsId; mInputView.setKeyboard(symbolsKeyboard); + // Symbol keyboard has an ALT key that has a caps lock style indicator. To disable the + // indicator, we need to call enableShiftLock() and setShiftLocked(false). + symbolsKeyboard.enableShiftLock(); symbolsKeyboard.setShifted(false); symbolsKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions); } diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index c7ca67727..caae92363 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -16,9 +16,6 @@ package com.android.inputmethod.latin; -import java.util.List; -import java.util.Locale; - import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -27,10 +24,10 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; +import android.graphics.Paint.Align; import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.Rect; -import android.graphics.Paint.Align; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.inputmethodservice.Keyboard; @@ -39,6 +36,9 @@ import android.util.Log; import android.view.ViewConfiguration; import android.view.inputmethod.EditorInfo; +import java.util.List; +import java.util.Locale; + public class LatinKeyboard extends Keyboard { private static final boolean DEBUG_PREFERRED_LETTER = false; @@ -128,7 +128,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((int) ' '); + mSpaceKeyIndex = indexOf(' '); } public LatinKeyboard(Context context, int layoutTemplateResId, diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index 71ca8b81a..4295427e3 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -131,7 +131,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { public boolean setShiftLocked(boolean shiftLocked) { Keyboard keyboard = getKeyboard(); - if (keyboard != null && keyboard instanceof LatinKeyboard) { + if (keyboard instanceof LatinKeyboard) { ((LatinKeyboard)keyboard).setShiftLocked(shiftLocked); invalidateAllKeys(); return true; From 8d7ffcb2ac3a8cdd051c7e493ff17b6bf1ded9c0 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 6 Sep 2010 22:16:11 +0900 Subject: [PATCH 5/7] Disable pop-up preview on mini keyboard This change also disable the special behavior of long press a key that has only one digit alternate. If the visual design of both the pop-up preview and the mini keyboard will look like same, I think that showing mini keyboard is enough for the key that has one digit alternate. Bug: 2973546 Change-Id: I04f138c120aa58526fe054626dac856171fb7a58 --- .../latin/LatinKeyboardBaseView.java | 3 ++- .../inputmethod/latin/LatinKeyboardView.java | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 51bdc2c0c..1e95e8ac4 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -1073,7 +1073,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mMiniKeyboardOriginY = y + container.getPaddingTop(); mMiniKeyboard.setPopupOffset((x < 0) ? 0 : x, y); mMiniKeyboard.setShifted(isShifted()); - mMiniKeyboard.setPreviewEnabled(isPreviewEnabled()); + // Mini keyboard needs no pop-up key preview displayed. + mMiniKeyboard.setPreviewEnabled(false); mMiniKeyboardPopup.setContentView(container); mMiniKeyboardPopup.setWidth(container.getMeasuredWidth()); mMiniKeyboardPopup.setHeight(container.getMeasuredHeight()); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index 4295427e3..8f20a22d0 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -78,17 +78,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { setKeyboardLocal(k); } - private static boolean hasOneDigitAlternate(Key key) { - final CharSequence alternates = key.popupCharacters; - if (alternates == null) - return false; - final String altChars = alternates.toString(); - if (altChars.codePointCount(0, altChars.length()) != 1) - return false; - final int altCode = altChars.codePointAt(0); - return altCode >= '0' && altCode <= '9'; - } - @Override protected boolean onLongPress(Key key) { int primaryCode = key.codes[0]; @@ -104,13 +93,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE, LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE); return true; - } else if (hasOneDigitAlternate(key)) { - mKeyCodes[0] = primaryCode = key.popupCharacters.charAt(0); - // when there is only one alternate character, send it as key action. - getOnKeyboardActionListener().onKey(primaryCode, mKeyCodes, - LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE, - LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE); - return true; } else { return super.onLongPress(key); } From d27c7aea7c0bd82dddd25c2ccf46cb2a14aa385d Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 6 Sep 2010 20:18:25 +0900 Subject: [PATCH 6/7] Add isModifier to the buttons in the lowest line Change-Id: I2d5c9e753f0f6fa21fdcfa7b55e81e6a3e3ea64f --- java/res/xml-da/kbd_qwerty.xml | 4 ++-- java/res/xml-de/kbd_qwerty.xml | 4 ++-- java/res/xml-fr/kbd_qwerty.xml | 4 ++-- java/res/xml-iw/kbd_qwerty.xml | 4 ++-- java/res/xml-nb/kbd_qwerty.xml | 4 ++-- java/res/xml-ru/kbd_qwerty.xml | 4 ++-- java/res/xml-sr/kbd_qwerty.xml | 4 ++-- java/res/xml-sv/kbd_qwerty.xml | 4 ++-- java/res/xml/kbd_qwerty.xml | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index 967fda851..57b013a9d 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -157,11 +157,11 @@ - + - + diff --git a/java/res/xml-de/kbd_qwerty.xml b/java/res/xml-de/kbd_qwerty.xml index 53f7434fb..52ac24210 100755 --- a/java/res/xml-de/kbd_qwerty.xml +++ b/java/res/xml-de/kbd_qwerty.xml @@ -137,11 +137,11 @@ - + - + diff --git a/java/res/xml-fr/kbd_qwerty.xml b/java/res/xml-fr/kbd_qwerty.xml index d750e5854..b4da9365a 100644 --- a/java/res/xml-fr/kbd_qwerty.xml +++ b/java/res/xml-fr/kbd_qwerty.xml @@ -139,11 +139,11 @@ - + - + diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml index c427a0547..c6b2056e2 100755 --- a/java/res/xml-iw/kbd_qwerty.xml +++ b/java/res/xml-iw/kbd_qwerty.xml @@ -111,11 +111,11 @@ - + - + diff --git a/java/res/xml-nb/kbd_qwerty.xml b/java/res/xml-nb/kbd_qwerty.xml index 952759b59..7bc02ebe4 100644 --- a/java/res/xml-nb/kbd_qwerty.xml +++ b/java/res/xml-nb/kbd_qwerty.xml @@ -155,11 +155,11 @@ - + - + diff --git a/java/res/xml-ru/kbd_qwerty.xml b/java/res/xml-ru/kbd_qwerty.xml index 320ee50a7..41d23b7d5 100755 --- a/java/res/xml-ru/kbd_qwerty.xml +++ b/java/res/xml-ru/kbd_qwerty.xml @@ -123,11 +123,11 @@ - + - + diff --git a/java/res/xml-sr/kbd_qwerty.xml b/java/res/xml-sr/kbd_qwerty.xml index 96f015f4e..78852fc22 100644 --- a/java/res/xml-sr/kbd_qwerty.xml +++ b/java/res/xml-sr/kbd_qwerty.xml @@ -119,11 +119,11 @@ - + - + diff --git a/java/res/xml-sv/kbd_qwerty.xml b/java/res/xml-sv/kbd_qwerty.xml index 6b70542d3..bd5c67631 100644 --- a/java/res/xml-sv/kbd_qwerty.xml +++ b/java/res/xml-sv/kbd_qwerty.xml @@ -159,11 +159,11 @@ - + - + diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml index 6884502f7..c75e27afb 100755 --- a/java/res/xml/kbd_qwerty.xml +++ b/java/res/xml/kbd_qwerty.xml @@ -165,11 +165,11 @@ - + - + From 66b42a1c2d38813be104a7f0435ec6e6ec1c6e65 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 6 Sep 2010 19:18:38 +0900 Subject: [PATCH 7/7] Add shared preference for re-correction Change-Id: Ie5b2e0d2f9739dd33524c2688e172e77aac1f243 --- java/res/values/bools.xml | 1 + java/res/values/strings.xml | 4 ++ java/res/xml/prefs.xml | 7 ++++ .../android/inputmethod/latin/LatinIME.java | 38 +++++++++++-------- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/java/res/values/bools.xml b/java/res/values/bools.xml index f5f2c3d0e..1f8051bfd 100644 --- a/java/res/values/bools.xml +++ b/java/res/values/bools.xml @@ -28,4 +28,5 @@ true true + true diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 7b760f002..456151b62 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -339,6 +339,10 @@ Enable user feedback Help improve this input method editor by automatically sending usage statistics and crash reports to Google. + + Tap to re-correction + + You can re-correct words by tapping words you have typed Keyboard Theme diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index b4d2d903d..762ada00c 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -37,6 +37,13 @@ android:defaultValue="@bool/default_popup_preview" /> + +