Merge "Fix bug #6567507 [Bidi] - Cursor is sometimes not visible on EditText" into jb-dev

This commit is contained in:
Fabrice Di Meglio
2012-05-30 15:31:23 -07:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 1 deletions

View File

@@ -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.
*/

View File

@@ -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.