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

Commit b3fbd7e0 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Stop text selection mode when new text replaces selection." into honeycomb

parents e0b19124 d94f8c50
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -4780,7 +4780,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }

        hideControllers();
        stopSelectionActionMode();

        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_CENTER:
@@ -5119,6 +5118,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (mInputMethodState != null) {
            mInputMethodState.mExtracting = req;
        }
        // This stops a possible text selection mode. Maybe not intended.
        hideControllers();
    }
    
@@ -6781,7 +6781,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        sendOnTextChanged(buffer, start, before, after);
        onTextChanged(buffer, start, before, after);

        // Hide the controller if the amount of content changed
        // Hide the controllers if the amount of content changed
        if (before != after) {
            hideControllers();
        }
@@ -8207,9 +8207,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            selectCurrentWord();
        }

        if (!mTextIsSelectable) {
            // Show the IME, except when selection non editable text.
            final InputMethodManager imm = (InputMethodManager)
                    getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(this, 0, null);
        }

        ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
        mSelectionActionMode = startActionMode(actionModeCallback);
@@ -8233,6 +8236,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private void stopSelectionActionMode() {
        if (mSelectionActionMode != null) {
            // This will hide the mSelectionModifierCursorController
            mSelectionActionMode.finish();
        }
    }
@@ -8356,8 +8360,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            if (mCustomSelectionActionModeCallback != null) {
                mCustomSelectionActionModeCallback.onDestroyActionMode(mode);
            }
            Selection.setSelection((Spannable) mText, getSelectionStart());
            hideSelectionModifierCursorController();
            Selection.setSelection((Spannable) mText, getSelectionEnd());

            if (mSelectionModifierCursorController != null) {
                mSelectionModifierCursorController.hide();
            }

            mSelectionActionMode = null;
        }
    }
@@ -9173,16 +9181,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
    }

    private void hideSelectionModifierCursorController() {
        // No need to create the controller to hide it.
        if (mSelectionModifierCursorController != null) {
            mSelectionModifierCursorController.hide();
        }
    }
    
    /**
     * Hides the insertion controller and stops text selection mode, hiding the selection controller
     */
    private void hideControllers() {
        hideInsertionPointCursorController();
        hideSelectionModifierCursorController();
        stopSelectionActionMode();
    }

    /**