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

Commit 6da7e935 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

No NPE in Browser when pasting in WebTextView.

Bug 3258790

Change-Id: I25d67ee85babb1bb3e4d05ea7b4e4d3756c60411
parent 49c7a01a
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -7388,14 +7388,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private boolean canSelectText() {
        return textCanBeSelected() && mText.length() != 0;
        return hasSelectionController() && mText.length() != 0;
    }

    private boolean textCanBeSelected() {
        // prepareCursorController() relies on this method.
        // If you change this condition, make sure prepareCursorController is called anywhere
        // the value of this condition might be changed.
        return (mText instanceof Spannable && mMovement != null && mMovement.canSelectArbitrarily());
        return mText instanceof Spannable && mMovement != null && mMovement.canSelectArbitrarily();
    }

    private boolean canCut() {
@@ -7529,6 +7529,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private void selectCurrentWord() {
        if (!canSelectText()) {
            return;
        }

        if (hasPasswordTransformationMethod()) {
            // selectCurrentWord is not available on a password field and would return an
            // arbitrary 10-charater selection around pressed position. Select all instead.
@@ -7544,7 +7548,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            minOffset = getSelectionStart();
            maxOffset = getSelectionEnd();
        } else {
            // selectionModifierCursorController is guaranteed to exist at that point
            SelectionModifierCursorController selectionController = getSelectionController();
            minOffset = selectionController.getMinTouchOffset();
            maxOffset = selectionController.getMaxTouchOffset();
@@ -7921,14 +7924,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        selectCurrentWord();
        ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
        if (actionModeCallback != null) {
        mSelectionActionMode = startActionMode(actionModeCallback);
        return mSelectionActionMode != null;
    }

        return false;
    }

    /**
     * Same as {@link #stopSelectionActionMode()}, except that there is no cursor controller
     * fade out animation. Needed since the drawable and their alpha values are shared by all