Loading core/java/android/widget/TextView.java +16 −14 Original line number Diff line number Diff line Loading @@ -301,6 +301,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Set when this TextView gained focus with some text selected. Will start selection mode. private boolean mCreatedWithASelection = false; private boolean mNoContextMenuOnUp = false; /* * Kick-start the font cache for the zygote process (to pay the cost of * initializing freetype for our default font only once). Loading Loading @@ -6777,8 +6779,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Restore previous selection Selection.setSelection((Spannable)mText, prevStart, prevEnd); // Tapping inside the selection displays the cut/copy/paste context menu showContextMenu(); // Tapping inside the selection displays the cut/copy/paste context menu, unless // this is a double tap that should simply trigger text selection mode. if (!mNoContextMenuOnUp) showContextMenu(); } else { // Tapping outside stops selection mode, if any stopTextSelectionMode(); Loading Loading @@ -6836,7 +6839,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mScrolled = false; } final boolean superResult = super.onTouchEvent(event); boolean result = super.onTouchEvent(event); /* * Don't handle the release after a long press, because it will Loading @@ -6845,10 +6848,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ if (mEatTouchRelease && action == MotionEvent.ACTION_UP) { mEatTouchRelease = false; return superResult; } if ((mMovement != null || onCheckIsTextEditor()) && mText instanceof Spannable && mLayout != null) { } else if ((mMovement != null || onCheckIsTextEditor()) && mText instanceof Spannable && mLayout != null) { boolean handled = false; // Save previous selection, in case this event is used to show the IME. Loading Loading @@ -6889,12 +6890,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (handled) { return true; if (handled) result = true; } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { mNoContextMenuOnUp = false; } return superResult; return result; } private void prepareCursorControllers() { Loading Loading @@ -8178,9 +8181,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int slopSquared = doubleTapSlop * doubleTapSlop; if (distanceSquared < slopSquared) { startTextSelectionMode(); // Hacky: onTapUpEvent will open a context menu with cut/copy // Prevent this by hiding handles which will be revived instead. hide(); // prevents onTapUpEvent from opening a context menu with cut/copy mNoContextMenuOnUp = true; } } mPreviousTapPositionX = x; Loading Loading
core/java/android/widget/TextView.java +16 −14 Original line number Diff line number Diff line Loading @@ -301,6 +301,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Set when this TextView gained focus with some text selected. Will start selection mode. private boolean mCreatedWithASelection = false; private boolean mNoContextMenuOnUp = false; /* * Kick-start the font cache for the zygote process (to pay the cost of * initializing freetype for our default font only once). Loading Loading @@ -6777,8 +6779,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Restore previous selection Selection.setSelection((Spannable)mText, prevStart, prevEnd); // Tapping inside the selection displays the cut/copy/paste context menu showContextMenu(); // Tapping inside the selection displays the cut/copy/paste context menu, unless // this is a double tap that should simply trigger text selection mode. if (!mNoContextMenuOnUp) showContextMenu(); } else { // Tapping outside stops selection mode, if any stopTextSelectionMode(); Loading Loading @@ -6836,7 +6839,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mScrolled = false; } final boolean superResult = super.onTouchEvent(event); boolean result = super.onTouchEvent(event); /* * Don't handle the release after a long press, because it will Loading @@ -6845,10 +6848,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ if (mEatTouchRelease && action == MotionEvent.ACTION_UP) { mEatTouchRelease = false; return superResult; } if ((mMovement != null || onCheckIsTextEditor()) && mText instanceof Spannable && mLayout != null) { } else if ((mMovement != null || onCheckIsTextEditor()) && mText instanceof Spannable && mLayout != null) { boolean handled = false; // Save previous selection, in case this event is used to show the IME. Loading Loading @@ -6889,12 +6890,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } if (handled) { return true; if (handled) result = true; } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { mNoContextMenuOnUp = false; } return superResult; return result; } private void prepareCursorControllers() { Loading Loading @@ -8178,9 +8181,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int slopSquared = doubleTapSlop * doubleTapSlop; if (distanceSquared < slopSquared) { startTextSelectionMode(); // Hacky: onTapUpEvent will open a context menu with cut/copy // Prevent this by hiding handles which will be revived instead. hide(); // prevents onTapUpEvent from opening a context menu with cut/copy mNoContextMenuOnUp = true; } } mPreviousTapPositionX = x; Loading