diff options
Diffstat (limited to 'java/src')
8 files changed, 143 insertions, 92 deletions
diff --git a/java/src/com/android/inputmethod/event/InputTransaction.java b/java/src/com/android/inputmethod/event/InputTransaction.java index 4fe9b403e..cdff265c6 100644 --- a/java/src/com/android/inputmethod/event/InputTransaction.java +++ b/java/src/com/android/inputmethod/event/InputTransaction.java @@ -41,6 +41,7 @@ public class InputTransaction { // Outputs private int mRequiredShiftUpdate = SHIFT_NO_UPDATE; private boolean mRequiresUpdateSuggestions = false; + private boolean mDidAffectContents = false; public InputTransaction(final SettingsValues settingsValues, final Event event, final long timestamp, final int spaceState, final int shiftState) { @@ -81,4 +82,19 @@ public class InputTransaction { public boolean requiresUpdateSuggestions() { return mRequiresUpdateSuggestions; } + + /** + * Indicate that this transaction affected the contents of the editor. + */ + public void setDidAffectContents() { + mDidAffectContents = true; + } + + /** + * Find out whether this transaction affected contents of the editor. + * @return Whether this transaction affected contents of the editor. + */ + public boolean didAffectContents() { + return mDidAffectContents; + } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index 7ba3b3bd5..d01c4cc8f 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -211,6 +211,10 @@ public final class KeyboardLayoutSet { return keyboard; } + public int getScriptId() { + return mParams.mScriptId; + } + public static final class Builder { private final Context mContext; private final String mPackageName; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 6aeff189f..dd71e9d4f 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -370,4 +370,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { return WordComposer.CAPS_MODE_OFF; } } + + public int getCurrentKeyboardScriptId() { + return mKeyboardLayoutSet.getScriptId(); + } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 6e5e0deaa..865ff07d6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -227,14 +227,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen case MSG_RESUME_SUGGESTIONS: latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor( latinIme.mSettings.getCurrent(), - msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */); + msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */, + latinIme.mKeyboardSwitcher.getCurrentKeyboardScriptId()); break; case MSG_REOPEN_DICTIONARIES: latinIme.resetSuggest(); - // In theory we could call latinIme.updateSuggestionStrip() right away, but - // in the practice, the dictionary is not finished opening yet so we wouldn't - // get any suggestions. Wait one frame. - postUpdateSuggestionStrip(); + // We need to re-evaluate the currently composing word in case the script has + // changed. + postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */); break; case MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED: latinIme.mInputLogic.onUpdateTailBatchInputCompleted( @@ -446,22 +446,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen static final class SubtypeState { private InputMethodSubtype mLastActiveSubtype; - private boolean mCurrentSubtypeUsed; + private boolean mCurrentSubtypeHasBeenUsed; - public void currentSubtypeUsed() { - mCurrentSubtypeUsed = true; + public void setCurrentSubtypeHasBeenUsed() { + mCurrentSubtypeHasBeenUsed = true; } public void switchSubtype(final IBinder token, final RichInputMethodManager richImm) { final InputMethodSubtype currentSubtype = richImm.getInputMethodManager() .getCurrentInputMethodSubtype(); final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype; - final boolean currentSubtypeUsed = mCurrentSubtypeUsed; - if (currentSubtypeUsed) { + final boolean currentSubtypeHasBeenUsed = mCurrentSubtypeHasBeenUsed; + if (currentSubtypeHasBeenUsed) { mLastActiveSubtype = currentSubtype; - mCurrentSubtypeUsed = false; + mCurrentSubtypeHasBeenUsed = false; } - if (currentSubtypeUsed + if (currentSubtypeHasBeenUsed && richImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastActiveSubtype) && !currentSubtype.equals(lastActiveSubtype)) { richImm.setInputMethodAndSubtype(token, lastActiveSubtype); @@ -795,8 +795,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // span, so we should reset our state unconditionally, even if restarting is true. // We also tell the input logic about the combining rules for the current subtype, so // it can adjust its combiners if needed. - mInputLogic.startInput(restarting, editorInfo, - mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype()); + mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype()); // Note: the following does a round-trip IPC on the main thread: be careful final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale(); @@ -929,12 +928,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(), getCurrentRecapitalizeState()); } - - mSubtypeState.currentSubtypeUsed(); } @Override - public void onUpdateCursor(Rect rect) { + public void onUpdateCursor(final Rect rect) { if (DEBUG) { Log.i(TAG, "onUpdateCursor:" + rect.toShortString()); } @@ -1239,7 +1236,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat); final InputTransaction completeInputTransaction = mInputLogic.onCodeInput(mSettings.getCurrent(), event, - mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); + mKeyboardSwitcher.getKeyboardShiftMode(), + mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler); updateStateAfterInputTransaction(completeInputTransaction); mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(), getCurrentRecapitalizeState()); @@ -1266,9 +1264,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onTextInput(final String rawText) { // TODO: have the keyboard pass the correct key code when we need it. final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE); - mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler); - mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(), - getCurrentRecapitalizeState()); + final InputTransaction completeInputTransaction = + mInputLogic.onTextInput(mSettings.getCurrent(), event, + mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); + updateStateAfterInputTransaction(completeInputTransaction); mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState(), getCurrentRecapitalizeState()); } @@ -1423,10 +1422,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // interface @Override - public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) { + public void pickSuggestionManually(final SuggestedWordInfo suggestionInfo) { final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually( - mSettings.getCurrent(), index, suggestionInfo, - mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); + mSettings.getCurrent(), suggestionInfo, + mKeyboardSwitcher.getKeyboardShiftMode(), + mKeyboardSwitcher.getCurrentKeyboardScriptId(), + mHandler); updateStateAfterInputTransaction(completeInputTransaction); } @@ -1486,6 +1487,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (inputTransaction.requiresUpdateSuggestions()) { mHandler.postUpdateSuggestionStrip(); } + if (inputTransaction.didAffectContents()) { + mSubtypeState.setCurrentSubtypeHasBeenUsed(); + } } private void hapticAndAudioFeedback(final int code, final int repeatCount) { @@ -1553,7 +1557,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // If it's handled, we return true because we did handle it. if (event.isHandled()) { mInputLogic.onCodeInput(mSettings.getCurrent(), event, - mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); + mKeyboardSwitcher.getKeyboardShiftMode(), + // TODO: this is not necessarily correct for a hardware keyboard right now + mKeyboardSwitcher.getCurrentKeyboardScriptId(), + mHandler); return true; } return super.onKeyDown(keyCode, keyEvent); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index e43db352d..c347f69a9 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -87,6 +87,40 @@ public final class Suggest { } } + private static ArrayList<SuggestedWordInfo> getTransformedSuggestedWordInfoList( + final WordComposer wordComposer, final SuggestionResults results, + final int trailingSingleQuotesCount) { + final boolean shouldMakeSuggestionsAllUpperCase = wordComposer.isAllUpperCase() + && !wordComposer.isResumed(); + final boolean isOnlyFirstCharCapitalized = + wordComposer.isOrWillBeOnlyFirstCharCapitalized(); + + final ArrayList<SuggestedWordInfo> suggestionsContainer = new ArrayList<>(results); + final int suggestionsCount = suggestionsContainer.size(); + if (isOnlyFirstCharCapitalized || shouldMakeSuggestionsAllUpperCase + || 0 != trailingSingleQuotesCount) { + for (int i = 0; i < suggestionsCount; ++i) { + final SuggestedWordInfo wordInfo = suggestionsContainer.get(i); + final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo( + wordInfo, results.mLocale, shouldMakeSuggestionsAllUpperCase, + isOnlyFirstCharCapitalized, trailingSingleQuotesCount); + suggestionsContainer.set(i, transformedWordInfo); + } + } + return suggestionsContainer; + } + + private static String getWhitelistedWordOrNull(final ArrayList<SuggestedWordInfo> suggestions) { + if (suggestions.isEmpty()) { + return null; + } + final SuggestedWordInfo firstSuggestedWordInfo = suggestions.get(0); + if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { + return null; + } + return firstSuggestedWordInfo.mWord; + } + // Retrieves suggestions for the typing input // and calls the callback function with the suggestions. private void getSuggestedWordsForTypingInput(final WordComposer wordComposer, @@ -103,42 +137,14 @@ public final class Suggest { final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults( wordComposer, prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, SESSION_TYPING); - - final boolean isPrediction = !wordComposer.isComposingWord(); - final boolean shouldMakeSuggestionsAllUpperCase = wordComposer.isAllUpperCase() - && !wordComposer.isResumed(); - final boolean isOnlyFirstCharCapitalized = - wordComposer.isOrWillBeOnlyFirstCharCapitalized(); - final ArrayList<SuggestedWordInfo> suggestionsContainer = - new ArrayList<>(suggestionResults); - final int suggestionsCount = suggestionsContainer.size(); - if (isOnlyFirstCharCapitalized || shouldMakeSuggestionsAllUpperCase - || 0 != trailingSingleQuotesCount) { - for (int i = 0; i < suggestionsCount; ++i) { - final SuggestedWordInfo wordInfo = suggestionsContainer.get(i); - final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo( - wordInfo, suggestionResults.mLocale, shouldMakeSuggestionsAllUpperCase, - isOnlyFirstCharCapitalized, trailingSingleQuotesCount); - suggestionsContainer.set(i, transformedWordInfo); - } - } + getTransformedSuggestedWordInfoList(wordComposer, suggestionResults, + trailingSingleQuotesCount); final boolean didRemoveTypedWord = - SuggestedWordInfo.removeDups(typedWord, suggestionsContainer); + SuggestedWordInfo.removeDups(wordComposer.getTypedWord(), suggestionsContainer); - final SuggestedWordInfo firstSuggestedWordInfo; - final String whitelistedWord; - if (suggestionsContainer.isEmpty()) { - firstSuggestedWordInfo = null; - whitelistedWord = null; - } else { - firstSuggestedWordInfo = suggestionsContainer.get(0); - if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { - whitelistedWord = null; - } else { - whitelistedWord = firstSuggestedWordInfo.mWord; - } - } + final String whitelistedWord = getWhitelistedWordOrNull(suggestionsContainer); + final boolean resultsArePredictions = !wordComposer.isComposingWord(); // We allow auto-correction if we have a whitelisted word, or if the word had more than // one char and was not suggested. @@ -151,11 +157,11 @@ public final class Suggest { // same time, it feels wrong that the SuggestedWord object includes information about // the current settings. It may also be useful to know, when the setting is off, whether // the word *would* have been auto-corrected. - if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction - || null == firstSuggestedWordInfo || wordComposer.hasDigits() + if (!isCorrectionEnabled || !allowsToBeAutoCorrected || resultsArePredictions + || suggestionResults.isEmpty() || wordComposer.hasDigits() || wordComposer.isMostlyCaps() || wordComposer.isResumed() || !mDictionaryFacilitator.hasInitializedMainDictionary() - || firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_SHORTCUT)) { + || suggestionResults.first().isKindOf(SuggestedWordInfo.KIND_SHORTCUT)) { // If we don't have a main dictionary, we never want to auto-correct. The reason for // this is, the user may have a contact whose name happens to match a valid word in // their language, and it will unexpectedly auto-correct. For example, if the user @@ -167,7 +173,7 @@ public final class Suggest { hasAutoCorrection = false; } else { hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold( - firstSuggestedWordInfo, consideredWord, mAutoCorrectionThreshold); + suggestionResults.first(), consideredWord, mAutoCorrectionThreshold); } if (!TextUtils.isEmpty(typedWord)) { @@ -190,9 +196,9 @@ public final class Suggest { // TODO: this first argument is lying. If this is a whitelisted word which is an // actual word, it says typedWordValid = false, which looks wrong. We should either // rename the attribute or change the value. - !isPrediction && !allowsToBeAutoCorrected /* typedWordValid */, + !resultsArePredictions && !allowsToBeAutoCorrected /* typedWordValid */, hasAutoCorrection /* willAutoCorrect */, - false /* isObsoleteSuggestions */, isPrediction, sequenceNumber)); + false /* isObsoleteSuggestions */, resultsArePredictions, sequenceNumber)); } // Retrieves suggestions for the batch input diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 15ddcf9ae..8831d36f7 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -119,17 +119,10 @@ public final class InputLogic { * Initializes the input logic for input in an editor. * * Call this when input starts or restarts in some editor (typically, in onStartInputView). - * If the input is starting in the same field as before, set `restarting' to true. This allows - * the input logic to reset only necessary stuff and save performance. Also, when restarting - * some things must not be done (for example, the keyboard should not be reset to the - * alphabetic layout), so do not send false to this just in case. * - * @param restarting whether input is starting in the same field as before. Unused for now. - * @param editorInfo the editorInfo associated with the editor. * @param combiningSpec the combining spec string for this subtype */ - public void startInput(final boolean restarting, final EditorInfo editorInfo, - final String combiningSpec) { + public void startInput(final String combiningSpec) { mEnteredText = null; mWordComposer.restartCombining(combiningSpec); resetComposingState(true /* alsoResetLastComposedWord */); @@ -154,7 +147,8 @@ public final class InputLogic { * @param combiningSpec the spec string for the combining rules */ public void onSubtypeChanged(final String combiningSpec) { - mWordComposer.restartCombining(combiningSpec); + finishInput(); + startInput(combiningSpec); } /** @@ -187,11 +181,16 @@ public final class InputLogic { * * @param settingsValues the current values of the settings. * @param event the input event containing the data. + * @return the complete transaction object */ - public void onTextInput(final SettingsValues settingsValues, final Event event, + public InputTransaction onTextInput(final SettingsValues settingsValues, final Event event, + final int keyboardShiftMode, // TODO: remove this argument final LatinIME.UIHandler handler) { final String rawText = event.mText.toString(); + final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, + SystemClock.uptimeMillis(), mSpaceState, + getActualCapsMode(settingsValues, keyboardShiftMode)); mConnection.beginBatchEdit(); if (mWordComposer.isComposingWord()) { commitCurrentAutoCorrection(settingsValues, rawText, handler); @@ -208,12 +207,14 @@ public final class InputLogic { // Space state must be updated before calling updateShiftState mSpaceState = SpaceState.NONE; mEnteredText = text; + inputTransaction.setDidAffectContents(); + inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); + return inputTransaction; } /** * A suggestion was picked from the suggestion strip. * @param settingsValues the current values of the settings. - * @param index the index of the suggestion. * @param suggestionInfo the suggestion info. * @param keyboardShiftState the shift state of the keyboard, as returned by * {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()} @@ -222,9 +223,9 @@ public final class InputLogic { // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // interface public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues, - final int index, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState, - // TODO: remove this argument - final LatinIME.UIHandler handler) { + final SuggestedWordInfo suggestionInfo, final int keyboardShiftState, + // TODO: remove these arguments + final int currentKeyboardScriptId, final LatinIME.UIHandler handler) { final SuggestedWords suggestedWords = mSuggestedWords; final String suggestion = suggestionInfo.mWord; // If this is a punctuation picked from the suggestion strip, pass it to onCodeInput @@ -232,12 +233,16 @@ public final class InputLogic { // Word separators are suggested before the user inputs something. // Rely on onCodeInput to do the complicated swapping/stripping logic consistently. final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo); - return onCodeInput(settingsValues, event, keyboardShiftState, handler); + return onCodeInput(settingsValues, event, keyboardShiftState, + currentKeyboardScriptId, handler); } final Event event = Event.createSuggestionPickedEvent(suggestionInfo); final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, SystemClock.uptimeMillis(), mSpaceState, keyboardShiftState); + // Manual pick affects the contents of the editor, so we take note of this. It's important + // for the sequence of language switching. + inputTransaction.setDidAffectContents(); mConnection.beginBatchEdit(); if (SpaceState.PHANTOM == mSpaceState && suggestion.length() > 0 // In the batch input mode, a manually picked suggested word should just replace @@ -378,8 +383,8 @@ public final class InputLogic { */ public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event, final int keyboardShiftMode, - // TODO: remove this argument - final LatinIME.UIHandler handler) { + // TODO: remove these arguments + final int currentKeyboardScriptId, final LatinIME.UIHandler handler) { final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, SystemClock.uptimeMillis(), mSpaceState, getActualCapsMode(settingsValues, keyboardShiftMode)); @@ -403,7 +408,9 @@ public final class InputLogic { // A special key, like delete, shift, emoji, or the settings key. switch (event.mKeyCode) { case Constants.CODE_DELETE: - handleBackspace(inputTransaction); + handleBackspace(inputTransaction, currentKeyboardScriptId); + // Backspace is a functional key, but it affects the contents of the editor. + inputTransaction.setDidAffectContents(); break; case Constants.CODE_SHIFT: performRecapitalization(inputTransaction.mSettingsValues); @@ -457,11 +464,15 @@ public final class InputLogic { inputTransaction.mTimestamp, inputTransaction.mSpaceState, inputTransaction.mShiftState); didAutoCorrect = handleNonSpecialCharacter(tmpTransaction, handler); + // Shift + Enter is treated as a functional key but it results in adding a new + // line, so that does affect the contents of the editor. + inputTransaction.setDidAffectContents(); break; default: throw new RuntimeException("Unknown key code : " + event.mKeyCode); } } else { + inputTransaction.setDidAffectContents(); switch (event.mCodePoint) { case Constants.CODE_ENTER: final EditorInfo editorInfo = getCurrentInputEditorInfo(); @@ -857,7 +868,9 @@ public final class InputLogic { * Handle a press on the backspace key. * @param inputTransaction The transaction in progress. */ - private void handleBackspace(final InputTransaction inputTransaction) { + private void handleBackspace(final InputTransaction inputTransaction, + // TODO: remove this argument, put it into settingsValues + final int currentKeyboardScriptId) { mSpaceState = SpaceState.NONE; mDeleteCount++; @@ -991,7 +1004,7 @@ public final class InputLogic { && !mConnection.isCursorFollowedByWordCharacter( inputTransaction.mSettingsValues.mSpacingAndPunctuations)) { restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues, - true /* shouldIncludeResumedWordInSuggestions */); + true /* shouldIncludeResumedWordInSuggestions */, currentKeyboardScriptId); } } } @@ -1244,7 +1257,9 @@ public final class InputLogic { */ // TODO: make this private. public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues, - final boolean shouldIncludeResumedWordInSuggestions) { + final boolean shouldIncludeResumedWordInSuggestions, + // TODO: remove this argument, put it into settingsValues + final int currentKeyboardScriptId) { // HACK: We may want to special-case some apps that exhibit bad behavior in case of // recorrection. This is a temporary, stopgap measure that will be removed later. // TODO: remove this. diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 47921ca0a..f7b6f919d 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -37,7 +37,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { private static final String TAG = MoreSuggestionsView.class.getSimpleName(); public static abstract class MoreSuggestionsListener extends KeyboardActionListener.Adapter { - public abstract void onSuggestionSelected(final int index, final SuggestedWordInfo info); + public abstract void onSuggestionSelected(final SuggestedWordInfo info); } public MoreSuggestionsView(final Context context, final AttributeSet attrs) { @@ -104,7 +104,6 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { + mListener.getClass().getName()); return; } - ((MoreSuggestionsListener)mListener).onSuggestionSelected( - index, suggestedWords.getInfo(index)); + ((MoreSuggestionsListener)mListener).onSuggestionSelected(suggestedWords.getInfo(index)); } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index aebfb7d4c..8654e12a9 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -59,7 +59,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick public interface Listener { public void addWordToUserDictionary(String word); public void showImportantNoticeContents(); - public void pickSuggestionManually(int index, SuggestedWordInfo word); + public void pickSuggestionManually(SuggestedWordInfo word); public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat); } @@ -286,8 +286,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() { @Override - public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) { - mListener.pickSuggestionManually(index, wordInfo); + public void onSuggestionSelected(final SuggestedWordInfo wordInfo) { + mListener.pickSuggestionManually(wordInfo); dismissMoreSuggestionsPanel(); } @@ -465,7 +465,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick return; } final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index); - mListener.pickSuggestionManually(index, wordInfo); + mListener.pickSuggestionManually(wordInfo); } } |