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

Commit 98dbfd49 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Non-editable TextViews should not display a cursor.

Bug 3381320

The tests were inconsistent between makeBlink and onDraw.
If the text is non-editable, do not draw the cursor.

Change-Id: I0405e59444261a553e868b3ae5bdddd278f60bb2
parent b35672e4
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -4334,7 +4334,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            selStart = getSelectionStart();
            selEnd = getSelectionEnd();

            if ((mCursorVisible || mTextIsSelectable) && selStart >= 0 && isEnabled()) {
            if ((isCursorVisible() || mTextIsSelectable) && selStart >= 0 && isEnabled()) {
                if (mHighlightPath == null)
                    mHighlightPath = new Path();

@@ -6490,6 +6490,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        prepareCursorControllers();
    }

    private boolean isCursorVisible() {
        return mCursorVisible && isTextEditable();
    }

    private boolean canMarquee() {
        int width = (mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight());
        return width > 0 && mLayout.getLineWidth(0) > width;
@@ -6978,7 +6982,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private void makeBlink() {
        if (!mCursorVisible || !isTextEditable()) {
        if (!isCursorVisible()) {
            if (mBlink != null) {
                mBlink.removeCallbacks(mBlink);
            }
@@ -7372,8 +7376,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
        }

        mInsertionControllerEnabled = windowSupportsHandles && isTextEditable() && mCursorVisible &&
                mLayout != null;
        mInsertionControllerEnabled = windowSupportsHandles && isCursorVisible() && mLayout != null;
        mSelectionControllerEnabled = windowSupportsHandles && textCanBeSelected() &&
                mLayout != null;