am 4db7da92: Merge "[SD3] Forward the script ID to where it will be used"

* commit '4db7da92f20924a7494dc0b1710413cf9f93a649':
  [SD3] Forward the script ID to where it will be used
main
Jean Chalard 2014-06-30 04:49:01 +00:00 committed by Android Git Automerger
commit cc8728408a
6 changed files with 42 additions and 24 deletions

View File

@ -211,6 +211,10 @@ public final class KeyboardLayoutSet {
return keyboard; return keyboard;
} }
public int getScriptId() {
return mParams.mScriptId;
}
public static final class Builder { public static final class Builder {
private final Context mContext; private final Context mContext;
private final String mPackageName; private final String mPackageName;

View File

@ -370,4 +370,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return WordComposer.CAPS_MODE_OFF; return WordComposer.CAPS_MODE_OFF;
} }
} }
public int getCurrentKeyboardScriptId() {
return mKeyboardLayoutSet.getScriptId();
}
} }

View File

@ -227,7 +227,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
case MSG_RESUME_SUGGESTIONS: case MSG_RESUME_SUGGESTIONS:
latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor( latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor(
latinIme.mSettings.getCurrent(), latinIme.mSettings.getCurrent(),
msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */); msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */,
latinIme.mKeyboardSwitcher.getCurrentKeyboardScriptId());
break; break;
case MSG_REOPEN_DICTIONARIES: case MSG_REOPEN_DICTIONARIES:
latinIme.resetSuggest(); latinIme.resetSuggest();
@ -1239,7 +1240,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat); final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat);
final InputTransaction completeInputTransaction = final InputTransaction completeInputTransaction =
mInputLogic.onCodeInput(mSettings.getCurrent(), event, mInputLogic.onCodeInput(mSettings.getCurrent(), event,
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); mKeyboardSwitcher.getKeyboardShiftMode(),
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
updateStateAfterInputTransaction(completeInputTransaction); updateStateAfterInputTransaction(completeInputTransaction);
mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(), mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(),
getCurrentRecapitalizeState()); getCurrentRecapitalizeState());
@ -1423,10 +1425,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface // interface
@Override @Override
public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) { public void pickSuggestionManually(final SuggestedWordInfo suggestionInfo) {
final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually( final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
mSettings.getCurrent(), index, suggestionInfo, mSettings.getCurrent(), suggestionInfo,
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); mKeyboardSwitcher.getKeyboardShiftMode(),
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
mHandler);
updateStateAfterInputTransaction(completeInputTransaction); updateStateAfterInputTransaction(completeInputTransaction);
} }
@ -1553,7 +1557,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// If it's handled, we return true because we did handle it. // If it's handled, we return true because we did handle it.
if (event.isHandled()) { if (event.isHandled()) {
mInputLogic.onCodeInput(mSettings.getCurrent(), event, 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 true;
} }
return super.onKeyDown(keyCode, keyEvent); return super.onKeyDown(keyCode, keyEvent);

View File

@ -213,7 +213,6 @@ public final class InputLogic {
/** /**
* A suggestion was picked from the suggestion strip. * A suggestion was picked from the suggestion strip.
* @param settingsValues the current values of the settings. * @param settingsValues the current values of the settings.
* @param index the index of the suggestion.
* @param suggestionInfo the suggestion info. * @param suggestionInfo the suggestion info.
* @param keyboardShiftState the shift state of the keyboard, as returned by * @param keyboardShiftState the shift state of the keyboard, as returned by
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()} * {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
@ -222,9 +221,9 @@ public final class InputLogic {
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface // interface
public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues, public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues,
final int index, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
// TODO: remove this argument // TODO: remove these arguments
final LatinIME.UIHandler handler) { final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final SuggestedWords suggestedWords = mSuggestedWords; final SuggestedWords suggestedWords = mSuggestedWords;
final String suggestion = suggestionInfo.mWord; final String suggestion = suggestionInfo.mWord;
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput // If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
@ -232,7 +231,8 @@ public final class InputLogic {
// Word separators are suggested before the user inputs something. // Word separators are suggested before the user inputs something.
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently. // Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo); 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 Event event = Event.createSuggestionPickedEvent(suggestionInfo);
@ -378,8 +378,8 @@ public final class InputLogic {
*/ */
public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event, public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event,
final int keyboardShiftMode, final int keyboardShiftMode,
// TODO: remove this argument // TODO: remove these arguments
final LatinIME.UIHandler handler) { final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, final InputTransaction inputTransaction = new InputTransaction(settingsValues, event,
SystemClock.uptimeMillis(), mSpaceState, SystemClock.uptimeMillis(), mSpaceState,
getActualCapsMode(settingsValues, keyboardShiftMode)); getActualCapsMode(settingsValues, keyboardShiftMode));
@ -403,7 +403,7 @@ public final class InputLogic {
// A special key, like delete, shift, emoji, or the settings key. // A special key, like delete, shift, emoji, or the settings key.
switch (event.mKeyCode) { switch (event.mKeyCode) {
case Constants.CODE_DELETE: case Constants.CODE_DELETE:
handleBackspace(inputTransaction); handleBackspace(inputTransaction, currentKeyboardScriptId);
break; break;
case Constants.CODE_SHIFT: case Constants.CODE_SHIFT:
performRecapitalization(inputTransaction.mSettingsValues); performRecapitalization(inputTransaction.mSettingsValues);
@ -857,7 +857,9 @@ public final class InputLogic {
* Handle a press on the backspace key. * Handle a press on the backspace key.
* @param inputTransaction The transaction in progress. * @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; mSpaceState = SpaceState.NONE;
mDeleteCount++; mDeleteCount++;
@ -991,7 +993,7 @@ public final class InputLogic {
&& !mConnection.isCursorFollowedByWordCharacter( && !mConnection.isCursorFollowedByWordCharacter(
inputTransaction.mSettingsValues.mSpacingAndPunctuations)) { inputTransaction.mSettingsValues.mSpacingAndPunctuations)) {
restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues, restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues,
true /* shouldIncludeResumedWordInSuggestions */); true /* shouldIncludeResumedWordInSuggestions */, currentKeyboardScriptId);
} }
} }
} }
@ -1244,7 +1246,9 @@ public final class InputLogic {
*/ */
// TODO: make this private. // TODO: make this private.
public void restartSuggestionsOnWordTouchedByCursor(final SettingsValues settingsValues, 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 // 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. // recorrection. This is a temporary, stopgap measure that will be removed later.
// TODO: remove this. // TODO: remove this.

View File

@ -37,7 +37,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
private static final String TAG = MoreSuggestionsView.class.getSimpleName(); private static final String TAG = MoreSuggestionsView.class.getSimpleName();
public static abstract class MoreSuggestionsListener extends KeyboardActionListener.Adapter { 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) { public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
@ -104,7 +104,6 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
+ mListener.getClass().getName()); + mListener.getClass().getName());
return; return;
} }
((MoreSuggestionsListener)mListener).onSuggestionSelected( ((MoreSuggestionsListener)mListener).onSuggestionSelected(suggestedWords.getInfo(index));
index, suggestedWords.getInfo(index));
} }
} }

View File

@ -59,7 +59,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public interface Listener { public interface Listener {
public void addWordToUserDictionary(String word); public void addWordToUserDictionary(String word);
public void showImportantNoticeContents(); 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); 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() { private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() {
@Override @Override
public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) { public void onSuggestionSelected(final SuggestedWordInfo wordInfo) {
mListener.pickSuggestionManually(index, wordInfo); mListener.pickSuggestionManually(wordInfo);
dismissMoreSuggestionsPanel(); dismissMoreSuggestionsPanel();
} }
@ -465,7 +465,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
return; return;
} }
final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index); final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
mListener.pickSuggestionManually(index, wordInfo); mListener.pickSuggestionManually(wordInfo);
} }
} }