Merge changes from topic "cursor-bg-blink-cp" into tm-qpr-dev
* changes: Add Ability to Check if Cursor is Blinking Stop cursor from blinking when not visible
This commit is contained in:
committed by
Android (Google) Code Review
commit
131fb1ff89
@@ -709,7 +709,7 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPositionListener().addSubscriber(mCursorAnchorInfoNotifier, true);
|
getPositionListener().addSubscriber(mCursorAnchorInfoNotifier, true);
|
||||||
resumeBlink();
|
makeBlink();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDetachedFromWindow() {
|
void onDetachedFromWindow() {
|
||||||
@@ -1685,17 +1685,12 @@ public class Editor {
|
|||||||
|
|
||||||
void onWindowFocusChanged(boolean hasWindowFocus) {
|
void onWindowFocusChanged(boolean hasWindowFocus) {
|
||||||
if (hasWindowFocus) {
|
if (hasWindowFocus) {
|
||||||
if (mBlink != null) {
|
resumeBlink();
|
||||||
mBlink.uncancel();
|
|
||||||
makeBlink();
|
|
||||||
}
|
|
||||||
if (mTextView.hasSelection() && !extractedTextModeWillBeStarted()) {
|
if (mTextView.hasSelection() && !extractedTextModeWillBeStarted()) {
|
||||||
refreshTextActionMode();
|
refreshTextActionMode();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mBlink != null) {
|
suspendBlink();
|
||||||
mBlink.cancel();
|
|
||||||
}
|
|
||||||
if (mInputContentType != null) {
|
if (mInputContentType != null) {
|
||||||
mInputContentType.enterDown = false;
|
mInputContentType.enterDown = false;
|
||||||
}
|
}
|
||||||
@@ -2851,7 +2846,8 @@ public class Editor {
|
|||||||
* @return True when the TextView isFocused and has a valid zero-length selection (cursor).
|
* @return True when the TextView isFocused and has a valid zero-length selection (cursor).
|
||||||
*/
|
*/
|
||||||
private boolean shouldBlink() {
|
private boolean shouldBlink() {
|
||||||
if (!isCursorVisible() || !mTextView.isFocused()) return false;
|
if (!isCursorVisible() || !mTextView.isFocused()
|
||||||
|
|| mTextView.getWindowVisibility() != mTextView.VISIBLE) return false;
|
||||||
|
|
||||||
final int start = mTextView.getSelectionStart();
|
final int start = mTextView.getSelectionStart();
|
||||||
if (start < 0) return false;
|
if (start < 0) return false;
|
||||||
@@ -2873,6 +2869,17 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return whether the Blink runnable is blinking or not, if null return false.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public boolean isBlinking() {
|
||||||
|
if (mBlink == null) return false;
|
||||||
|
return !mBlink.mCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
private class Blink implements Runnable {
|
private class Blink implements Runnable {
|
||||||
private boolean mCancelled;
|
private boolean mCancelled;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user