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

Commit 7ae34197 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Allow touches to change the selection in WebTextView.

Fix http://b/issue?id=2019857

If the user has not moved beyond the scaled touch slop, do not
turn it into a scroll, so the user can change the selection.

Change-Id: I1d88691a35ea2da4b03ad713b56331b5c268b757
parent 4f8bb4c8
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
@@ -430,18 +431,26 @@ import java.util.ArrayList;
            mGotTouchDown = true;
            break;
        case MotionEvent.ACTION_MOVE:
            int slop = ViewConfiguration.get(mContext).getScaledTouchSlop();
            Spannable buffer = getText();
            int initialScrollX = Touch.getInitialScrollX(this, buffer);
            int initialScrollY = Touch.getInitialScrollY(this, buffer);
            super.onTouchEvent(event);
            if (mScrollX != initialScrollX
                    || mScrollY != initialScrollY) {
            if (Math.abs(mScrollX - initialScrollX) > slop
                    || Math.abs(mScrollY - initialScrollY) > slop) {
                if (mWebView != null) {
                    mWebView.scrollFocusedTextInput(mScrollX, mScrollY);
                }
                mScrolled = true;
                return true;
            }
            if (Math.abs((int) event.getX() - mDragStartX) < slop
                    && Math.abs((int) event.getY() - mDragStartY) < slop) {
                // If the user has not scrolled further than slop, we should not
                // send the drag.  Instead, do nothing, and when the user lifts
                // their finger, we will change the selection.
                return true;
            }
            if (mWebView != null) {
                // Only want to set the initial state once.
                if (!mDragSent) {