Skip to content

Commit 1fb9049

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Text blinking cursor hard to see." into ics-mr1
2 parents 9c92fcd + 961ebb9 commit 1fb9049

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

core/java/android/widget/SpellChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo s
393393
SuggestionSpan.FLAG_EASY_CORRECT | SuggestionSpan.FLAG_MISSPELLED);
394394
editable.setSpan(suggestionSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
395395

396-
mTextView.invalidateRegion(start, end);
396+
mTextView.invalidateRegion(start, end, false /* No cursor involved */);
397397
}
398398

399399
private class SpellParser {

core/java/android/widget/TextView.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static class InputMethodState {
339339

340340
private int mCursorDrawableRes;
341341
private final Drawable[] mCursorDrawable = new Drawable[2];
342-
private int mCursorCount; // Actual current number of used mCursorDrawable: 0, 1 or 2
342+
private int mCursorCount; // Actual current number of used mCursorDrawable: 0, 1 or 2 (split)
343343

344344
private Drawable mSelectHandleLeft;
345345
private Drawable mSelectHandleRight;
@@ -4322,7 +4322,7 @@ private void invalidateCursor(int a, int b, int c) {
43224322
if (a >= 0 || b >= 0 || c >= 0) {
43234323
int start = Math.min(Math.min(a, b), c);
43244324
int end = Math.max(Math.max(a, b), c);
4325-
invalidateRegion(start, end);
4325+
invalidateRegion(start, end, true /* Also invalidates blinking cursor */);
43264326
}
43274327
}
43284328

@@ -4331,7 +4331,7 @@ private void invalidateCursor(int a, int b, int c) {
43314331
*
43324332
* @hide
43334333
*/
4334-
void invalidateRegion(int start, int end) {
4334+
void invalidateRegion(int start, int end, boolean invalidateCursor) {
43354335
if (mLayout == null) {
43364336
invalidate();
43374337
} else {
@@ -4357,11 +4357,19 @@ void invalidateRegion(int start, int end) {
43574357

43584358
int bottom = mLayout.getLineBottom(lineEnd);
43594359

4360+
if (invalidateCursor) {
4361+
for (int i = 0; i < mCursorCount; i++) {
4362+
Rect bounds = mCursorDrawable[i].getBounds();
4363+
top = Math.min(top, bounds.top);
4364+
bottom = Math.max(bottom, bounds.bottom);
4365+
}
4366+
}
4367+
43604368
final int compoundPaddingLeft = getCompoundPaddingLeft();
43614369
final int verticalPadding = getExtendedPaddingTop() + getVerticalOffset(true);
43624370

43634371
int left, right;
4364-
if (lineStart == lineEnd) {
4372+
if (lineStart == lineEnd && !invalidateCursor) {
43654373
left = (int) mLayout.getPrimaryHorizontal(start);
43664374
right = (int) (mLayout.getPrimaryHorizontal(end) + 1.0);
43674375
left += compoundPaddingLeft;

0 commit comments

Comments
 (0)