diff options
| author | ArenaL5 <arenal5@gmx.com> | 2019-12-01 23:18:13 +0000 |
|---|---|---|
| committer | ArenaL5 <arenal5@gmx.com> | 2019-12-01 23:18:13 +0000 |
| commit | 60e6e42f73d16be59eafdb9766c5dc5bec6e773a (patch) | |
| tree | 543960b92a0ed47f68a6cbe7721c5a45e26fff10 | |
| parent | 18b43791706c3207301fbe9608c4178171c1526d (diff) | |
| download | AnySoftKeyboard-60e6e42f73d16be59eafdb9766c5dc5bec6e773a.tar.gz AnySoftKeyboard-60e6e42f73d16be59eafdb9766c5dc5bec6e773a.tar.bz2 | |
Fix #620
I misdiagnosed the problem; the code responsible for syncing up the internal knowledge of the cursor with its actual location wasn't fired for "expected events" on onSelectionUpdate. These events are no longer discarded.
| -rw-r--r-- | app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardSuggestions.java | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardSuggestions.java b/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardSuggestions.java index a1e164307..dc77ee26b 100644 --- a/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardSuggestions.java +++ b/app/src/main/java/com/anysoftkeyboard/ime/AnySoftKeyboardSuggestions.java @@ -49,9 +49,7 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard private static final long CLOSE_DICTIONARIES_DELAY = 10 * ONE_FRAME_DELAY; - private static final long MAX_TIME_TO_EXPECT_SELECTION_UPDATE = 1500; - // a year ago. - private static final long NEVER_TIME_STAMP = -1L * 365L * 24L * 60L * 60L * 1000L; + private static final long NEVER_TIME_STAMP = -1L * 365L * 24L * 60L * 60L * 1000L; // a year ago. private static final int UNDO_COMMIT_NONE = -1; private static final int UNDO_COMMIT_WAITING_TO_RECORD_POSITION = -2; @@ -131,7 +129,6 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard */ private int mUndoCommitCursorPosition = UNDO_COMMIT_NONE; - private long mExpectingSelectionUpdateBy = Long.MIN_VALUE; /* * is prediction needed for the current input connection */ @@ -458,14 +455,6 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard mUndoCommitCursorPosition = newSelStart; } - final boolean isExpectedEvent = SystemClock.uptimeMillis() < mExpectingSelectionUpdateBy; - mExpectingSelectionUpdateBy = NEVER_TIME_STAMP; - - if (isExpectedEvent) { - Logger.v(TAG, "onUpdateSelection: Expected event. Discarding."); - return; - } - if (TextEntryState.willUndoCommitOnBackspace() && mUndoCommitCursorPosition == oldSelStart && mUndoCommitCursorPosition != newSelStart) { @@ -585,8 +574,6 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard TextEntryState.isPredicting()); } - mExpectingSelectionUpdateBy = - SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE; if (TextEntryState.isReadyToPredict() && isAlphabet(primaryCode) && !isCursorTouchingWord()) { @@ -604,16 +591,16 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard mLastCharacterWasShifted = (getInputView() != null) && getInputView().isShifted(); + final InputConnection ic = getCurrentInputConnection(); if (TextEntryState.isPredicting()) { - final InputConnection ic = getCurrentInputConnection(); mWord.add(primaryCode, nearByKeyCodes); ChewbaccaOnTheDrums.onKeyTyped(mWord, getApplicationContext()); if (ic != null) { final int cursorPosition; if (mWord.cursorPosition() != mWord.charCount()) { - // Cursor is not at the end of the word. I'll need to reposition - /* The code for tracking the current position is split among several files and difficult to debug. + /* Cursor is not at the end of the word. I'll need to reposition. + The code for tracking the current position is split among several files and difficult to debug. This has been proven to work in every case: */ if (multiTapIndex > 0) { final int previousKeyCode = key.getMultiTapCode(multiTapIndex - 1); @@ -644,9 +631,15 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard mCandidateView.replaceTypedWord(mWord.getTypedWord()); } } else { + if (ic != null) { + ic.beginBatchEdit(); + } for (char c : Character.toChars(primaryCode)) { sendKeyChar(c); } + if (ic != null) { + ic.endBatchEdit(); + } } mJustAutoAddedWord = false; } @@ -660,8 +653,6 @@ public abstract class AnySoftKeyboardSuggestions extends AnySoftKeyboardKeyboard primaryCode = (int) ')'; } } - mExpectingSelectionUpdateBy = - SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE; // will not show next-word suggestion in case of a new line or if the separator is a // sentence separator. boolean newLine = primaryCode == KeyCodes.ENTER; |
