[IL128] Remove passing some handlers.
Bug: 8636060 Change-Id: I088be9a7555265ca097667523defd73be4cbe37fmain
parent
3c38e1f269
commit
6bd3723e73
|
@ -40,6 +40,7 @@ public class InputTransaction {
|
||||||
|
|
||||||
// Outputs
|
// Outputs
|
||||||
private int mRequiredShiftUpdate = SHIFT_NO_UPDATE;
|
private int mRequiredShiftUpdate = SHIFT_NO_UPDATE;
|
||||||
|
private boolean mRequiresUpdateSuggestions = false;
|
||||||
|
|
||||||
public InputTransaction(final SettingsValues settingsValues, final Event event,
|
public InputTransaction(final SettingsValues settingsValues, final Event event,
|
||||||
final long timestamp, final int spaceState, final int shiftState) {
|
final long timestamp, final int spaceState, final int shiftState) {
|
||||||
|
@ -50,10 +51,34 @@ public class InputTransaction {
|
||||||
mShiftState = shiftState;
|
mShiftState = shiftState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that this transaction requires some type of shift update.
|
||||||
|
* @param updateType What type of shift update this requires.
|
||||||
|
*/
|
||||||
public void requireShiftUpdate(final int updateType) {
|
public void requireShiftUpdate(final int updateType) {
|
||||||
mRequiredShiftUpdate = Math.max(mRequiredShiftUpdate, updateType);
|
mRequiredShiftUpdate = Math.max(mRequiredShiftUpdate, updateType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets what type of shift update this transaction requires.
|
||||||
|
* @return The shift update type.
|
||||||
|
*/
|
||||||
public int getRequiredShiftUpdate() {
|
public int getRequiredShiftUpdate() {
|
||||||
return mRequiredShiftUpdate;
|
return mRequiredShiftUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that this transaction requires updating the suggestions.
|
||||||
|
*/
|
||||||
|
public void setRequiresUpdateSuggestions() {
|
||||||
|
mRequiresUpdateSuggestions = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find out whether this transaction requires updating the suggestions.
|
||||||
|
* @return Whether this transaction requires updating the suggestions.
|
||||||
|
*/
|
||||||
|
public boolean requiresUpdateSuggestions() {
|
||||||
|
return mRequiresUpdateSuggestions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ import android.net.ConnectivityManager;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
@ -1230,7 +1229,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final InputTransaction completeInputTransaction =
|
final InputTransaction completeInputTransaction =
|
||||||
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
||||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||||
updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
|
updateStateAfterInputTransaction(completeInputTransaction);
|
||||||
mKeyboardSwitcher.onCodeInput(codePoint);
|
mKeyboardSwitcher.onCodeInput(codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,7 +1449,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
|
final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
|
||||||
mSettings.getCurrent(), index, suggestionInfo,
|
mSettings.getCurrent(), index, suggestionInfo,
|
||||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||||
updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
|
updateStateAfterInputTransaction(completeInputTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1488,8 +1487,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShiftModeAfterInputTransaction(final int requiredShiftUpdate) {
|
/**
|
||||||
switch (requiredShiftUpdate) {
|
* After an input transaction has been executed, some state must be updated. This includes
|
||||||
|
* the shift state of the keyboard and suggestions. This method looks at the finished
|
||||||
|
* inputTransaction to find out what is necessary and updates the state accordingly.
|
||||||
|
* @param inputTransaction The transaction that has been executed.
|
||||||
|
*/
|
||||||
|
private void updateStateAfterInputTransaction(final InputTransaction inputTransaction) {
|
||||||
|
switch (inputTransaction.getRequiredShiftUpdate()) {
|
||||||
case InputTransaction.SHIFT_UPDATE_LATER:
|
case InputTransaction.SHIFT_UPDATE_LATER:
|
||||||
mHandler.postUpdateShiftState();
|
mHandler.postUpdateShiftState();
|
||||||
break;
|
break;
|
||||||
|
@ -1498,6 +1503,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
break;
|
break;
|
||||||
default: // SHIFT_NO_UPDATE
|
default: // SHIFT_NO_UPDATE
|
||||||
}
|
}
|
||||||
|
if (inputTransaction.requiresUpdateSuggestions()) {
|
||||||
|
mHandler.postUpdateSuggestionStrip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hapticAndAudioFeedback(final int code, final int repeatCount) {
|
private void hapticAndAudioFeedback(final int code, final int repeatCount) {
|
||||||
|
|
|
@ -402,7 +402,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, handler);
|
handleBackspace(inputTransaction);
|
||||||
LatinImeLogger.logOnDelete(event.mX, event.mY);
|
LatinImeLogger.logOnDelete(event.mX, event.mY);
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
|
@ -673,7 +673,7 @@ public final class InputLogic {
|
||||||
commitTyped(inputTransaction.mSettingsValues, LastComposedWord.NOT_A_SEPARATOR);
|
commitTyped(inputTransaction.mSettingsValues, LastComposedWord.NOT_A_SEPARATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleNonSeparator(inputTransaction.mSettingsValues, inputTransaction, handler);
|
handleNonSeparator(inputTransaction.mSettingsValues, inputTransaction);
|
||||||
}
|
}
|
||||||
return didAutoCorrect;
|
return didAutoCorrect;
|
||||||
}
|
}
|
||||||
|
@ -684,9 +684,7 @@ public final class InputLogic {
|
||||||
* @param inputTransaction The transaction in progress.
|
* @param inputTransaction The transaction in progress.
|
||||||
*/
|
*/
|
||||||
private void handleNonSeparator(final SettingsValues settingsValues,
|
private void handleNonSeparator(final SettingsValues settingsValues,
|
||||||
final InputTransaction inputTransaction,
|
final InputTransaction inputTransaction) {
|
||||||
// TODO: Remove this argument
|
|
||||||
final LatinIME.UIHandler handler) {
|
|
||||||
final int codePoint = inputTransaction.mEvent.mCodePoint;
|
final int codePoint = inputTransaction.mEvent.mCodePoint;
|
||||||
// TODO: refactor this method to stop flipping isComposingWord around all the time, and
|
// TODO: refactor this method to stop flipping isComposingWord around all the time, and
|
||||||
// make it shorter (possibly cut into several pieces). Also factor handleNonSpecialCharacter
|
// make it shorter (possibly cut into several pieces). Also factor handleNonSpecialCharacter
|
||||||
|
@ -762,7 +760,7 @@ public final class InputLogic {
|
||||||
// In case the "add to dictionary" hint was still displayed.
|
// In case the "add to dictionary" hint was still displayed.
|
||||||
mSuggestionStripViewAccessor.dismissAddToDictionaryHint();
|
mSuggestionStripViewAccessor.dismissAddToDictionaryHint();
|
||||||
}
|
}
|
||||||
handler.postUpdateSuggestionStrip();
|
inputTransaction.setRequiresUpdateSuggestions();
|
||||||
if (settingsValues.mIsInternal) {
|
if (settingsValues.mIsInternal) {
|
||||||
LatinImeLoggerUtils.onNonSeparator((char)codePoint, inputTransaction.mEvent.mX,
|
LatinImeLoggerUtils.onNonSeparator((char)codePoint, inputTransaction.mEvent.mX,
|
||||||
inputTransaction.mEvent.mY);
|
inputTransaction.mEvent.mY);
|
||||||
|
@ -844,7 +842,7 @@ public final class InputLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
startDoubleSpacePeriodCountdown(inputTransaction);
|
startDoubleSpacePeriodCountdown(inputTransaction);
|
||||||
handler.postUpdateSuggestionStrip();
|
inputTransaction.setRequiresUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
if (swapWeakSpace) {
|
if (swapWeakSpace) {
|
||||||
swapSwapperAndSpace(inputTransaction);
|
swapSwapperAndSpace(inputTransaction);
|
||||||
|
@ -880,9 +878,7 @@ 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
|
|
||||||
final LatinIME.UIHandler handler) {
|
|
||||||
mSpaceState = SpaceState.NONE;
|
mSpaceState = SpaceState.NONE;
|
||||||
mDeleteCount++;
|
mDeleteCount++;
|
||||||
|
|
||||||
|
@ -911,7 +907,7 @@ public final class InputLogic {
|
||||||
mWordComposer.deleteLast(inputTransaction.mEvent);
|
mWordComposer.deleteLast(inputTransaction.mEvent);
|
||||||
}
|
}
|
||||||
mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
||||||
handler.postUpdateSuggestionStrip();
|
inputTransaction.setRequiresUpdateSuggestions();
|
||||||
if (!mWordComposer.isComposingWord()) {
|
if (!mWordComposer.isComposingWord()) {
|
||||||
// If we just removed the last character, auto-caps mode may have changed so we
|
// If we just removed the last character, auto-caps mode may have changed so we
|
||||||
// need to re-evaluate.
|
// need to re-evaluate.
|
||||||
|
@ -922,7 +918,7 @@ public final class InputLogic {
|
||||||
if (inputTransaction.mSettingsValues.mIsInternal) {
|
if (inputTransaction.mSettingsValues.mIsInternal) {
|
||||||
LatinImeLoggerUtils.onAutoCorrectionCancellation();
|
LatinImeLoggerUtils.onAutoCorrectionCancellation();
|
||||||
}
|
}
|
||||||
revertCommit(inputTransaction.mSettingsValues, handler);
|
revertCommit(inputTransaction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) {
|
if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) {
|
||||||
|
@ -1401,11 +1397,9 @@ public final class InputLogic {
|
||||||
*
|
*
|
||||||
* This is triggered upon pressing backspace just after a commit with auto-correction.
|
* This is triggered upon pressing backspace just after a commit with auto-correction.
|
||||||
*
|
*
|
||||||
* @param settingsValues the current settings values.
|
* @param inputTransaction The transaction in progress.
|
||||||
*/
|
*/
|
||||||
private void revertCommit(final SettingsValues settingsValues,
|
private void revertCommit(final InputTransaction inputTransaction) {
|
||||||
// TODO: remove this argument
|
|
||||||
final LatinIME.UIHandler handler) {
|
|
||||||
final String previousWord = mLastComposedWord.mPrevWord;
|
final String previousWord = mLastComposedWord.mPrevWord;
|
||||||
final CharSequence originallyTypedWord = mLastComposedWord.mTypedWord;
|
final CharSequence originallyTypedWord = mLastComposedWord.mTypedWord;
|
||||||
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
||||||
|
@ -1449,7 +1443,8 @@ public final class InputLogic {
|
||||||
// Given this, we add it to the list of suggestions, otherwise we discard it.
|
// Given this, we add it to the list of suggestions, otherwise we discard it.
|
||||||
if (span instanceof SuggestionSpan) {
|
if (span instanceof SuggestionSpan) {
|
||||||
final SuggestionSpan suggestionSpan = (SuggestionSpan)span;
|
final SuggestionSpan suggestionSpan = (SuggestionSpan)span;
|
||||||
if (!suggestionSpan.getLocale().equals(settingsValues.mLocale.toString())) {
|
if (!suggestionSpan.getLocale().equals(
|
||||||
|
inputTransaction.mSettingsValues.mLocale.toString())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (final String suggestion : suggestionSpan.getSuggestions()) {
|
for (final String suggestion : suggestionSpan.getSuggestions()) {
|
||||||
|
@ -1464,11 +1459,11 @@ public final class InputLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add the suggestion list to the list of suggestions.
|
// Add the suggestion list to the list of suggestions.
|
||||||
textToCommit.setSpan(new SuggestionSpan(settingsValues.mLocale,
|
textToCommit.setSpan(new SuggestionSpan(inputTransaction.mSettingsValues.mLocale,
|
||||||
suggestions.toArray(new String[suggestions.size()]), 0 /* flags */),
|
suggestions.toArray(new String[suggestions.size()]), 0 /* flags */),
|
||||||
0 /* start */, lastCharIndex /* end */, 0 /* flags */);
|
0 /* start */, lastCharIndex /* end */, 0 /* flags */);
|
||||||
}
|
}
|
||||||
if (settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces) {
|
if (inputTransaction.mSettingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces) {
|
||||||
// For languages with spaces, we revert to the typed string, but the cursor is still
|
// For languages with spaces, we revert to the typed string, but the cursor is still
|
||||||
// after the separator so we don't resume suggestions. If the user wants to correct
|
// after the separator so we don't resume suggestions. If the user wants to correct
|
||||||
// the word, they have to press backspace again.
|
// the word, they have to press backspace again.
|
||||||
|
@ -1481,7 +1476,7 @@ public final class InputLogic {
|
||||||
mLatinIME.getCoordinatesForCurrentKeyboard(codePoints), previousWord);
|
mLatinIME.getCoordinatesForCurrentKeyboard(codePoints), previousWord);
|
||||||
mConnection.setComposingText(textToCommit, 1);
|
mConnection.setComposingText(textToCommit, 1);
|
||||||
}
|
}
|
||||||
if (settingsValues.mIsInternal) {
|
if (inputTransaction.mSettingsValues.mIsInternal) {
|
||||||
LatinImeLoggerUtils.onSeparator(mLastComposedWord.mSeparatorString,
|
LatinImeLoggerUtils.onSeparator(mLastComposedWord.mSeparatorString,
|
||||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1489,7 @@ public final class InputLogic {
|
||||||
// separator.
|
// separator.
|
||||||
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
||||||
// We have a separator between the word and the cursor: we should show predictions.
|
// We have a separator between the word and the cursor: we should show predictions.
|
||||||
handler.postUpdateSuggestionStrip();
|
inputTransaction.setRequiresUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue