Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 822b8f0c authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Double tap to select enabled on suggestions

Using a runnable to schedule the action, interrupted by any other
touch event, enabling a catch of a double tap to trigger text selection
instead.

Change-Id: I21f8b9fdfad0036d6970f5dbfe6d72dd3eff35a1
parent 2f9510ca
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -342,6 +342,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private int mTextEditSuggestionItemLayout;
    private SuggestionsPopupWindow mSuggestionsPopupWindow;
    private SuggestionRangeSpan mSuggestionRangeSpan;
    private Runnable mShowSuggestionRunnable;

    private int mCursorDrawableRes;
    private final Drawable[] mCursorDrawable = new Drawable[2];
@@ -4513,6 +4514,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            mSelectionModifierCursorController.onDetached();
        }

        if (mShowSuggestionRunnable != null) {
            removeCallbacks(mShowSuggestionRunnable);
        }

        hideControllers();

        resetResolvedDrawables();
@@ -8330,6 +8335,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            getSelectionController().onTouchEvent(event);
        }

        if (mShowSuggestionRunnable != null) {
            removeCallbacks(mShowSuggestionRunnable);
        }

        if (action == MotionEvent.ACTION_DOWN) {
            mLastDownPositionX = event.getX();
            mLastDownPositionY = event.getY();
@@ -8370,7 +8379,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                ClickableSpan[] links = ((Spannable) mText).getSpans(getSelectionStart(),
                        getSelectionEnd(), ClickableSpan.class);

                if (links.length != 0) {
                if (links.length > 0) {
                    links[0].onClick(this);
                    handled = true;
                }
@@ -8397,7 +8406,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    }
                    if (!extractedTextModeWillBeStarted()) {
                        if (isCursorInsideEasyCorrectionSpan()) {
                            if (mShowSuggestionRunnable == null) {
                                mShowSuggestionRunnable = new Runnable() {
                                    public void run() {
                                        showSuggestions();
                                    }
                                };
                            }
                            postDelayed(mShowSuggestionRunnable,
                                    ViewConfiguration.getDoubleTapTimeout());
                        } else if (hasInsertionController()) {
                            getInsertionController().show();
                        }