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

Commit a447937d authored by Clara Bayarri's avatar Clara Bayarri
Browse files

Fix TextView ActionMode overflow finishes the ActionMode

stopSelectionActionMode() was called within hideCursors, and this
gets called in many scenarios. One of them is onWindowFocusChanged,
which is triggered when the user clicks the overflow icon in the
action bar. Removed the action mode call from this use case.

Bug: 21267270
Change-Id: I1cd359e87de67141627e25d2ec520fc91303a48d
parent aee243b8
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -390,6 +390,7 @@ public class Editor {

        mPreserveDetachedSelection = true;
        hideControllers();
        stopSelectionActionMode();
        mPreserveDetachedSelection = false;
        mTemporaryDetach = false;
    }
@@ -624,7 +625,6 @@ public class Editor {
            mSuggestionsPopupWindow.hide();
        }
        hideInsertionPointCursorController();
        stopSelectionActionMode();
    }

    /**
@@ -1101,10 +1101,12 @@ public class Editor {
                final int selStart = mTextView.getSelectionStart();
                final int selEnd = mTextView.getSelectionEnd();
                hideControllers();
                stopSelectionActionMode();
                Selection.setSelection((Spannable) mTextView.getText(), selStart, selEnd);
            } else {
                if (mTemporaryDetach) mPreserveDetachedSelection = true;
                hideControllers();
                stopSelectionActionMode();
                if (mTemporaryDetach) mPreserveDetachedSelection = false;
                downgradeEasyCorrectionSpans();
            }
@@ -1147,6 +1149,7 @@ public class Editor {
        // We do not hide the span controllers, since they can be added when a new text is
        // inserted into the text view (voice IME).
        hideCursorControllers();
        stopSelectionActionMode();
    }

    private int getLastTapPosition() {
@@ -1878,6 +1881,7 @@ public class Editor {
    void onTouchUpEvent(MotionEvent event) {
        boolean selectAllGotFocus = mSelectAllOnFocus && mTextView.didTouchFocusSelect();
        hideControllers();
        stopSelectionActionMode();
        CharSequence text = mTextView.getText();
        if (!selectAllGotFocus && text.length() > 0) {
            // Move cursor
@@ -1998,6 +2002,7 @@ public class Editor {
            mSuggestionsPopupWindow = new SuggestionsPopupWindow();
        }
        hideControllers();
        stopSelectionActionMode();
        mSuggestionsPopupWindow.show();
    }

+2 −0
Original line number Diff line number Diff line
@@ -6422,6 +6422,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        // extracted mode will start. Some text is selected though, and will trigger an action mode
        // in the extracted view.
        mEditor.hideControllers();
        stopSelectionActionMode();
    }

    /**
@@ -8256,6 +8257,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        super.onVisibilityChanged(changedView, visibility);
        if (mEditor != null && visibility != VISIBLE) {
            mEditor.hideControllers();
            stopSelectionActionMode();
        }
    }