From cba1af9c5626a2cb1e611735deb72db72d02c4c1 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 24 Oct 2011 22:25:37 +0900 Subject: [PATCH 01/10] Fix a bug where the sequence numbers would be wrong The spell checker cannot afford to return static objects, seeing as the framework will then use the same objects to pair the cookie and sequence ids to the request. Bug: 5503243 Change-Id: Ia9c3a933bfb30cf5525418b240ef60632d72c9d0 --- .../AndroidSpellCheckerService.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 8f478f385..095c2c51c 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -61,11 +61,6 @@ public class AndroidSpellCheckerService extends SpellCheckerService { private static final int CAPITALIZE_ALL = 2; // All caps private final static String[] EMPTY_STRING_ARRAY = new String[0]; - private final static SuggestionsInfo NOT_IN_DICT_EMPTY_SUGGESTIONS = - new SuggestionsInfo(0, EMPTY_STRING_ARRAY); - private final static SuggestionsInfo IN_DICT_EMPTY_SUGGESTIONS = - new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY, - EMPTY_STRING_ARRAY); private final static Flag[] USE_FULL_EDIT_DISTANCE_FLAG_ARRAY; static { // See BinaryDictionary.java for an explanation of these flags @@ -103,6 +98,15 @@ public class AndroidSpellCheckerService extends SpellCheckerService { return new AndroidSpellCheckerSession(this); } + private static SuggestionsInfo getNotInDictEmptySuggestions() { + return new SuggestionsInfo(0, EMPTY_STRING_ARRAY); + } + + private static SuggestionsInfo getInDictEmptySuggestions() { + return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY, + EMPTY_STRING_ARRAY); + } + private static class SuggestionsGatherer implements WordCallback { public static class Result { public final String[] mSuggestions; @@ -408,9 +412,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService { DictAndProximity dictInfo = null; try { dictInfo = mDictionaryPool.takeOrGetNull(); - if (null == dictInfo) return NOT_IN_DICT_EMPTY_SUGGESTIONS; - return dictInfo.mDictionary.isValidWord(text) ? IN_DICT_EMPTY_SUGGESTIONS - : NOT_IN_DICT_EMPTY_SUGGESTIONS; + if (null == dictInfo) return getNotInDictEmptySuggestions(); + return dictInfo.mDictionary.isValidWord(text) ? getInDictEmptySuggestions() + : getNotInDictEmptySuggestions(); } finally { if (null != dictInfo) { if (!mDictionaryPool.offer(dictInfo)) { @@ -445,7 +449,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService { DictAndProximity dictInfo = null; try { dictInfo = mDictionaryPool.takeOrGetNull(); - if (null == dictInfo) return NOT_IN_DICT_EMPTY_SUGGESTIONS; + if (null == dictInfo) return getNotInDictEmptySuggestions(); dictInfo.mDictionary.getWords(composer, suggestionsGatherer, dictInfo.mProximityInfo); isInDict = dictInfo.mDictionary.isValidWord(text); @@ -490,7 +494,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService { throw e; } else { Log.e(TAG, "Exception while spellcheking: " + e); - return NOT_IN_DICT_EMPTY_SUGGESTIONS; + return getNotInDictEmptySuggestions(); } } } From cd43edbc32d3efd4e076597aa30922c7a500a444 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 25 Oct 2011 17:12:51 +0900 Subject: [PATCH 02/10] Small clean up Remove an unused method and constant Change-Id: I3e99ea9fc182c83399d46aca81d1b69aab2c36d1 --- .../inputmethod/latin/TextEntryState.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java index 79b3bdebb..ba93ab526 100644 --- a/java/src/com/android/inputmethod/latin/TextEntryState.java +++ b/java/src/com/android/inputmethod/latin/TextEntryState.java @@ -30,13 +30,12 @@ public class TextEntryState { private static final int IN_WORD = 2; private static final int ACCEPTED_DEFAULT = 3; private static final int PICKED_SUGGESTION = 4; - private static final int PUNCTUATION_AFTER_WORD = 5; - private static final int PUNCTUATION_AFTER_ACCEPTED = 6; - private static final int SPACE_AFTER_ACCEPTED = 7; - private static final int SPACE_AFTER_PICKED = 8; - private static final int UNDO_COMMIT = 9; - private static final int RECORRECTING = 10; - private static final int PICKED_RECORRECTION = 11; + private static final int PUNCTUATION_AFTER_ACCEPTED = 5; + private static final int SPACE_AFTER_ACCEPTED = 6; + private static final int SPACE_AFTER_PICKED = 7; + private static final int UNDO_COMMIT = 8; + private static final int RECORRECTING = 9; + private static final int PICKED_RECORRECTION = 10; private static int sState = UNKNOWN; private static int sPreviousState = UNKNOWN; @@ -136,7 +135,6 @@ public class TextEntryState { case START: case UNKNOWN: case SPACE_AFTER_ACCEPTED: - case PUNCTUATION_AFTER_WORD: if (!isSpace && !isSeparator) { setState(IN_WORD); } else { @@ -182,10 +180,6 @@ public class TextEntryState { return sState == ACCEPTED_DEFAULT; } - public static boolean isSpaceAfterPicked() { - return sState == SPACE_AFTER_PICKED; - } - public static boolean isUndoCommit() { return sState == UNDO_COMMIT; } @@ -208,7 +202,6 @@ public class TextEntryState { case IN_WORD: return "IN_WORD"; case ACCEPTED_DEFAULT: return "ACCEPTED_DEFAULT"; case PICKED_SUGGESTION: return "PICKED_SUGGESTION"; - case PUNCTUATION_AFTER_WORD: return "PUNCTUATION_AFTER_WORD"; case PUNCTUATION_AFTER_ACCEPTED: return "PUNCTUATION_AFTER_ACCEPTED"; case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED"; case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED"; From b715299125e8fbaaa941d994217baf823e6c4013 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 25 Oct 2011 17:32:04 +0900 Subject: [PATCH 03/10] Fix a cosmetic bug where text would blink on space swap On space swap or space removal in some occasions there would be a small blink on the screen. This change fixes that. Change-Id: I486cbcc5dfcafd531b3fa92c4f9a3255832f22cc --- .../android/inputmethod/latin/LatinIME.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 866cdaa51..861ea663d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1132,17 +1132,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return false; } - private void swapSwapperAndSpace() { - final InputConnection ic = getCurrentInputConnection(); - if (ic == null) return; + // "ic" may be null + private void swapSwapperAndSpaceWhileInBatchEdit(final InputConnection ic) { + if (null == ic) return; CharSequence lastTwo = ic.getTextBeforeCursor(2, 0); // It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called. if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == Keyboard.CODE_SPACE) { - ic.beginBatchEdit(); ic.deleteSurroundingText(2, 0); ic.commitText(lastTwo.charAt(1) + " ", 1); - ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); } } @@ -1169,11 +1167,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - // "ic" must not null + // "ic" must not be null private void maybeRemovePreviousPeriod(final InputConnection ic, CharSequence text) { // When the text's first character is '.', remove the previous period // if there is one. - CharSequence lastOne = ic.getTextBeforeCursor(1, 0); + final CharSequence lastOne = ic.getTextBeforeCursor(1, 0); if (lastOne != null && lastOne.length() == 1 && lastOne.charAt(0) == Keyboard.CODE_PERIOD && text.charAt(0) == Keyboard.CODE_PERIOD) { @@ -1181,11 +1179,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - private void removeTrailingSpace() { - final InputConnection ic = getCurrentInputConnection(); + // "ic" may be null + private void removeTrailingSpaceWhileInBatchEdit(final InputConnection ic) { if (ic == null) return; - - CharSequence lastOne = ic.getTextBeforeCursor(1, 0); + final CharSequence lastOne = ic.getTextBeforeCursor(1, 0); if (lastOne != null && lastOne.length() == 1 && lastOne.charAt(0) == Keyboard.CODE_SPACE) { ic.deleteSurroundingText(1, 0); @@ -1435,8 +1432,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) { mVoiceProxy.handleCharacter(); + final InputConnection ic = getCurrentInputConnection(); + if (ic != null) ic.beginBatchEdit(); if (mJustAddedMagicSpace && mSettingsValues.isMagicSpaceStripper(primaryCode)) { - removeTrailingSpace(); + removeTrailingSpaceWhileInBatchEdit(ic); } int code = primaryCode; @@ -1454,6 +1453,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (switcher.isShiftedOrShiftLocked()) { if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT || keyCodes[0] > Character.MAX_CODE_POINT) { + if (null != ic) ic.endBatchEdit(); return; } code = keyCodes[0]; @@ -1467,6 +1467,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } else { // Some keys, such as [eszett], have upper case as multi-characters. onTextInput(upperCaseString); + if (null != ic) ic.endBatchEdit(); return; } } @@ -1474,7 +1475,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (mHasUncommittedTypedChars) { mComposingStringBuilder.append((char) code); mWordComposer.add(code, keyCodes, x, y); - final InputConnection ic = getCurrentInputConnection(); if (ic != null) { // If it's the first letter, make note of auto-caps state if (mWordComposer.size() == 1) { @@ -1493,7 +1493,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar sendKeyChar((char)code); } if (mJustAddedMagicSpace && mSettingsValues.isMagicSpaceSwapper(primaryCode)) { - swapSwapperAndSpace(); + if (null != ic) swapSwapperAndSpaceWhileInBatchEdit(ic); } else { mJustAddedMagicSpace = false; } @@ -1501,6 +1501,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar switcher.updateShiftState(); if (LatinIME.PERF_DEBUG) measureCps(); TextEntryState.typedCharacter((char) code, mSettingsValues.isWordSeparator(code), x, y); + if (null != ic) ic.endBatchEdit(); } private void handleSeparator(int primaryCode, int x, int y) { @@ -1536,9 +1537,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (mJustAddedMagicSpace) { if (mSettingsValues.isMagicSpaceSwapper(primaryCode)) { sendKeyChar((char)primaryCode); - swapSwapperAndSpace(); + swapSwapperAndSpaceWhileInBatchEdit(ic); } else { - if (mSettingsValues.isMagicSpaceStripper(primaryCode)) removeTrailingSpace(); + if (mSettingsValues.isMagicSpaceStripper(primaryCode)) { + removeTrailingSpaceWhileInBatchEdit(ic); + } sendKeyChar((char)primaryCode); mJustAddedMagicSpace = false; } From 126698fdd256a2e3734634d3b923cabd800064ba Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 24 Oct 2011 18:00:05 +0900 Subject: [PATCH 04/10] Add a strong space behavior. Bug: 5454442 Change-Id: Ic095cb65dd7b4427617cd74fc7c53a9666b218c4 --- .../android/inputmethod/latin/LatinIME.java | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 861ea663d..90fc818bb 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -157,6 +157,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar SUGGESTION_VISIBILILTY_HIDE_VALUE }; + private static final int SPACE_STRENGTH_NORMAL = 0; + private static final int SPACE_STRENGTH_MAGIC = 1; + private static final int SPACE_STRENGTH_STRONG = 2; + private Settings.Values mSettingsValues; private View mExtractArea; @@ -192,7 +196,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private boolean mHasUncommittedTypedChars; // Magic space: a space that should disappear on space/apostrophe insertion, move after the // punctuation on punctuation insertion, and become a real space on alpha char insertion. - private boolean mJustAddedMagicSpace; // This indicates whether the last char is a magic space. + private int mLastSpaceStrength; // This indicates whether the last space is normal/magic/strong. // This indicates whether the last keypress resulted in processing of double space replacement // with period-space. private boolean mJustReplacedDoubleSpace; @@ -727,7 +731,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mComposingStringBuilder.setLength(0); mHasUncommittedTypedChars = false; mDeleteCount = 0; - mJustAddedMagicSpace = false; + mLastSpaceStrength = SPACE_STRENGTH_NORMAL; mJustReplacedDoubleSpace = false; loadSettings(); @@ -889,6 +893,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; if (!mExpectingUpdateSelection) { + if (isShowingPunctuationList()) { + // Test for the punctuation list because there is a race condition that + // may end up in coming here on a normal key press + mLastSpaceStrength = SPACE_STRENGTH_STRONG; + } if (((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || candidatesCleared)) { @@ -906,7 +915,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar TextEntryState.reset(); updateSuggestions(); } - mJustAddedMagicSpace = false; // The user moved the cursor. mJustReplacedDoubleSpace = false; } mExpectingUpdateSelection = false; @@ -1238,6 +1246,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return mOptionsDialog != null && mOptionsDialog.isShowing(); } + private void onCodeInputWithSpaceStrength(final int primaryCode, final int[] keyCodes, + final int x, final int y, final int spaceStrength) { + final int lastStateOfSpaceStrength = mLastSpaceStrength; + mLastSpaceStrength = spaceStrength; + onCodeInput(primaryCode, keyCodes, x, y); + mLastSpaceStrength = lastStateOfSpaceStrength; + } + // Implementation of {@link KeyboardActionListener}. @Override public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { @@ -1323,7 +1339,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.onKey(Keyboard.CODE_DUMMY); - mJustAddedMagicSpace = false; + mLastSpaceStrength = SPACE_STRENGTH_NORMAL; mEnteredText = text; } @@ -1371,6 +1387,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } mHandler.postUpdateShiftKeyState(); + // After backspace we want to reset the space to strong to prevent an undue swap with + // a subsequent press of a punctuation sign in the suggestion strip. + mLastSpaceStrength = SPACE_STRENGTH_STRONG; TextEntryState.backspace(); if (TextEntryState.isUndoCommit()) { revertLastWord(ic); @@ -1434,7 +1453,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.beginBatchEdit(); - if (mJustAddedMagicSpace && mSettingsValues.isMagicSpaceStripper(primaryCode)) { + if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength + && mSettingsValues.isMagicSpaceStripper(primaryCode)) { removeTrailingSpaceWhileInBatchEdit(ic); } @@ -1492,10 +1512,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } else { sendKeyChar((char)code); } - if (mJustAddedMagicSpace && mSettingsValues.isMagicSpaceSwapper(primaryCode)) { + if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength + && mSettingsValues.isMagicSpaceSwapper(primaryCode)) { if (null != ic) swapSwapperAndSpaceWhileInBatchEdit(ic); } else { - mJustAddedMagicSpace = false; + mLastSpaceStrength = SPACE_STRENGTH_NORMAL; } switcher.updateShiftState(); @@ -1534,7 +1555,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - if (mJustAddedMagicSpace) { + if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength) { if (mSettingsValues.isMagicSpaceSwapper(primaryCode)) { sendKeyChar((char)primaryCode); swapSwapperAndSpaceWhileInBatchEdit(ic); @@ -1543,7 +1564,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar removeTrailingSpaceWhileInBatchEdit(ic); } sendKeyChar((char)primaryCode); - mJustAddedMagicSpace = false; + mLastSpaceStrength = SPACE_STRENGTH_NORMAL; } } else { sendKeyChar((char)primaryCode); @@ -1564,6 +1585,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } if (Keyboard.CODE_SPACE == primaryCode) { + if (isShowingPunctuationList()) { + mLastSpaceStrength = SPACE_STRENGTH_STRONG; + } if (!isCursorTouchingWord()) { mHandler.cancelUpdateSuggestions(); mHandler.postUpdateBigramPredictions(); @@ -1826,12 +1850,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : ""; final int toLeft = (ic == null || TextUtils.isEmpty(beforeText)) ? 0 : beforeText.charAt(0); - final boolean oldMagicSpace = mJustAddedMagicSpace; - if (Keyboard.CODE_SPACE == toLeft) mJustAddedMagicSpace = true; - onCodeInput(primaryCode, new int[] { primaryCode }, + final int spaceStrength; + if (Keyboard.CODE_SPACE == toLeft && mLastSpaceStrength != SPACE_STRENGTH_STRONG) { + spaceStrength = SPACE_STRENGTH_MAGIC; + } else { + spaceStrength = mLastSpaceStrength; + } + onCodeInputWithSpaceStrength(primaryCode, new int[] { primaryCode }, KeyboardActionListener.NOT_A_TOUCH_COORDINATE, - KeyboardActionListener.NOT_A_TOUCH_COORDINATE); - mJustAddedMagicSpace = oldMagicSpace; + KeyboardActionListener.NOT_A_TOUCH_COORDINATE, spaceStrength); if (ic != null) { ic.endBatchEdit(); } @@ -2084,7 +2111,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void sendMagicSpace() { sendKeyChar((char)Keyboard.CODE_SPACE); - mJustAddedMagicSpace = true; + mLastSpaceStrength = SPACE_STRENGTH_MAGIC; mKeyboardSwitcher.updateShiftState(); } From ce668e7a0b6ae7046e1f22a162ad174d58dfe145 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 25 Oct 2011 21:35:43 +0900 Subject: [PATCH 05/10] Small clean up. Remove unused methods and constants. Change-Id: If72e04394a2943b416915217d22cb6e58a0508b3 --- .../inputmethod/latin/TextEntryState.java | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java index ba93ab526..4204b8a4f 100644 --- a/java/src/com/android/inputmethod/latin/TextEntryState.java +++ b/java/src/com/android/inputmethod/latin/TextEntryState.java @@ -34,8 +34,7 @@ public class TextEntryState { private static final int SPACE_AFTER_ACCEPTED = 6; private static final int SPACE_AFTER_PICKED = 7; private static final int UNDO_COMMIT = 8; - private static final int RECORRECTING = 9; - private static final int PICKED_RECORRECTION = 10; + private static final int PICKED_RECORRECTION = 9; private static int sState = UNKNOWN; private static int sPreviousState = UNKNOWN; @@ -78,7 +77,9 @@ public class TextEntryState { } public static void acceptedSuggestion(CharSequence typedWord, CharSequence actualWord) { - if (sState == RECORRECTING || sState == PICKED_RECORRECTION) { + if (sState == PICKED_RECORRECTION) { + // TODO: this seems to be the only place where setState(PICKED_RECORRECTION) is done + // so this state should never be reached. Check this and remove. setState(PICKED_RECORRECTION); } else { setState(PICKED_SUGGESTION); @@ -87,18 +88,6 @@ public class TextEntryState { displayState("acceptedSuggestion", "typedWord", typedWord, "actualWord", actualWord); } - public static void selectedForRecorrection() { - setState(RECORRECTING); - if (DEBUG) displayState("selectedForRecorrection"); - } - - public static void onAbortRecorrection() { - if (sState == RECORRECTING || sState == PICKED_RECORRECTION) { - setState(START); - } - if (DEBUG) displayState("onAbortRecorrection"); - } - public static void typedCharacter(char c, boolean isSeparator, int x, int y) { final boolean isSpace = (c == Keyboard.CODE_SPACE); switch (sState) { @@ -148,9 +137,6 @@ public class TextEntryState { setState(IN_WORD); } break; - case RECORRECTING: - setState(START); - break; } RingCharBuffer.getInstance().push(c, x, y); if (isSeparator) { @@ -176,20 +162,12 @@ public class TextEntryState { if (DEBUG) displayState("reset"); } - public static boolean isAcceptedDefault() { - return sState == ACCEPTED_DEFAULT; - } - public static boolean isUndoCommit() { return sState == UNDO_COMMIT; } - public static boolean isPunctuationAfterAccepted() { - return sState == PUNCTUATION_AFTER_ACCEPTED; - } - public static boolean isRecorrecting() { - return sState == RECORRECTING || sState == PICKED_RECORRECTION; + return sState == PICKED_RECORRECTION; } public static String getState() { @@ -206,7 +184,6 @@ public class TextEntryState { case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED"; case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED"; case UNDO_COMMIT: return "UNDO_COMMIT"; - case RECORRECTING: return "RECORRECTING"; case PICKED_RECORRECTION: return "PICKED_RECORRECTION"; default: return "UNKNOWN"; } From d0c5f9395a1b94e8425982e353d090f972dc44f0 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 25 Oct 2011 21:54:35 +0900 Subject: [PATCH 06/10] Cleanup. Remove a state that can never be reached, and ajust all the callers that would always have received false. Change-Id: Iac025568be11743428419e0772da306a4f0a0bf1 --- .../android/inputmethod/latin/LatinIME.java | 18 +++++++----------- .../inputmethod/latin/TextEntryState.java | 15 +-------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 90fc818bb..94be6f0fd 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1630,7 +1630,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public boolean isSuggestionsStripVisible() { if (mSuggestionsView == null) return false; - if (mSuggestionsView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting()) + if (mSuggestionsView.isShowingAddToDictionaryHint()) return true; if (!isShowingSuggestionsStrip()) return false; @@ -1735,7 +1735,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } // Don't auto-correct words with multiple capital letter autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); - autoCorrectionAvailable &= !TextEntryState.isRecorrecting(); // Basically, we update the suggestion strip only when suggestion count > 1. However, // there is an exception: We update the suggestion strip whenever typed word's length @@ -1808,7 +1807,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mSettingsValues.mWordSeparators); - final boolean recorrecting = TextEntryState.isRecorrecting(); final InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.beginBatchEdit(); @@ -1882,7 +1880,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar suggestion.toString(), index, suggestions.mWords); TextEntryState.acceptedSuggestion(mComposingStringBuilder.toString(), suggestion); // Follow it with a space - if (mInsertSpaceOnPickSuggestionManually && !recorrecting) { + if (mInsertSpaceOnPickSuggestionManually) { sendMagicSpace(); } @@ -1902,13 +1900,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar || !AutoCorrection.isValidWord( mSuggest.getUnigramDictionaries(), suggestion, true)); - if (!recorrecting) { - // Fool the state watcher so that a subsequent backspace will not do a revert, unless - // we just did a correction, in which case we need to stay in - // TextEntryState.State.PICKED_SUGGESTION state. - TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true, - WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE); - } + // Fool the state watcher so that a subsequent backspace will not do a revert, unless + // we just did a correction, in which case we need to stay in + // TextEntryState.State.PICKED_SUGGESTION state. + TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true, + WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE); if (!showingAddToDictionaryHint) { // If we're not showing the "Touch again to save", then show corrections again. // In case the cursor position doesn't change, make sure we show the suggestions again. diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java index 4204b8a4f..82242f87e 100644 --- a/java/src/com/android/inputmethod/latin/TextEntryState.java +++ b/java/src/com/android/inputmethod/latin/TextEntryState.java @@ -34,7 +34,6 @@ public class TextEntryState { private static final int SPACE_AFTER_ACCEPTED = 6; private static final int SPACE_AFTER_PICKED = 7; private static final int UNDO_COMMIT = 8; - private static final int PICKED_RECORRECTION = 9; private static int sState = UNKNOWN; private static int sPreviousState = UNKNOWN; @@ -77,13 +76,7 @@ public class TextEntryState { } public static void acceptedSuggestion(CharSequence typedWord, CharSequence actualWord) { - if (sState == PICKED_RECORRECTION) { - // TODO: this seems to be the only place where setState(PICKED_RECORRECTION) is done - // so this state should never be reached. Check this and remove. - setState(PICKED_RECORRECTION); - } else { - setState(PICKED_SUGGESTION); - } + setState(PICKED_SUGGESTION); if (DEBUG) displayState("acceptedSuggestion", "typedWord", typedWord, "actualWord", actualWord); } @@ -111,7 +104,6 @@ public class TextEntryState { } break; case PICKED_SUGGESTION: - case PICKED_RECORRECTION: if (isSpace) { setState(SPACE_AFTER_PICKED); } else if (isSeparator) { @@ -166,10 +158,6 @@ public class TextEntryState { return sState == UNDO_COMMIT; } - public static boolean isRecorrecting() { - return sState == PICKED_RECORRECTION; - } - public static String getState() { return stateName(sState); } @@ -184,7 +172,6 @@ public class TextEntryState { case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED"; case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED"; case UNDO_COMMIT: return "UNDO_COMMIT"; - case PICKED_RECORRECTION: return "PICKED_RECORRECTION"; default: return "UNKNOWN"; } } From ace21e5b577d153641960538702647bcb1a6cf38 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 25 Oct 2011 11:08:58 -0700 Subject: [PATCH 07/10] Import revised translations. Change-Id: I45b2224d22ea73a50b7bfcc1a05b3ece25f402c5 --- java/res/values-bg/strings.xml | 6 ++---- java/res/values-da/strings.xml | 10 +++++----- java/res/values-de/strings.xml | 18 +++++++++--------- java/res/values-es-rUS/strings.xml | 2 +- java/res/values-es/strings.xml | 12 ++++++------ java/res/values-fr/strings.xml | 4 ++-- java/res/values-hr/strings.xml | 6 ++---- java/res/values-in/strings.xml | 6 ++---- java/res/values-it/strings.xml | 2 +- java/res/values-ja/strings.xml | 6 ++---- java/res/values-ko/strings.xml | 14 +++++++------- java/res/values-lt/strings.xml | 4 ++-- java/res/values-ms/strings.xml | 4 ++-- java/res/values-pl/strings.xml | 12 ++++++------ java/res/values-ru/strings.xml | 2 +- java/res/values-sl/strings.xml | 22 +++++++++++----------- java/res/values-zh-rCN/strings.xml | 14 +++++++------- java/res/values-zh-rTW/strings.xml | 8 ++++---- 18 files changed, 72 insertions(+), 80 deletions(-) diff --git a/java/res/values-bg/strings.xml b/java/res/values-bg/strings.xml index 2b266472f..30fe132d8 100644 --- a/java/res/values-bg/strings.xml +++ b/java/res/values-bg/strings.xml @@ -148,8 +148,6 @@ "английски (Великобритания)" "английски (САЩ)" "Режим за изучаване на използваемостта" - - - - + "Настройки за продължителност на вибрирането при натискане на клавиш" + "Настройки за силата на звука при натискане на клавиш" diff --git a/java/res/values-da/strings.xml b/java/res/values-da/strings.xml index 5d8f80635..b91acaa90 100644 --- a/java/res/values-da/strings.xml +++ b/java/res/values-da/strings.xml @@ -21,7 +21,7 @@ "Android-tastatur" - "Indstillinger for Android-tastatur" + "Android-tastatur-indstillinger" "Indstillinger for input" "Android-rettelse" "Indstillinger for stavekontrol" @@ -29,16 +29,16 @@ "Brug en tastaturlignende nærhedsalgoritme til stavekontrol" "Vibration ved tastetryk" "Lyd ved tastetryk" - "Popup ved tastetryk" + "Pop op ved tastetryk" "Generelt" "Tekstkorrigering" "Andre valgmuligheder" "Avancerede indstillinger" "Muligheder for ekspertbrugere" - "Forsink. afvis. af taste-popup" + "Forsink. afvis. af taste-pop op" "Ingen forsink." "Standard" - "Foreslå navne på kontaktpersoner" + "Foreslå navne på kontakter" "Brug navne fra Kontaktpersoner til forslag og rettelser" "Aktiver fornyet rettelse" "Angiv forslag til fornyet rettelse" @@ -54,7 +54,7 @@ "Automatisk retning" "Mellemrumstast og tegnsætning retter automatisk forkerte ord" "Fra" - "Beskeden" + "Moderat" "Aggressiv" "Meget aggressiv" "Bigram-forslag" diff --git a/java/res/values-de/strings.xml b/java/res/values-de/strings.xml index 2e23f1d09..d329f3271 100644 --- a/java/res/values-de/strings.xml +++ b/java/res/values-de/strings.xml @@ -27,7 +27,7 @@ "Einstellungen für Rechtschreibprüfung" "Näherungsdaten verwenden" "Tastaturähnl. Abstandsalgorith. für Rechtschreibprüfung verwenden" - "Vibrieren b. Tastendruck" + "Bei Tastendruck vibrieren" "Ton bei Tastendruck" "Pop-up bei Tastendruck" "Allgemein" @@ -35,7 +35,7 @@ "Sonstige Optionen" "Erweiterte Einstellungen" "Optionen für Experten" - "Verzög. Schlüssel-Pop-up" + "Tasten-Pop-up" "Keine Verzögerung" "Standard" "Kontakte vorschlagen" @@ -43,20 +43,20 @@ "Korrekturen aktivieren" "Vorschläge für Korrekturen festlegen" "Autom. Groß-/Kleinschr." - "Add-on-Wörterbücher" + "Erweiterte Wörterbücher" "Allgemeines Wörterbuch" - "Änderungsvorschläge anzeigen" + "Änderungsvorschläge" "Vorgeschlagene Wörter während des Tippens anzeigen" "Immer anzeigen" "Im Hochformat anzeigen" - "Immer ausblenden" - "Einstellungstaste anz." + "Nie anzeigen" + "Taste für Einstellungen" "Autokorrektur" "Korrektur fehlerhafter Wörter durch Leertaste und Satzzeichen" "Aus" "Mäßig" "Stark" - "Sehr aggressiv" + "Sehr stark" "Bigramm-Vorschläge" "Zur Verbesserung des Vorschlags vorheriges Wort verwenden" "Bigramm-Vervollständigung" @@ -128,7 +128,7 @@ "Hinweis:"" Versuchen Sie beim nächsten Mal, Satzzeichen wie \"Punkt\", \"Komma\" oder \"Fragezeichen\" per Sprachbefehl einzugeben." "Abbrechen" "OK" - "Schlüssel für Spracheingabe" + "Taste für Spracheingabe" "Auf Haupttastatur" "Auf Symboltastatur" "Aus" @@ -149,5 +149,5 @@ "Englisch (USA)" "Modus der Studie zur Benutzerfreundlichkeit" "Einstellungen für Vibrationsdauer bei Tastendruck" - "Einstellungen für Sound-Lautstärke bei Tastendruck" + "Einstellungen für Tonlautstärke bei Tastendruck" diff --git a/java/res/values-es-rUS/strings.xml b/java/res/values-es-rUS/strings.xml index a45a2a4c5..95e309ff7 100644 --- a/java/res/values-es-rUS/strings.xml +++ b/java/res/values-es-rUS/strings.xml @@ -149,5 +149,5 @@ "Inglés (EE.UU.)" "Modo de estudio de usabilidad" "Configuración de la duración de vibraciones al presionar las teclas" - "Configuración de la duración de volumen al presionar las teclas" + "Configuración del volumen de sonio al presionar las teclas" diff --git a/java/res/values-es/strings.xml b/java/res/values-es/strings.xml index 516e81021..9c97250a9 100644 --- a/java/res/values-es/strings.xml +++ b/java/res/values-es/strings.xml @@ -29,7 +29,7 @@ "Usar algoritmo de proximidad de teclado para corregir la ortografía" "Vibrar al pulsar tecla" "Sonido al pulsar tecla" - "Popup al pulsar tecla" + "Pop-up al pulsar tecla" "General" "Corrección ortográfica" "Otras opciones" @@ -52,11 +52,11 @@ "Ocultar siempre" "Mostrar tecla de ajustes" "Autocorrección" - "Espacio y punt para corregir errores" + "Pulsa la tecla de espacio o punto para corregir errores" "Desactivada" "Parcial" "Total" - "Muy agresivo" + "Muy agresiva" "Sugerencias de bigramas" "Usar palabra anterior para mejorar sugerencias" "Predicción de bigramas" @@ -132,15 +132,15 @@ "En teclado principal" "En teclado de símbolos" "Desactivada" - "Micro en teclado principal" + "Micrófono en teclado principal" "Micro en teclado de símbolos" "Entrada de voz inhabilitada" - "Seleccionar método de introducción de texto" + "Selecciona un método de introducción de texto" "Configurar métodos de introducción" "Idiomas" "Idiomas de entrada" "← Volver a tocar para guardar" - "Hay un diccionario disponible." + "Hay un diccionario disponible" "Habilitar comentarios de usuarios" "Ayuda a mejorar este editor de método de introducción de texto enviando estadísticas de uso e informes de error a Google." "Tema de teclado" diff --git a/java/res/values-fr/strings.xml b/java/res/values-fr/strings.xml index ae14e2fdc..ef9303e88 100644 --- a/java/res/values-fr/strings.xml +++ b/java/res/values-fr/strings.xml @@ -148,6 +148,6 @@ "Anglais (Royaume-Uni)" "Anglais (États-Unis)" "Mode d\'étude de l\'utilisabilité" - "Paramètres de durée du vibreur à chaque touche" - "Paramètres de volume du son à chaque touche" + "Paramètres de durée du vibreur à chaque pression de touche" + "Paramètres de volume sonore à chaque pression de touche" diff --git a/java/res/values-hr/strings.xml b/java/res/values-hr/strings.xml index 49e71d16b..30c20b3cc 100644 --- a/java/res/values-hr/strings.xml +++ b/java/res/values-hr/strings.xml @@ -148,8 +148,6 @@ "Engleski (UK)" "Engleski (SAD)" "Način studije upotrebljivosti" - - - - + "Postavke trajanja vibracije kod pritiska tipke" + "Postavke glasnoće zvuka kod pritiska tipke" diff --git a/java/res/values-in/strings.xml b/java/res/values-in/strings.xml index 663ea1ee1..a023b6477 100644 --- a/java/res/values-in/strings.xml +++ b/java/res/values-in/strings.xml @@ -148,8 +148,6 @@ "Inggris (Inggris)" "Inggris (AS)" "Modus studi daya guna" - - - - + "Setelan durasi getaran saat tombol ditekan" + "Setelan volume suara saat tombol ditekan" diff --git a/java/res/values-it/strings.xml b/java/res/values-it/strings.xml index ef9ba04b1..58c0e2c3b 100644 --- a/java/res/values-it/strings.xml +++ b/java/res/values-it/strings.xml @@ -114,7 +114,7 @@ "Per disattivare l\'input vocale, vai alle impostazioni del metodo di input." "Per utilizzare l\'input vocale, premi il pulsante del microfono." "Parla ora" - "Elaborazione in corso" + "Elaborazione..." "Errore. Riprova più tardi." "Impossibile connettersi." diff --git a/java/res/values-ja/strings.xml b/java/res/values-ja/strings.xml index 14972854a..57b389580 100644 --- a/java/res/values-ja/strings.xml +++ b/java/res/values-ja/strings.xml @@ -148,8 +148,6 @@ "英語(英国)" "英語(米国)" "使いやすさの研究モード" - - - - + "キー操作バイブの振動時間の設定" + "キー操作音の音量設定" diff --git a/java/res/values-ko/strings.xml b/java/res/values-ko/strings.xml index 5ccc95083..bc2b6289c 100644 --- a/java/res/values-ko/strings.xml +++ b/java/res/values-ko/strings.xml @@ -38,25 +38,25 @@ "키 팝업 해제 지연" "지연 없음" "기본값" - "연락처 이름 추천" + "주소록 이름 활용" "추천 및 수정에 주소록의 이름 사용" - "다시 수정 가능하도록 설정" - "다시 수정하기 위한 추천사항 설정" + "재수정 가능 설정" + "재수정 추천어 사전 활성화" "자동 대문자화" "사전 추가" "기본 사전" "수정 제안 표시" "글자를 입력하는 동안 추천 단어 표시" "항상 표시" - "세로 모드로 표시" + "세로 화면일 때만 표시" "항상 숨기기" "설정 키 표시" "자동 수정" "스페이스바와 문장부호 키를 사용하면 오타가 자동으로 교정됩니다." "사용 안함" - "보통" - "적극적" - "매우 적극적" + "약" + "중" + "강" "Bigram 추천" "이전 단어를 사용하여 추천 기능 개선" "Bigram 예측" diff --git a/java/res/values-lt/strings.xml b/java/res/values-lt/strings.xml index 333355382..6263f6706 100644 --- a/java/res/values-lt/strings.xml +++ b/java/res/values-lt/strings.xml @@ -148,6 +148,6 @@ "Anglų k. (JK)" "Anglų k. (JAV)" "Tinkamumo tyrimo režimas" - "Vibracijos nuspaudus mygtuką trukmės nustatymai" - "Garso nuspaudus mygtuką garsumo nustatymai" + "Vibracijos paspaudus mygtuką trukmės nustatymai" + "Garso paspaudus mygtuką garsumo nustatymai" diff --git a/java/res/values-ms/strings.xml b/java/res/values-ms/strings.xml index 498a9a4d8..8a9954175 100644 --- a/java/res/values-ms/strings.xml +++ b/java/res/values-ms/strings.xml @@ -148,6 +148,6 @@ "Bahasa Inggeris (UK)" "Bahasa Inggeris (AS)" "Mod kajian kebolehgunaan" - "Tekan kunci tetapan tempoh getaran" - "Tekan kunci tetapan kelantangan bunyi" + "Tetapan tempoh getaran tekanan kekunci" + "Tetapan kelantangan bunyi tekanan kekunci" diff --git a/java/res/values-pl/strings.xml b/java/res/values-pl/strings.xml index 458d3c3d4..a9a6a76b6 100644 --- a/java/res/values-pl/strings.xml +++ b/java/res/values-pl/strings.xml @@ -35,10 +35,10 @@ "Inne opcje" "Ustawienia zaawansowane" "Opcje dla zaawansowanych użytkowników" - "Opóźnienie wyłączenia wyskakującego okienka" + "Opóźnienie znikania klawiszy" "Bez opóźnienia" "Wartość domyślna" - "Proponuj nazwiska z kontaktów" + "Proponuj osoby z kontaktów" "W propozycjach i poprawkach użyj nazwisk z kontaktów" "Włącz poprawki" "Ustaw sugestie poprawek" @@ -56,7 +56,7 @@ "Wyłącz" "Umiarkowana" "Agresywna" - "Bardzo agresywnie" + "Bardzo agresywna" "Podpowiadanie dwuznaków" "Używaj poprzedniego wyrazu, aby polepszyć sugestię" "Przewidywanie dwuznaków" @@ -128,7 +128,7 @@ "Wskazówka:"" następnym razem spróbuj wypowiadać nazwy znaków interpunkcyjnych: „kropka”, „przecinek” lub „pytajnik”." "Anuluj" "OK" - "Klawisz wprowadzania głosowego" + "Klawisz rozpoznawania mowy" "Na klawiaturze głównej" "Na klawiaturze z symbolami" "Wyłącz" @@ -148,6 +148,6 @@ "Angielska (Wielka Brytania)" "Angielska (Stany Zjednoczone)" "Tryb badania przydatności" - "Ustawienia czasu trwania wibracji przy naciśnięciu" - "Ustawienia głośności dźwięku przy naciśnięciu" + "Czas trwania wibracji przy naciśnięciu" + "Głośność dźwięku przy naciśnięciu" diff --git a/java/res/values-ru/strings.xml b/java/res/values-ru/strings.xml index 9af496bb1..863c8a28c 100644 --- a/java/res/values-ru/strings.xml +++ b/java/res/values-ru/strings.xml @@ -139,7 +139,7 @@ "Настройка способов ввода" "Языки ввода" "Языки ввода" - "← Нажмите еще раз, чтобы сохранить" + "← Нажмите, чтобы сохранить" "Доступен словарь" "Включить отправку сведений" "Помогите усовершенствовать редактор способа ввода, разрешив отправку статистики и отчетов о сбоях в Google." diff --git a/java/res/values-sl/strings.xml b/java/res/values-sl/strings.xml index c4661289a..d7f357aa0 100644 --- a/java/res/values-sl/strings.xml +++ b/java/res/values-sl/strings.xml @@ -23,40 +23,40 @@ "Tipkovnica Android" "Nastavitve tipkovnice Android" "Možnosti vnosa" - "Popravek za Android" + "Preverjanje črkovanja za Android" "Nastavitve preverjanja črkovanja" "Uporabi podatke bližine" "Uporaba algoritma za preverjanje črkovanja na podlagi bližine znakov na tipkovnici" "Vibriranje ob pritisku tipke" "Zvok ob pritisku tipke" - "Pojavno okno ob pritisku tipke" + "Povečaj črko ob pritisku" "Splošno" - "Popravek besedila" + "Popravljanje besedila" "Druge možnosti" "Dodatne nastavitve" "Možnosti za izkušene uporabnike" - "Zakas. okna za zavrnitev" - "Brez zamude" + "Trajanje povečanja tipke" + "Brez zakasnitve" "Privzeto" "Predlagaj imena stikov" "Uporaba imen iz stikov za predloge in popravke" "Omogoči vnovične popravke" "Nastavitev predlogov za vnovične popravke" - "Samodejne velike začetnice" - "Nastavitev slovarjev" + "Samod. velike začetnice" + "Dodatni slovarji" "Glavni slovar" "Pokaži predloge popravkov" "Pokaži predlagane besede med tipkanjem" "Vedno pokaži" "Pokaži v pokončnem načinu" "Vedno skrij" - "Pokaži tipko za nastavitve" + "Tipka za prikaz nastavitev" "Samodejni popravek" "Preslednica in ločila samodejno popravijo napačno vtipkane besede" "Izklopljeno" "Zmerno" - "Agresivno" - "Zelo dosledno" + "Strogo" + "Zelo strogo" "Bigramni predlogi" "Predlog izboljšaj s prejšnjo besedo" "Bigramsko predvidevanje" @@ -128,7 +128,7 @@ "Nasvet:"" naslednjič poskusite ločila izgovoriti, npr. »pika«, »vejica« ali »vprašaj«." "Prekliči" "V redu" - "Ključ za glasovni vnos" + "Tipka za glasovni vnos" "Na glavni tipkovnici" "Na tipk. s simboli" "Izklopljeno" diff --git a/java/res/values-zh-rCN/strings.xml b/java/res/values-zh-rCN/strings.xml index 02cc67615..c3adf23c0 100644 --- a/java/res/values-zh-rCN/strings.xml +++ b/java/res/values-zh-rCN/strings.xml @@ -34,14 +34,14 @@ "文本更正" "其他选项" "高级设置" - "适合专家级用户的选项" - "关闭弹出式键盘的延迟" + "适合于资深用户的选项" + "关闭弹出键时的延迟" "无延迟" "默认" "推荐联系人姓名" "使用联系人中的姓名提供建议和更正" - "启用更正" - "设置更正建议" + "允许再次更正" + "设置建议以用于再次更正" "自动大写" "附加词典" "主词典" @@ -52,10 +52,10 @@ "始终隐藏" "显示设置键" "自动更正" - "空格键或标点自动更正拼写错误的字词" + "按空格键和标点可自动更正错别字" "关闭" - "部分" - "全部" + "小改" + "大改" "改动极大" "双连词建议" "使用以前的字词改进建议" diff --git a/java/res/values-zh-rTW/strings.xml b/java/res/values-zh-rTW/strings.xml index 88917819c..8d60fb7cd 100644 --- a/java/res/values-zh-rTW/strings.xml +++ b/java/res/values-zh-rTW/strings.xml @@ -39,7 +39,7 @@ "不延遲" "預設" "建議聯絡人名稱" - "使用「聯絡人」的名稱提供建議與修正" + "根據「聯絡人」名稱提供建議與修正" "啟用重新更正" "設定建議供重新更正" "自動大寫" @@ -52,7 +52,7 @@ "永遠隱藏" "顯示設定金鑰" "自動修正" - "自動插入空白鍵和標點符號鍵盤,以修正拼字錯誤" + "按空白鍵或標點符號時,自動修正前面的錯字" "關閉" "部分" "全部" @@ -111,7 +111,7 @@ "語音輸入" "語音輸入目前不支援您的語言,但是可以辨識英文。" "語音輸入使用 Google 的語音辨識功能,並遵循《""行動服務隱私權政策""》。" - "如要關閉語音輸入,請前往輸入方式設定。" + "如要關閉語音輸入,請前往輸入法設定。" "如要使用語音輸入,請按下麥克風按鈕。" "請說話" "辨識中" @@ -135,7 +135,7 @@ "主鍵盤上的麥克風" "符號鍵盤上的麥克風" "語音輸入已停用" - "選取輸入法" + "選擇輸入法" "設定輸入法" "輸入語言" "輸入語言" From 120586c226c416d2211b6ebb3f4b914a30f9a74f Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 25 Oct 2011 21:14:33 +0900 Subject: [PATCH 08/10] Group special spaces and double/swapped spaces in undo mode This introduces an elementary undo facility that accounts for magic space, strong space, double space and its cancelling, and swapped punctuation and its cancelling. The former three were existing behavior ; this change adds the swapped punctuation cancelling behavior. Bug: 5454442 Change-Id: I87af633f30caa2788e9af725e556a7f0746d9a14 --- .../android/inputmethod/latin/LatinIME.java | 216 +++++++++++------- 1 file changed, 129 insertions(+), 87 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 94be6f0fd..311f9e202 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -157,9 +157,21 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar SUGGESTION_VISIBILILTY_HIDE_VALUE }; - private static final int SPACE_STRENGTH_NORMAL = 0; - private static final int SPACE_STRENGTH_MAGIC = 1; - private static final int SPACE_STRENGTH_STRONG = 2; + // Magic space: a space that should disappear on space/apostrophe insertion, move after the + // punctuation on punctuation insertion, and become a real space on alpha char insertion. + // Weak space: a space that be swapped only by suggestion strip punctuation. + // Double space: the state where the user pressed space twice quickly, which LatinIME + // resolved as period-space. Undoing this converts the period to a space. + // Swap punctuation: the state where a (weak or magic) space and a punctuation from the + // suggestion strip have just been swapped. Undoing this swaps them back. + private static final int SPACE_STATE_NONE = 0; + private static final int SPACE_STATE_DOUBLE = 1; + private static final int SPACE_STATE_SWAP_PUNCTUATION = 2; + private static final int SPACE_STATE_MAGIC = 3; + private static final int SPACE_STATE_WEAK = 4; + + // Current space state of the input method. This can be any of the above constants. + private int mSpaceState; private Settings.Values mSettingsValues; @@ -194,12 +206,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private WordComposer mWordComposer = new WordComposer(); private CharSequence mBestWord; private boolean mHasUncommittedTypedChars; - // Magic space: a space that should disappear on space/apostrophe insertion, move after the - // punctuation on punctuation insertion, and become a real space on alpha char insertion. - private int mLastSpaceStrength; // This indicates whether the last space is normal/magic/strong. - // This indicates whether the last keypress resulted in processing of double space replacement - // with period-space. - private boolean mJustReplacedDoubleSpace; private int mCorrectionMode; private int mCommittedLength; @@ -731,8 +737,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mComposingStringBuilder.setLength(0); mHasUncommittedTypedChars = false; mDeleteCount = 0; - mLastSpaceStrength = SPACE_STRENGTH_NORMAL; - mJustReplacedDoubleSpace = false; + mSpaceState = SPACE_STATE_NONE; loadSettings(); updateCorrectionMode(); @@ -893,10 +898,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; if (!mExpectingUpdateSelection) { - if (isShowingPunctuationList()) { - // Test for the punctuation list because there is a race condition that - // may end up in coming here on a normal key press - mLastSpaceStrength = SPACE_STRENGTH_STRONG; + if (SPACE_STATE_WEAK == mSpaceState) { + // Test for no WEAK_SPACE action because there is a race condition that may end up + // in coming here on a normal key press. We set this to NONE because after + // a cursor move, we don't want the suggestion strip to swap the space with the + // newly inserted punctuation. + mSpaceState = SPACE_STATE_NONE; } if (((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) || mVoiceProxy.isVoiceInputHighlighted()) @@ -915,7 +922,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar TextEntryState.reset(); updateSuggestions(); } - mJustReplacedDoubleSpace = false; } mExpectingUpdateSelection = false; mHandler.postUpdateShiftKeyState(); @@ -1153,10 +1159,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - private void maybeDoubleSpace() { - if (mCorrectionMode == Suggest.CORRECTION_NONE) return; - final InputConnection ic = getCurrentInputConnection(); - if (ic == null) return; + private boolean maybeDoubleSpaceWhileInBatchEdit(final InputConnection ic) { + if (mCorrectionMode == Suggest.CORRECTION_NONE) return false; + if (ic == null) return false; final CharSequence lastThree = ic.getTextBeforeCursor(3, 0); if (lastThree != null && lastThree.length() == 3 && Utils.canBeFollowedByPeriod(lastThree.charAt(0)) @@ -1164,15 +1169,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar && lastThree.charAt(2) == Keyboard.CODE_SPACE && mHandler.isAcceptingDoubleSpaces()) { mHandler.cancelDoubleSpacesTimer(); - ic.beginBatchEdit(); ic.deleteSurroundingText(2, 0); ic.commitText(". ", 1); - ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); - mJustReplacedDoubleSpace = true; - } else { - mHandler.startDoubleSpacesTimer(); + return true; } + return false; } // "ic" must not be null @@ -1246,12 +1248,26 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return mOptionsDialog != null && mOptionsDialog.isShowing(); } - private void onCodeInputWithSpaceStrength(final int primaryCode, final int[] keyCodes, - final int x, final int y, final int spaceStrength) { - final int lastStateOfSpaceStrength = mLastSpaceStrength; - mLastSpaceStrength = spaceStrength; - onCodeInput(primaryCode, keyCodes, x, y); - mLastSpaceStrength = lastStateOfSpaceStrength; + private void insertPunctuationFromSuggestionStrip(final InputConnection ic, final int code) { + final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : null; + final int toLeft = TextUtils.isEmpty(beforeText) ? 0 : beforeText.charAt(0); + final boolean shouldRegisterSwapPunctuation; + // If we have a space left of the cursor and it's a weak or a magic space, then we should + // swap it, and override the space state with SPACESTATE_SWAP_PUNCTUATION. + // To swap it, we fool handleSeparator to think the previous space state was a + // magic space. + if (Keyboard.CODE_SPACE == toLeft && mSpaceState == SPACE_STATE_WEAK) { + mSpaceState = SPACE_STATE_MAGIC; + shouldRegisterSwapPunctuation = true; + } else { + shouldRegisterSwapPunctuation = false; + } + onCodeInput(code, new int[] { code }, + KeyboardActionListener.NOT_A_TOUCH_COORDINATE, + KeyboardActionListener.NOT_A_TOUCH_COORDINATE); + if (shouldRegisterSwapPunctuation) { + mSpaceState = SPACE_STATE_SWAP_PUNCTUATION; + } } // Implementation of {@link KeyboardActionListener}. @@ -1264,11 +1280,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mLastKeyTime = when; KeyboardSwitcher switcher = mKeyboardSwitcher; final boolean distinctMultiTouch = switcher.hasDistinctMultitouch(); - final boolean lastStateOfJustReplacedDoubleSpace = mJustReplacedDoubleSpace; - mJustReplacedDoubleSpace = false; + // The space state depends only on the last character pressed and its own previous + // state. Here, we revert the space state to neutral if the key is actually modifying + // the input contents (any non-shift key), which is what we should do for + // all inputs that do not result in a special state. Each character handling is then + // free to override the state as they see fit. + final int spaceState = mSpaceState; switch (primaryCode) { case Keyboard.CODE_DELETE: - handleBackspace(lastStateOfJustReplacedDoubleSpace); + mSpaceState = SPACE_STATE_NONE; + handleBackspace(spaceState); mDeleteCount++; mExpectingUpdateSelection = true; LatinImeLogger.logOnDelete(); @@ -1314,10 +1335,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // To sum it up: do not update mExpectingUpdateSelection here. break; default: + mSpaceState = SPACE_STATE_NONE; if (mSettingsValues.isWordSeparator(primaryCode)) { - handleSeparator(primaryCode, x, y); + handleSeparator(primaryCode, x, y, spaceState); } else { - handleCharacter(primaryCode, keyCodes, x, y); + handleCharacter(primaryCode, keyCodes, x, y, spaceState); } mExpectingUpdateSelection = true; break; @@ -1339,7 +1361,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.onKey(Keyboard.CODE_DUMMY); - mLastSpaceStrength = SPACE_STRENGTH_NORMAL; + mSpaceState = SPACE_STATE_NONE; mEnteredText = text; } @@ -1349,7 +1371,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mKeyboardSwitcher.onCancelInput(); } - private void handleBackspace(boolean justReplacedDoubleSpace) { + private void handleBackspace(final int spaceState) { if (mVoiceProxy.logAndRevertVoiceInput()) return; final InputConnection ic = getCurrentInputConnection(); @@ -1387,18 +1409,24 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } mHandler.postUpdateShiftKeyState(); - // After backspace we want to reset the space to strong to prevent an undue swap with - // a subsequent press of a punctuation sign in the suggestion strip. - mLastSpaceStrength = SPACE_STRENGTH_STRONG; + // TODO: Merge space state with TextEntryState TextEntryState.backspace(); if (TextEntryState.isUndoCommit()) { revertLastWord(ic); ic.endBatchEdit(); return; } - if (justReplacedDoubleSpace) { + if (SPACE_STATE_DOUBLE == spaceState) { if (revertDoubleSpace(ic)) { ic.endBatchEdit(); + // No need to reset mSpaceState, it has already be done (that's why we + // receive it as a parameter) + return; + } + } else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) { + if (revertSwapPunctuation(ic)) { + ic.endBatchEdit(); + // Likewise return; } } @@ -1448,12 +1476,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) { + private void handleCharacter(final int primaryCode, final int[] keyCodes, final int x, + final int y, final int spaceState) { mVoiceProxy.handleCharacter(); final InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.beginBatchEdit(); - if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength + if (SPACE_STATE_MAGIC == spaceState && mSettingsValues.isMagicSpaceStripper(primaryCode)) { removeTrailingSpaceWhileInBatchEdit(ic); } @@ -1512,11 +1541,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } else { sendKeyChar((char)code); } - if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength + if (SPACE_STATE_MAGIC == spaceState && mSettingsValues.isMagicSpaceSwapper(primaryCode)) { if (null != ic) swapSwapperAndSpaceWhileInBatchEdit(ic); - } else { - mLastSpaceStrength = SPACE_STRENGTH_NORMAL; } switcher.updateShiftState(); @@ -1525,7 +1552,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (null != ic) ic.endBatchEdit(); } - private void handleSeparator(int primaryCode, int x, int y) { + private void handleSeparator(final int primaryCode, final int x, final int y, + final int spaceState) { mVoiceProxy.handleSeparator(); mComposingStateManager.onFinishComposingText(); @@ -1555,23 +1583,45 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } } - if (SPACE_STRENGTH_MAGIC == mLastSpaceStrength) { + final boolean swapMagicSpace; + if (SPACE_STATE_MAGIC == spaceState) { if (mSettingsValues.isMagicSpaceSwapper(primaryCode)) { - sendKeyChar((char)primaryCode); - swapSwapperAndSpaceWhileInBatchEdit(ic); + swapMagicSpace = true; } else { + swapMagicSpace = false; if (mSettingsValues.isMagicSpaceStripper(primaryCode)) { removeTrailingSpaceWhileInBatchEdit(ic); } - sendKeyChar((char)primaryCode); - mLastSpaceStrength = SPACE_STRENGTH_NORMAL; } } else { - sendKeyChar((char)primaryCode); + swapMagicSpace = false; } - if (isSuggestionsRequested() && primaryCode == Keyboard.CODE_SPACE) { - maybeDoubleSpace(); + sendKeyChar((char)primaryCode); + + if (Keyboard.CODE_SPACE == primaryCode) { + if (isSuggestionsRequested()) { + if (maybeDoubleSpaceWhileInBatchEdit(ic)) { + mSpaceState = SPACE_STATE_DOUBLE; + } else if (!isShowingPunctuationList()) { + mSpaceState = SPACE_STATE_WEAK; + } + } + + mHandler.startDoubleSpacesTimer(); + if (!isCursorTouchingWord()) { + mHandler.cancelUpdateSuggestions(); + mHandler.postUpdateBigramPredictions(); + } + } else { + if (swapMagicSpace) { + swapSwapperAndSpaceWhileInBatchEdit(ic); + mSpaceState = SPACE_STATE_MAGIC; + } + + // Set punctuation right away. onUpdateSelection will fire but tests whether it is + // already displayed or not, so it's okay. + setPunctuationSuggestions(); } TextEntryState.typedCharacter((char) primaryCode, true, x, y); @@ -1584,19 +1634,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic, mLastSelectionEnd - typedWord.length(), typedWord, mBestWord); } } - if (Keyboard.CODE_SPACE == primaryCode) { - if (isShowingPunctuationList()) { - mLastSpaceStrength = SPACE_STRENGTH_STRONG; - } - if (!isCursorTouchingWord()) { - mHandler.cancelUpdateSuggestions(); - mHandler.postUpdateBigramPredictions(); - } - } else { - // Set punctuation right away. onUpdateSelection will fire but tests whether it is - // already displayed or not, so it's okay. - setPunctuationSuggestions(); - } mKeyboardSwitcher.updateShiftState(); if (ic != null) { ic.endBatchEdit(); @@ -1836,8 +1873,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar LatinImeLogger.logOnManualSuggestion( "", suggestion.toString(), index, suggestions.mWords); // Find out whether the previous character is a space. If it is, as a special case - // for punctuation entered through the suggestion strip, it should be considered - // a magic space even if it was a normal space. This is meant to help in case the user + // for punctuation entered through the suggestion strip, it should be swapped + // if it was a magic or a weak space. This is meant to help in case the user // pressed space on purpose of displaying the suggestion strip punctuation. final int rawPrimaryCode = suggestion.charAt(0); // Maybe apply the "bidi mirrored" conversions for parentheses @@ -1845,18 +1882,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final boolean isRtl = keyboard != null && keyboard.mIsRtlKeyboard; final int primaryCode = Key.getRtlParenthesisCode(rawPrimaryCode, isRtl); - final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : ""; - final int toLeft = (ic == null || TextUtils.isEmpty(beforeText)) - ? 0 : beforeText.charAt(0); - final int spaceStrength; - if (Keyboard.CODE_SPACE == toLeft && mLastSpaceStrength != SPACE_STRENGTH_STRONG) { - spaceStrength = SPACE_STRENGTH_MAGIC; - } else { - spaceStrength = mLastSpaceStrength; - } - onCodeInputWithSpaceStrength(primaryCode, new int[] { primaryCode }, - KeyboardActionListener.NOT_A_TOUCH_COORDINATE, - KeyboardActionListener.NOT_A_TOUCH_COORDINATE, spaceStrength); + insertPunctuationFromSuggestionStrip(ic, primaryCode); + // TODO: the following endBatchEdit seems useless, check if (ic != null) { ic.endBatchEdit(); } @@ -2046,13 +2073,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return false; } - // "ic" must not null + // "ic" must not be null private boolean sameAsTextBeforeCursor(final InputConnection ic, CharSequence text) { CharSequence beforeText = ic.getTextBeforeCursor(text.length(), 0); return TextUtils.equals(text, beforeText); } - // "ic" must not null + // "ic" must not be null private void revertLastWord(final InputConnection ic) { if (mHasUncommittedTypedChars || mComposingStringBuilder.length() <= 0) { sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL); @@ -2086,7 +2113,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mHandler.postUpdateSuggestions(); } - // "ic" must not null + // "ic" must not be null private boolean revertDoubleSpace(final InputConnection ic) { mHandler.cancelDoubleSpacesTimer(); // Here we test whether we indeed have a period and a space before us. This should not @@ -2101,13 +2128,28 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return true; } + private boolean revertSwapPunctuation(final InputConnection ic) { + // Here we test whether we indeed have a space and something else before us. This should not + // be needed, but it's there just in case something went wrong. + final CharSequence textBeforeCursor = ic.getTextBeforeCursor(2, 0); + // NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to + // enter surrogate pairs this code will have been removed. + if (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1)) + return false; + ic.beginBatchEdit(); + ic.deleteSurroundingText(2, 0); + ic.commitText(" " + textBeforeCursor.subSequence(0, 1), 1); + ic.endBatchEdit(); + return true; + } + public boolean isWordSeparator(int code) { return mSettingsValues.isWordSeparator(code); } private void sendMagicSpace() { sendKeyChar((char)Keyboard.CODE_SPACE); - mLastSpaceStrength = SPACE_STRENGTH_MAGIC; + mSpaceState = SPACE_STATE_MAGIC; mKeyboardSwitcher.updateShiftState(); } From e51d164482c7896892d6eccb80f1e1e6fe6d50db Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 26 Oct 2011 20:54:35 +0900 Subject: [PATCH 09/10] Remove eventTime argument from PointerTracker.onShowMoreKeysPanel Change-Id: Idbcd6e3047c6c0c407e3b347cf9f65951d43a312 --- .../com/android/inputmethod/keyboard/LatinKeyboardView.java | 4 +--- .../src/com/android/inputmethod/keyboard/PointerTracker.java | 5 +++-- java/src/com/android/inputmethod/latin/SuggestionsView.java | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index a24195e87..3a6d1a4f2 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -21,7 +21,6 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Canvas; import android.os.Message; -import android.os.SystemClock; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; @@ -452,8 +451,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke this, this, pointX, pointY, mMoreKeysWindow, getKeyboardActionListener()); final int translatedX = moreKeysPanel.translateX(tracker.getLastX()); final int translatedY = moreKeysPanel.translateY(tracker.getLastY()); - tracker.onShowMoreKeysPanel( - translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel); + tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel); dimEntireKeyboard(true); return true; } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 38c419dc6..d5986aa32 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard; import android.content.Context; import android.content.res.Resources; +import android.os.SystemClock; import android.util.Log; import android.view.MotionEvent; import android.widget.TextView; @@ -615,9 +616,9 @@ public class PointerTracker { } } - public void onShowMoreKeysPanel(int x, int y, long eventTime, KeyEventHandler handler) { + public void onShowMoreKeysPanel(int x, int y, KeyEventHandler handler) { onLongPressed(); - onDownEvent(x, y, eventTime, handler); + onDownEvent(x, y, SystemClock.uptimeMillis(), handler); mIsShowingMoreKeysPanel = true; } diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index c25ecb382..3b0715cfd 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -30,7 +30,6 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Message; -import android.os.SystemClock; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; @@ -832,8 +831,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, // Decided to be in the sliding input mode only when the touch point has been moved // upward. mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_SLIDING_MODE; - tracker.onShowMoreKeysPanel( - translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel); + tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel); } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) { // Decided to be in the modal input mode mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_MODAL_MODE; From d999ea44805ae0a3ccac4c4f49aaf500f6c479ac Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 26 Oct 2011 20:49:57 +0900 Subject: [PATCH 10/10] Use onCustomRequest to request haptick and audio feedback Change-Id: I958f274d8cfebb1551cdf08f1bada50c20fb9ca0 --- .../android/inputmethod/keyboard/Keyboard.java | 1 - .../keyboard/LatinKeyboardView.java | 8 +++++--- .../android/inputmethod/latin/LatinIME.java | 18 +++++++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index a57b9d172..8d40e7aa5 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -75,7 +75,6 @@ public class Keyboard { public static final int CODE_DELETE = -5; public static final int CODE_SETTINGS = -6; public static final int CODE_SHORTCUT = -7; - public static final int CODE_HAPTIC_AND_AUDIO_FEEDBACK_ONLY = -98; // Code value representing the code is not specified. public static final int CODE_UNSPECIFIED = -99; diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index a24195e87..4b7c94d8a 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -349,9 +349,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // When shift key is double tapped, the first tap is correctly processed as usual tap. And // the second tap is treated as this double tap event, so that we need not mark tracker // calling setAlreadyProcessed() nor remove the tracker from mPointerQueue. - final int primaryCode = ignore ? Keyboard.CODE_HAPTIC_AND_AUDIO_FEEDBACK_ONLY - : Keyboard.CODE_CAPSLOCK; - mKeyboardActionListener.onCodeInput(primaryCode, null, 0, 0); + if (ignore) { + mKeyboardActionListener.onCustomRequest(LatinIME.CODE_HAPTIC_AND_AUDIO_FEEDBACK); + } else { + mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0); + } } // This default implementation returns a more keys panel. diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 94be6f0fd..b6f189b35 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1227,6 +1227,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // Virtual codes representing custom requests. These are used in onCustomRequest() below. public static final int CODE_SHOW_INPUT_METHOD_PICKER = 1; + public static final int CODE_HAPTIC_AND_AUDIO_FEEDBACK = 2; @Override public boolean onCustomRequest(int requestCode) { @@ -1238,6 +1239,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return true; } return false; + case CODE_HAPTIC_AND_AUDIO_FEEDBACK: + hapticAndAudioFeedback(Keyboard.CODE_UNSPECIFIED); + return true; } return false; } @@ -1293,11 +1297,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar break; case Keyboard.CODE_CAPSLOCK: switcher.toggleCapsLock(); - //$FALL-THROUGH$ - case Keyboard.CODE_HAPTIC_AND_AUDIO_FEEDBACK_ONLY: - // Dummy code for haptic and audio feedbacks. - vibrate(); - playKeyClick(primaryCode); + hapticAndAudioFeedback(primaryCode); break; case Keyboard.CODE_SHORTCUT: mSubtypeSwitcher.switchToShortcutIME(); @@ -2129,12 +2129,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar loadSettings(); } + private void hapticAndAudioFeedback(int primaryCode) { + vibrate(); + playKeyClick(primaryCode); + } + @Override public void onPress(int primaryCode, boolean withSliding) { final KeyboardSwitcher switcher = mKeyboardSwitcher; if (switcher.isVibrateAndSoundFeedbackRequired()) { - vibrate(); - playKeyClick(primaryCode); + hapticAndAudioFeedback(primaryCode); } final boolean distinctMultiTouch = switcher.hasDistinctMultitouch(); if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {