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

Commit 39f0efba authored by Maryam Garrett's avatar Maryam Garrett
Browse files

Fixes context-menu trigger behavior after scroll in TextView

This change fixes the context menu trigger behavior while
the user is selecting via touch. How if a user is selecting
text via dragging their finger, to trigger the context menu
they will have to lift their finger up, then issue a
longpress. This is consistent with the behavior of selecting
via the trackball.
parent ba8e4d24
Loading
Loading
Loading
Loading
+43 −36
Original line number Diff line number Diff line
@@ -267,7 +267,15 @@ implements MovementMethod
                              (MetaKeyKeyListener.getMetaState(buffer,
                                MetaKeyKeyListener.META_SELECTING) != 0);

              if (cap) {
                if (cap & handled) {
                    // Before selecting, make sure we've moved out of the "slop".
                    // handled will be true, if we're in select mode AND we're
                    // OUT of the slop

                    // Turn long press off while we're selecting. User needs to
                    // re-tap on the selection to enable longpress
                    widget.cancelLongPress();

                    // Update selection as we're moving the selection area.

                    // Get the current touch position
@@ -296,7 +304,6 @@ implements MovementMethod
                        spanstart = findWordEnd(buffer, lastDownOffset);
                        spanend = findWordStart(buffer, offset);
                    }

                    Selection.setSelection(buffer, spanstart, spanend);
                    return true;
                }
+6 −18
Original line number Diff line number Diff line
@@ -2726,9 +2726,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            setPressed(false);

            if (!mHasPerformedLongPress) {
                if (mPendingCheckForLongPress != null) {
                    removeCallbacks(mPendingCheckForLongPress);
                }
                cancelLongPress();
            }
        }
    }
@@ -3750,9 +3748,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
                imm.focusOut(this);
            }
            if (mPendingCheckForLongPress != null) {
                removeCallbacks(mPendingCheckForLongPress);
            }
            cancelLongPress();
            onFocusLost();
        } else if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
            imm.focusIn(this);
@@ -3998,9 +3994,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility

                    if (!mHasPerformedLongPress) {
                        // This is a tap, so remove the longpress check
                        if (mPendingCheckForLongPress != null) {
                            removeCallbacks(mPendingCheckForLongPress);
                        }
                        cancelLongPress();

                        result = performClick();
                    }
@@ -4190,9 +4184,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility

                        if (!mHasPerformedLongPress) {
                            // This is a tap, so remove the longpress check
                            if (mPendingCheckForLongPress != null) {
                                removeCallbacks(mPendingCheckForLongPress);
                            }
                            cancelLongPress();

                            // Only perform take click actions if we were in the pressed state
                            if (!focusTaken) {
@@ -4235,9 +4227,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                        // Outside button
                        if ((mPrivateFlags & PRESSED) != 0) {
                            // Remove any future long press checks
                            if (mPendingCheckForLongPress != null) {
                                removeCallbacks(mPendingCheckForLongPress);
                            }
                            cancelLongPress();

                            // Need to switch from pressed to not pressed
                            mPrivateFlags &= ~PRESSED;
@@ -5769,9 +5759,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * @see #onAttachedToWindow()
     */
    protected void onDetachedFromWindow() {
        if (mPendingCheckForLongPress != null) {
            removeCallbacks(mPendingCheckForLongPress);
        }
        cancelLongPress();
        destroyDrawingCache();
    }