From b7419dd76e6d0ff06a1d45fd8389093c9a212351 Mon Sep 17 00:00:00 2001 From: Clara Bayarri <clarabayarri@google.com> Date: Thu, 9 Apr 2015 15:24:58 +0100 Subject: Editor: Account for a split cursor in the content rect calculation In some cases, the cursor in a TextView is split. This happens with RTL languages. For this case we need to ensure neither of the half cursors is obscured by the Floating Toolbar, hence we take the minimal rectangle that contains both cursors as the content rect. Change-Id: I2ce411793fcba2140c4ad7fb7caaf03593620484 --- core/java/android/widget/Editor.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core/java/android') diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 32b99a8..70152a1 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -3091,6 +3091,17 @@ public class Editor { mTextView.getSelectionStart(), mTextView.getSelectionEnd(), mSelectionPath); mSelectionPath.computeBounds(mSelectionBounds, true); mSelectionBounds.bottom += mSelectionHandleHeight; + } else if (mCursorCount == 2) { + // We have a split cursor. In this case, we take the rectangle that includes both + // parts of the cursor to ensure we don't obscure either of them. + Rect firstCursorBounds = mCursorDrawable[0].getBounds(); + Rect secondCursorBounds = mCursorDrawable[1].getBounds(); + mSelectionBounds.set( + Math.min(firstCursorBounds.left, secondCursorBounds.left), + Math.min(firstCursorBounds.top, secondCursorBounds.top), + Math.max(firstCursorBounds.right, secondCursorBounds.right), + Math.max(firstCursorBounds.bottom, secondCursorBounds.bottom) + + mInsertionHandleHeight); } else { // We have a single cursor. int line = mTextView.getLayout().getLineForOffset(mTextView.getSelectionStart()); -- cgit v1.1