aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-26 18:43:14 +0900
committerJean Chalard <jchalard@google.com>2014-06-27 21:18:42 +0900
commit35c37dbef8a65cc1e199a60090d1b4e60da69fe6 (patch)
tree13f755ccebdc65e025c3192bd66b2b9d5a212146
parentaca2ef85e1af82ccadbd0cbdd691a680a03a824d (diff)
downloadlatinime-35c37dbef8a65cc1e199a60090d1b4e60da69fe6.tar.gz
latinime-35c37dbef8a65cc1e199a60090d1b4e60da69fe6.tar.xz
latinime-35c37dbef8a65cc1e199a60090d1b4e60da69fe6.zip
[SD3] Forward the script ID to where it will be used
Bug: 15840116 Change-Id: If2073e76fed74ae6e1cdd7670013e0e985b0e630
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java4
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java19
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java26
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java5
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java8
6 files changed, 42 insertions, 24 deletions
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..c9a4bf5a1 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -227,7 +227,8 @@ 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();
@@ -1239,7 +1240,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());
@@ -1423,10 +1425,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);
}
@@ -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/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 15ddcf9ae..158663d96 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -213,7 +213,6 @@ public final class InputLogic {
/**
* 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 +221,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,7 +231,8 @@ 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);
@@ -378,8 +378,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 +403,7 @@ 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);
break;
case Constants.CODE_SHIFT:
performRecapitalization(inputTransaction.mSettingsValues);
@@ -857,7 +857,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 +993,7 @@ public final class InputLogic {
&& !mConnection.isCursorFollowedByWordCharacter(
inputTransaction.mSettingsValues.mSpacingAndPunctuations)) {
restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues,
- true /* shouldIncludeResumedWordInSuggestions */);
+ true /* shouldIncludeResumedWordInSuggestions */, currentKeyboardScriptId);
}
}
}
@@ -1244,7 +1246,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);
}
}