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

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

Merge "resolved conflicts for merge of f309c7a8 to master"

parents 8a359961 fc2563ba
Loading
Loading
Loading
Loading
+32 −31
Original line number Diff line number Diff line
@@ -7174,6 +7174,38 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return (((long) start) << 32) | end;
    }

    private void selectCurrentWord() {
        // In case selection mode is started after an orientation change or after a select all,
        // use the current selection instead of creating one
        if (hasSelection()) {
            return;
        }

        int selectionStart, selectionEnd;

        // selectionModifierCursorController is not null at that point
        SelectionModifierCursorController selectionModifierCursorController =
            ((SelectionModifierCursorController) mSelectionModifierCursorController);
        int minOffset = selectionModifierCursorController.getMinTouchOffset();
        int maxOffset = selectionModifierCursorController.getMaxTouchOffset();

        long wordLimits = getWordLimitsAt(minOffset);
        if (wordLimits >= 0) {
            selectionStart = (int) (wordLimits >>> 32);
        } else {
            selectionStart = Math.max(minOffset - 5, 0);
        }

        wordLimits = getWordLimitsAt(maxOffset);
        if (wordLimits >= 0) {
            selectionEnd = (int) (wordLimits & 0x00000000FFFFFFFFL);
        } else {
            selectionEnd = Math.min(maxOffset + 5, mText.length());
        }

        Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
    }

    @Override
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
        if (!isShown()) {
@@ -7470,37 +7502,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }
        }

        private void selectCurrentWord() {
            // In case selection mode is started after an orientation change, use the current
            // selection instead of creating one
            if (hasSelection()) {
                return;
            }

            int selectionStart, selectionEnd;

            SelectionModifierCursorController selectionModifierCursorController =
                ((SelectionModifierCursorController) mSelectionModifierCursorController);
            int minOffset = selectionModifierCursorController.getMinTouchOffset();
            int maxOffset = selectionModifierCursorController.getMaxTouchOffset();

            long wordLimits = getWordLimitsAt(minOffset);
            if (wordLimits >= 0) {
                selectionStart = (int) (wordLimits >>> 32);
            } else {
                selectionStart = Math.max(minOffset - 5, 0);
            }

            wordLimits = getWordLimitsAt(maxOffset);
            if (wordLimits >= 0) {
                selectionEnd = (int) (wordLimits & 0x00000000FFFFFFFFL);
            } else {
                selectionEnd = Math.min(maxOffset + 5, mText.length());
            }

            Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return true;