aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java33
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java36
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java2
3 files changed, 45 insertions, 26 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4a18c2b3c..fc5c7f7ec 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -169,7 +169,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private int mDelayUpdateSuggestions;
private int mDelayUpdateShiftState;
- private long mDoubleSpacePeriodTimeout;
private long mDoubleSpacePeriodTimerStart;
public UIHandler(final LatinIME ownerInstance) {
@@ -184,8 +183,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final Resources res = latinIme.getResources();
mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state);
- mDoubleSpacePeriodTimeout =
- res.getInteger(R.integer.config_double_space_period_timeout);
}
@Override
@@ -327,7 +324,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public boolean isAcceptingDoubleSpacePeriod() {
return SystemClock.uptimeMillis() - mDoubleSpacePeriodTimerStart
- < mDoubleSpacePeriodTimeout;
+ < getOwnerInstance().mSettings.getCurrent().mDoubleSpacePeriodTimeout;
}
// Working variables for the following methods.
@@ -1276,15 +1273,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final InputTransaction completeInputTransaction =
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
- switch (completeInputTransaction.getRequiredShiftUpdate()) {
- case InputTransaction.SHIFT_UPDATE_LATER:
- mHandler.postUpdateShiftState();
- break;
- case InputTransaction.SHIFT_UPDATE_NOW:
- mKeyboardSwitcher.updateShiftState();
- break;
- default: // SHIFT_NO_UPDATE
- }
+ updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
mKeyboardSwitcher.onCodeInput(codePoint);
}
@@ -1500,8 +1489,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// interface
@Override
public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) {
- mInputLogic.onPickSuggestionManually(mSettings.getCurrent(), index, suggestionInfo,
- mHandler, mKeyboardSwitcher);
+ final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
+ mSettings.getCurrent(), index, suggestionInfo,
+ mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
+ updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
}
@Override
@@ -1539,6 +1530,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
+ private void updateShiftModeAfterInputTransaction(final int requiredShiftUpdate) {
+ switch (requiredShiftUpdate) {
+ case InputTransaction.SHIFT_UPDATE_LATER:
+ mHandler.postUpdateShiftState();
+ break;
+ case InputTransaction.SHIFT_UPDATE_NOW:
+ mKeyboardSwitcher.updateShiftState();
+ break;
+ default: // SHIFT_NO_UPDATE
+ }
+ }
+
private void hapticAndAudioFeedback(final int code, final int repeatCount) {
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
if (keyboardView != null && keyboardView.isInDraggingFinger()) {
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index fa7c4b4fc..1eff42762 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -196,13 +196,16 @@ public final class InputLogic {
* @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()}
+ * @return the complete transaction object
*/
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
- public void onPickSuggestionManually(final SettingsValues settingsValues,
- final int index, final SuggestedWordInfo suggestionInfo,
- // TODO: remove these two arguments
- final LatinIME.UIHandler handler, final KeyboardSwitcher keyboardSwitcher) {
+ public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues,
+ final int index, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
+ // TODO: remove this argument
+ 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
@@ -212,16 +215,26 @@ public final class InputLogic {
LatinImeLogger.logOnManualSuggestion("", suggestion, index, suggestedWords);
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final int primaryCode = suggestion.charAt(0);
- final Event event = Event.createSoftwareKeypressEvent(primaryCode, Event.NOT_A_KEY_CODE,
- Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE);
- onCodeInput(settingsValues, event, keyboardSwitcher.getKeyboardShiftMode(), handler);
+ // TODO: we should be using createSuggestionPickedEvent here, but for legacy reasons,
+ // onCodeInput is expected a software keypress event for a suggested punctuation
+ // because the current code is descended from a time where this information used not
+ // to be available. Fix this.
+ final Event event = Event.createSoftwareKeypressEvent(primaryCode,
+ Event.NOT_A_KEY_CODE /* keyCode*/,
+ Constants.SUGGESTION_STRIP_COORDINATE /* x */,
+ Constants.SUGGESTION_STRIP_COORDINATE /* y */);
+ final InputTransaction completeTransaction = onCodeInput(settingsValues, event,
+ keyboardShiftState, handler);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_punctuationSuggestion(index, suggestion,
false /* isBatchMode */, suggestedWords.mIsPrediction);
}
- return;
+ return completeTransaction;
}
+ final Event event = Event.createSuggestionPickedEvent(suggestionInfo);
+ final InputTransaction inputTransaction = new InputTransaction(settingsValues,
+ event, SystemClock.uptimeMillis(), mSpaceState, keyboardShiftState);
mConnection.beginBatchEdit();
if (SpaceState.PHANTOM == mSpaceState && suggestion.length() > 0
// In the batch input mode, a manually picked suggested word should just replace
@@ -241,11 +254,11 @@ public final class InputLogic {
if (SuggestedWordInfo.KIND_APP_DEFINED == suggestionInfo.mKind) {
mSuggestedWords = SuggestedWords.EMPTY;
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
- keyboardSwitcher.updateShiftState();
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
resetComposingState(true /* alsoResetLastComposedWord */);
mConnection.commitCompletion(suggestionInfo.mApplicationSpecifiedCompletionInfo);
mConnection.endBatchEdit();
- return;
+ return inputTransaction;
}
// We need to log before we commit, because the word composer will store away the user
@@ -264,7 +277,7 @@ public final class InputLogic {
mLastComposedWord.deactivate();
// Space state must be updated before calling updateShiftState
mSpaceState = SpaceState.PHANTOM;
- keyboardSwitcher.updateShiftState();
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
// We should show the "Touch again to save" hint if the user pressed the first entry
// AND it's in none of our current dictionaries (main, user or otherwise).
@@ -290,6 +303,7 @@ public final class InputLogic {
// If we're not showing the "Touch again to save", then update the suggestion strip.
handler.postUpdateSuggestionStrip();
}
+ return inputTransaction;
}
/**
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index 5a652a557..d47a61ed1 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -50,6 +50,7 @@ public final class SettingsValues {
// From resources:
public final SpacingAndPunctuations mSpacingAndPunctuations;
public final int mDelayUpdateOldSuggestions;
+ public final long mDoubleSpacePeriodTimeout;
// From preferences, in the same order as xml/prefs.xml:
public final boolean mAutoCap;
@@ -132,6 +133,7 @@ public final class SettingsValues {
mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
+ mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
// Compute other readable settings
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);