Merge "Fix bug #6567507 [Bidi] - Cursor is sometimes not visible on EditText" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f053e2367d
@@ -1416,6 +1416,7 @@ public class Editor {
|
||||
}
|
||||
|
||||
Layout layout = mTextView.getLayout();
|
||||
Layout hintLayout = mTextView.getHintLayout();
|
||||
final int offset = mTextView.getSelectionStart();
|
||||
final int line = layout.getLineForOffset(offset);
|
||||
final int top = layout.getLineTop(line);
|
||||
@@ -1429,13 +1430,23 @@ public class Editor {
|
||||
middle = (top + bottom) >> 1;
|
||||
}
|
||||
|
||||
updateCursorPosition(0, top, middle, layout.getPrimaryHorizontal(offset));
|
||||
updateCursorPosition(0, top, middle, getPrimaryHorizontal(layout, hintLayout, offset));
|
||||
|
||||
if (mCursorCount == 2) {
|
||||
updateCursorPosition(1, middle, bottom, layout.getSecondaryHorizontal(offset));
|
||||
}
|
||||
}
|
||||
|
||||
private float getPrimaryHorizontal(Layout layout, Layout hintLayout, int offset) {
|
||||
if (TextUtils.isEmpty(layout.getText()) &&
|
||||
hintLayout != null &&
|
||||
!TextUtils.isEmpty(hintLayout.getText())) {
|
||||
return hintLayout.getPrimaryHorizontal(offset);
|
||||
} else {
|
||||
return layout.getPrimaryHorizontal(offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the selection mode was actually started.
|
||||
*/
|
||||
|
||||
@@ -1311,6 +1311,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
return mLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Layout that is currently being used to display the hint text.
|
||||
* This can be null.
|
||||
*/
|
||||
final Layout getHintLayout() {
|
||||
return mHintLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current key listener for this TextView.
|
||||
* This will frequently be null for non-EditText TextViews.
|
||||
|
||||
Reference in New Issue
Block a user