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

Commit 6820434e authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Editor: Avoid the paste popup from coming up when a word is selected."

parents 9504a9d9 6351e660
Loading
Loading
Loading
Loading
+3 −50
Original line number Diff line number Diff line
@@ -1666,6 +1666,7 @@ public class Editor {
    private boolean startSelectionActionModeWithoutSelection() {
        if (mSelectionActionMode != null) {
            // Selection action mode is already started
            // TODO: revisit invocations to minimize this case.
            return false;
        }
        ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
@@ -3339,14 +3340,10 @@ public class Editor {
        private float mIdealVerticalOffset;
        // Parent's (TextView) previous position in window
        private int mLastParentX, mLastParentY;
        // Transient action popup window for Paste and Replace actions
        protected ActionPopupWindow mActionPopupWindow;
        // Previous text character offset
        private int mPreviousOffset = -1;
        // Previous text character offset
        private boolean mPositionHasChanged = true;
        // Used to delay the appearance of the action popup window
        private Runnable mActionPopupShower;
        // Minimum touch target size for handles
        private int mMinSize;
        // Indicates the line of text that the handle is on.
@@ -3448,8 +3445,6 @@ public class Editor {
            // Make sure the offset is always considered new, even when focusing at same position
            mPreviousOffset = -1;
            positionAtCursorOffset(getCurrentCursorOffset(), false);

            hideActionPopupWindow();
        }

        protected void dismiss() {
@@ -3464,31 +3459,6 @@ public class Editor {
            getPositionListener().removeSubscriber(this);
        }

        void showActionPopupWindow(int delay) {
            if (mActionPopupWindow == null) {
                mActionPopupWindow = new ActionPopupWindow();
            }
            if (mActionPopupShower == null) {
                mActionPopupShower = new Runnable() {
                    public void run() {
                        mActionPopupWindow.show();
                    }
                };
            } else {
                mTextView.removeCallbacks(mActionPopupShower);
            }
            mTextView.postDelayed(mActionPopupShower, delay);
        }

        protected void hideActionPopupWindow() {
            if (mActionPopupShower != null) {
                mTextView.removeCallbacks(mActionPopupShower);
            }
            if (mActionPopupWindow != null) {
                mActionPopupWindow.hide();
            }
        }

        public boolean isShowing() {
            return mContainer.isShowing();
        }
@@ -3689,13 +3659,9 @@ public class Editor {
            return mIsDragging;
        }

        void onHandleMoved() {
            hideActionPopupWindow();
        }
        void onHandleMoved() {}

        public void onDetached() {
            hideActionPopupWindow();
        }
        public void onDetached() {}
    }

    private class InsertionHandleView extends HandleView {
@@ -3923,10 +3889,6 @@ public class Editor {
            }
        }

        public ActionPopupWindow getActionPopupWindow() {
            return mActionPopupWindow;
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            boolean superResult = super.onTouchEvent(event);
@@ -4027,10 +3989,6 @@ public class Editor {
            }
        }

        public void setActionPopupWindow(ActionPopupWindow actionPopupWindow) {
            mActionPopupWindow = actionPopupWindow;
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            boolean superResult = super.onTouchEvent(event);
@@ -4159,11 +4117,6 @@ public class Editor {
            mStartHandle.show();
            mEndHandle.show();

            // Make sure both left and right handles share the same ActionPopupWindow (so that
            // moving any of the handles hides the action popup).
            mStartHandle.showActionPopupWindow(DELAY_BEFORE_REPLACE_ACTION);
            mEndHandle.setActionPopupWindow(mStartHandle.getActionPopupWindow());

            hideInsertionPointCursorController();
        }