Stop showing both the floating toolbar and suggestions

The selection mode without selection (PASTE|SELECT_ALL)
pops up along the suggestion popup if we tap on a word
within 15sec of the most recent cut/copy/textChanged
operation. Fix this by making suggestion popup take
precedence.

Also moved the invalidation of the text changed time
into the handleTextChanged() which fixes the selection
mode starting once after the text has changed.

NOTE: Subsequent clicks on non-suggestion spans will
still trigger the selection mode without selection if
within the defined timeframe.

Bug: 20443325
Change-Id: If2726e2c965e77e82ef7b847cf352d4426205bdc
This commit is contained in:
Andrei Stingaceanu
2015-05-28 11:26:28 +01:00
parent 7ff76d637f
commit 373816ef1f
2 changed files with 11 additions and 4 deletions

View File

@@ -1890,6 +1890,11 @@ public class Editor {
if (!extractedTextModeWillBeStarted()) {
if (isCursorInsideEasyCorrectionSpan()) {
// Cancel the single tap delayed runnable.
if (mSelectionModeWithoutSelectionRunnable != null) {
mTextView.removeCallbacks(mSelectionModeWithoutSelectionRunnable);
}
mShowSuggestionRunnable = new Runnable() {
public void run() {
showSuggestions();
@@ -3819,13 +3824,15 @@ public class Editor {
SystemClock.uptimeMillis() - TextView.sLastCutCopyOrTextChangedTime;
// Cancel the single tap delayed runnable.
if (mDoubleTap && mSelectionModeWithoutSelectionRunnable != null) {
if (mSelectionModeWithoutSelectionRunnable != null
&& (mDoubleTap || isCursorInsideEasyCorrectionSpan())) {
mTextView.removeCallbacks(mSelectionModeWithoutSelectionRunnable);
}
// Prepare and schedule the single tap runnable to run exactly after the double tap
// timeout has passed.
if (!mDoubleTap && (durationSinceCutOrCopy < RECENT_CUT_COPY_DURATION)) {
if (!mDoubleTap && !isCursorInsideEasyCorrectionSpan()
&& (durationSinceCutOrCopy < RECENT_CUT_COPY_DURATION)) {
if (mSelectionModeWithoutSelectionRunnable == null) {
mSelectionModeWithoutSelectionRunnable = new Runnable() {
public void run() {

View File

@@ -8015,8 +8015,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* through a thunk.
*/
void sendAfterTextChanged(Editable text) {
sLastCutCopyOrTextChangedTime = 0;
if (mListeners != null) {
final ArrayList<TextWatcher> list = mListeners;
final int count = list.size();
@@ -8049,6 +8047,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* through a thunk.
*/
void handleTextChanged(CharSequence buffer, int start, int before, int after) {
sLastCutCopyOrTextChangedTime = 0;
final Editor.InputMethodState ims = mEditor == null ? null : mEditor.mInputMethodState;
if (ims == null || ims.mBatchEditNesting == 0) {
updateAfterEdit();