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

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

Merge "Rationalize blinking cursor test."

parents d02c5dfd 545c4d44
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1202,14 +1202,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                imm.hideSoftInputFromWindow(getWindowToken(), 0);
            }
        }

        super.setEnabled(enabled);
        prepareCursorControllers();

        if (enabled) {
            // Make sure IME is updated with current editor info.
            InputMethodManager imm = InputMethodManager.peekInstance();
            if (imm != null) imm.restartInput(this);
        }

        prepareCursorControllers();

        // start or stop the cursor blinking as appropriate
        makeBlink();
    }
@@ -8581,7 +8584,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @return True when the TextView isFocused and has a valid zero-length selection (cursor).
     */
    private boolean shouldBlink() {
        if (!isFocused()) return false;
        if (!isCursorVisible() || !isFocused()) return false;

        final int start = getSelectionStart();
        if (start < 0) return false;
@@ -8593,13 +8596,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private void makeBlink() {
        if (isCursorVisible()) {
        if (shouldBlink()) {
            mShowCursor = SystemClock.uptimeMillis();
            if (mBlink == null) mBlink = new Blink(this);
            mBlink.removeCallbacks(mBlink);
            mBlink.postAtTime(mBlink, mShowCursor + BLINK);
            }
        } else {
            if (mBlink != null) mBlink.removeCallbacks(mBlink);
        }