Loading core/java/android/widget/TextView.java +38 −16 Original line number Diff line number Diff line Loading @@ -6903,7 +6903,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public boolean onTouchEvent(MotionEvent event) { final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { if (mInsertionPointCursorController != null) { mInsertionPointCursorController.onTouchEvent(event); } Loading @@ -6911,6 +6910,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mSelectionModifierCursorController.onTouchEvent(event); } if (action == MotionEvent.ACTION_DOWN) { // Reset this state; it will be re-set if super.onTouchEvent // causes focus to move to the view. mTouchFocusSelected = false; Loading @@ -6931,13 +6931,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if ((mMovement != null || onCheckIsTextEditor()) && isEnabled() && mText instanceof Spannable && mLayout != null) { if (mInsertionPointCursorController != null) { mInsertionPointCursorController.onTouchEvent(event); } if (mSelectionModifierCursorController != null) { mSelectionModifierCursorController.onTouchEvent(event); } boolean handled = false; // Save previous selection, in case this event is used to show the IME. Loading Loading @@ -7981,7 +7974,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } mDrawable = mSelectHandleLeft; handleWidth = mDrawable.getIntrinsicWidth(); mHotspotX = handleWidth / 4 * 3; mHotspotX = (handleWidth * 3) / 4; break; } Loading Loading @@ -8264,6 +8257,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Whether selection anchors are active private boolean mIsShowing; // Double tap detection private long mPreviousTapUpTime = 0; private int mPreviousTapPositionX; private int mPreviousTapPositionY; private static final int DELAY_BEFORE_FADE_OUT = 4100; private final Runnable mHider = new Runnable() { Loading Loading @@ -8369,6 +8367,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Remember finger down position, to be able to start selection from there mMinTouchOffset = mMaxTouchOffset = getOffset(x, y); // Double tap detection long duration = SystemClock.uptimeMillis() - mPreviousTapUpTime; if (duration <= ViewConfiguration.getDoubleTapTimeout()) { final int deltaX = x - mPreviousTapPositionX; final int deltaY = y - mPreviousTapPositionY; final int distanceSquared = deltaX * deltaX + deltaY * deltaY; final int doubleTapSlop = ViewConfiguration.get(getContext()).getScaledDoubleTapSlop(); final int slopSquared = doubleTapSlop * doubleTapSlop; if (distanceSquared < slopSquared) { startSelectionActionMode(); // Hacky: onTapUpEvent will open a context menu with cut/copy // Prevent this by hiding handles which will be revived instead. hide(); } } mPreviousTapPositionX = x; mPreviousTapPositionY = y; break; case MotionEvent.ACTION_POINTER_DOWN: Loading @@ -8380,6 +8398,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener updateMinAndMaxOffsets(event); } break; case MotionEvent.ACTION_UP: mPreviousTapUpTime = SystemClock.uptimeMillis(); break; } } return false; Loading Loading
core/java/android/widget/TextView.java +38 −16 Original line number Diff line number Diff line Loading @@ -6903,7 +6903,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public boolean onTouchEvent(MotionEvent event) { final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { if (mInsertionPointCursorController != null) { mInsertionPointCursorController.onTouchEvent(event); } Loading @@ -6911,6 +6910,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mSelectionModifierCursorController.onTouchEvent(event); } if (action == MotionEvent.ACTION_DOWN) { // Reset this state; it will be re-set if super.onTouchEvent // causes focus to move to the view. mTouchFocusSelected = false; Loading @@ -6931,13 +6931,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if ((mMovement != null || onCheckIsTextEditor()) && isEnabled() && mText instanceof Spannable && mLayout != null) { if (mInsertionPointCursorController != null) { mInsertionPointCursorController.onTouchEvent(event); } if (mSelectionModifierCursorController != null) { mSelectionModifierCursorController.onTouchEvent(event); } boolean handled = false; // Save previous selection, in case this event is used to show the IME. Loading Loading @@ -7981,7 +7974,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } mDrawable = mSelectHandleLeft; handleWidth = mDrawable.getIntrinsicWidth(); mHotspotX = handleWidth / 4 * 3; mHotspotX = (handleWidth * 3) / 4; break; } Loading Loading @@ -8264,6 +8257,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Whether selection anchors are active private boolean mIsShowing; // Double tap detection private long mPreviousTapUpTime = 0; private int mPreviousTapPositionX; private int mPreviousTapPositionY; private static final int DELAY_BEFORE_FADE_OUT = 4100; private final Runnable mHider = new Runnable() { Loading Loading @@ -8369,6 +8367,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Remember finger down position, to be able to start selection from there mMinTouchOffset = mMaxTouchOffset = getOffset(x, y); // Double tap detection long duration = SystemClock.uptimeMillis() - mPreviousTapUpTime; if (duration <= ViewConfiguration.getDoubleTapTimeout()) { final int deltaX = x - mPreviousTapPositionX; final int deltaY = y - mPreviousTapPositionY; final int distanceSquared = deltaX * deltaX + deltaY * deltaY; final int doubleTapSlop = ViewConfiguration.get(getContext()).getScaledDoubleTapSlop(); final int slopSquared = doubleTapSlop * doubleTapSlop; if (distanceSquared < slopSquared) { startSelectionActionMode(); // Hacky: onTapUpEvent will open a context menu with cut/copy // Prevent this by hiding handles which will be revived instead. hide(); } } mPreviousTapPositionX = x; mPreviousTapPositionY = y; break; case MotionEvent.ACTION_POINTER_DOWN: Loading @@ -8380,6 +8398,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener updateMinAndMaxOffsets(event); } break; case MotionEvent.ACTION_UP: mPreviousTapUpTime = SystemClock.uptimeMillis(); break; } } return false; Loading