diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
9 files changed, 47 insertions, 98 deletions
diff --git a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java index 5c4e9af68..700709d50 100644 --- a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java +++ b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java @@ -435,44 +435,6 @@ public class VoiceProxy implements VoiceInput.UiListener { } } - /** - * Tries to apply any voice alternatives for the word if this was a spoken word and - * there are voice alternatives. - * @param touching The word that the cursor is touching, with position information - * @return true if an alternative was found, false otherwise. - */ - public boolean applyVoiceAlternatives(EditingUtils.SelectedWord touching) { - if (!VOICE_INSTALLED) { - return false; - } - // Search for result in spoken word alternatives - String selectedWord = touching.mWord.toString().trim(); - if (!mWordToSuggestions.containsKey(selectedWord)) { - selectedWord = selectedWord.toLowerCase(); - } - if (mWordToSuggestions.containsKey(selectedWord)) { - mShowingVoiceSuggestions = true; - List<CharSequence> suggestions = mWordToSuggestions.get(selectedWord); - SuggestedWords.Builder builder = new SuggestedWords.Builder(); - // If the first letter of touching is capitalized, make all the suggestions - // start with a capital letter. - if (Character.isUpperCase(touching.mWord.charAt(0))) { - for (CharSequence word : suggestions) { - String str = word.toString(); - word = Character.toUpperCase(str.charAt(0)) + str.substring(1); - builder.addWord(word); - } - } else { - builder.addWords(suggestions, null); - } - builder.setTypedWordValid(true).setHasMinimalSuggestion(true); - mService.setSuggestions(builder.build()); -// mService.setCandidatesViewShown(true); - return true; - } - return false; - } - public void handleBackspace() { if (!VOICE_INSTALLED) { return; diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 0ce98d2f1..10cf1d1f4 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -267,7 +267,7 @@ public class KeyDetector { addDelimiter = false; } else { if (addDelimiter) sb.append(", "); - sb.append(code); + sb.append(Keyboard.printableCode(code)); addDelimiter = true; } } diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 30ed59e18..c6cdf7986 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -85,8 +85,6 @@ public class Keyboard { public static final int CODE_CLOSING_SQUARE_BRACKET = ']'; public static final int CODE_CLOSING_CURLY_BRACKET = '}'; public static final int CODE_CLOSING_ANGLE_BRACKET = '>'; - public static final int CODE_DIGIT0 = '0'; - public static final int CODE_PLUS = '+'; private static final int MINIMUM_LETTER_CODE = CODE_TAB; /** Special keys code. Must be negative. @@ -185,18 +183,11 @@ public class Keyboard { } // TODO: Remove this method. - public boolean isShiftLocked() { - return mId.isAlphabetShiftLockedKeyboard(); - } - - // TODO: Remove this method. public boolean isShiftedOrShiftLocked() { - return mId.isAlphabetShiftedOrShiftLockedKeyboard(); - } - - // TODO: Remove this method. - public boolean isManualShifted() { - return mId.isAlphabetManualShiftedKeyboard(); + // Alphabet mode have unshifted, manual shifted, automatic shifted, shift locked, and + // shift lock shifted element. So that unshifed element is the only one that is NOT in + // shifted or shift locked state. + return mId.isAlphabetKeyboard() && mId.mElementId != KeyboardId.ELEMENT_ALPHABET; } public static boolean isLetterCode(int code) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index ed4a89e0f..f5752962e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -36,6 +36,9 @@ public class KeyboardId { public static final int MODE_IM = 3; public static final int MODE_PHONE = 4; public static final int MODE_NUMBER = 5; + public static final int MODE_DATE = 6; + public static final int MODE_TIME = 7; + public static final int MODE_DATETIME = 8; public static final int ELEMENT_ALPHABET = 0; public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1; @@ -123,31 +126,6 @@ public class KeyboardId { return mElementId < ELEMENT_SYMBOLS; } - public boolean isAlphabetShiftLockedKeyboard() { - return mElementId == ELEMENT_ALPHABET_SHIFT_LOCKED - || mElementId == ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED; - } - - public boolean isAlphabetShiftedOrShiftLockedKeyboard() { - return isAlphabetKeyboard() && mElementId != ELEMENT_ALPHABET; - } - - public boolean isAlphabetManualShiftedKeyboard() { - return mElementId == ELEMENT_ALPHABET_MANUAL_SHIFTED; - } - - public boolean isSymbolsKeyboard() { - return mElementId == ELEMENT_SYMBOLS || mElementId == ELEMENT_SYMBOLS_SHIFTED; - } - - public boolean isPhoneKeyboard() { - return mElementId == ELEMENT_PHONE || mElementId == ELEMENT_PHONE_SYMBOLS; - } - - public boolean isPhoneShiftKeyboard() { - return mElementId == ELEMENT_PHONE_SYMBOLS; - } - public boolean navigateNext() { return EditorInfoCompatUtils.hasFlagNavigateNext(mEditorInfo.imeOptions); } @@ -242,6 +220,9 @@ public class KeyboardId { case MODE_IM: return "im"; case MODE_PHONE: return "phone"; case MODE_NUMBER: return "number"; + case MODE_DATE: return "date"; + case MODE_TIME: return "time"; + case MODE_DATETIME: return "datetime"; default: return null; } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java index 6e62f743b..ee882edc0 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java @@ -131,6 +131,9 @@ public class KeyboardSet { } break; case KeyboardId.MODE_NUMBER: + case KeyboardId.MODE_DATE: + case KeyboardId.MODE_TIME: + case KeyboardId.MODE_DATETIME: keyboardSetElementId = KeyboardId.ELEMENT_NUMBER; break; default: diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index d65253ede..78e0ee230 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -849,7 +849,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { final KeyPreviewDrawParams params = mKeyPreviewDrawParams; final int keyDrawX = key.mX + key.mVisualInsetsLeft; final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight; - // What we show as preview should match what we show on key top in onBufferDraw(). + // What we show as preview should match what we show on a key top in onBufferDraw(). if (key.mLabel != null) { // TODO Should take care of temporaryShiftLabel here. previewText.setCompoundDrawables(null, null, null, null); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 432959508..89dad7be5 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -481,11 +481,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke */ protected boolean onLongPress(Key parentKey, PointerTracker tracker) { final int primaryCode = parentKey.mCode; - final Keyboard keyboard = getKeyboard(); - if (primaryCode == Keyboard.CODE_DIGIT0 && keyboard.mId.isPhoneKeyboard()) { + if (parentKey.mAltCode != Keyboard.CODE_UNSPECIFIED) { + // Long press on a key that has altCode defined. tracker.onLongPressed(); - // Long pressing on 0 in phone number keypad gives you a '+'. - invokeCodeInput(Keyboard.CODE_PLUS); + invokeCodeInput(parentKey.mAltCode); invokeReleaseKey(primaryCode); KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode); return true; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 953d87beb..211b69a44 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -979,7 +979,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar .setTypedWordValid(false) .setHasMinimalSuggestion(false); // When in fullscreen mode, show completions generated by the application - setSuggestions(builder.build()); + final SuggestedWords words = builder.build(); + setSuggestions(words); + setAutoCorrectionIndicator(Utils.willAutoCorrect(words)); // TODO: is this the right thing to do? What should we auto-correct to in // this case? This says to keep whatever the user typed. mWordComposer.setAutoCorrection(mWordComposer.getTypedWord()); @@ -1713,21 +1715,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void clearSuggestions() { setSuggestions(SuggestedWords.EMPTY); + setAutoCorrectionIndicator(false); } - public void setSuggestions(SuggestedWords words) { + public void setSuggestions(final SuggestedWords words) { if (mSuggestionsView != null) { mSuggestionsView.setSuggestions(words); mKeyboardSwitcher.onAutoCorrectionStateChanged( words.hasWordAboveAutoCorrectionScoreThreshold()); } + } + private void setAutoCorrectionIndicator(final boolean newAutoCorrectionIndicator) { // Put a blue underline to a word in TextView which will be auto-corrected. final InputConnection ic = getCurrentInputConnection(); if (ic != null) { final boolean oldAutoCorrectionIndicator = mComposingStateManager.isAutoCorrectionIndicatorOn(); - final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words); if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) { mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator); if (DEBUG) { @@ -1738,9 +1742,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar throw new RuntimeException("Couldn't flip the indicator!"); } } - final CharSequence textWithUnderline = - getTextWithUnderline(mWordComposer.getTypedWord()); - if (!TextUtils.isEmpty(textWithUnderline)) { + if (mWordComposer.isComposingWord()) { + final CharSequence textWithUnderline = + getTextWithUnderline(mWordComposer.getTypedWord()); ic.setComposingText(textWithUnderline, 1); } } @@ -1830,25 +1834,25 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar showSuggestions(builder.build(), typedWord); } - public void showSuggestions(SuggestedWords suggestedWords, CharSequence typedWord) { + public void showSuggestions(final SuggestedWords suggestedWords, final CharSequence typedWord) { final boolean shouldBlockAutoCorrectionBySafetyNet = Utils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords, mSuggest); if (shouldBlockAutoCorrectionBySafetyNet) { suggestedWords.setShouldBlockAutoCorrection(); } - setSuggestions(suggestedWords); + final CharSequence autoCorrection; if (suggestedWords.size() > 0) { - if (shouldBlockAutoCorrectionBySafetyNet) { - mWordComposer.setAutoCorrection(typedWord); - } else if (suggestedWords.hasAutoCorrectionWord()) { - mWordComposer.setAutoCorrection(suggestedWords.getWord(1)); + if (!shouldBlockAutoCorrectionBySafetyNet && suggestedWords.hasAutoCorrectionWord()) { + autoCorrection = suggestedWords.getWord(1); } else { - mWordComposer.setAutoCorrection(typedWord); + autoCorrection = typedWord; } } else { - // TODO: replace with mWordComposer.deleteAutoCorrection()? - mWordComposer.setAutoCorrection(null); + autoCorrection = null; } + mWordComposer.setAutoCorrection(autoCorrection); + setSuggestions(suggestedWords); + setAutoCorrectionIndicator(Utils.willAutoCorrect(suggestedWords)); setSuggestionStripShown(isSuggestionsStripVisible()); } @@ -2022,6 +2026,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void setPunctuationSuggestions() { setSuggestions(mSettingsValues.mSuggestPuncList); + setAutoCorrectionIndicator(false); setSuggestionStripShown(isSuggestionsStripVisible()); } diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 6d63e95f6..47ea9ee8a 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -563,8 +563,16 @@ public class Utils { switch (inputType & InputType.TYPE_MASK_CLASS) { case InputType.TYPE_CLASS_NUMBER: - case InputType.TYPE_CLASS_DATETIME: return KeyboardId.MODE_NUMBER; + case InputType.TYPE_CLASS_DATETIME: + switch (variation) { + case InputType.TYPE_DATETIME_VARIATION_DATE: + return KeyboardId.MODE_DATE; + case InputType.TYPE_DATETIME_VARIATION_TIME: + return KeyboardId.MODE_TIME; + default: // InputType.TYPE_DATETIME_VARIATION_NORMAL + return KeyboardId.MODE_DATETIME; + } case InputType.TYPE_CLASS_PHONE: return KeyboardId.MODE_PHONE; case InputType.TYPE_CLASS_TEXT: |