summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2011-08-08 14:32:41 -0700
committer Dianne Hackborn <hackbod@google.com> 2011-08-09 11:11:25 -0700
commit70a3f677bf015d8641f41d149b76d362bb2b801c (patch)
tree093eea4cefbec149d893ba4f47f126bbff5cb92d
parent43321684393fbb92b306aeee1f5337db1904e569 (diff)
Fix issue #5016544: IME keyboard hides folder rename text field.
Tweak some issues in TextView with the focus rect used to determing where the scroll position needs to be. The ultimate problem was that in various situations it would use the right-most selection position cursor as the scroll location and when it adds 1 to make this a valid rect we end up with a rectangle that is outside of the view. Change-Id: Ia200c58e4e014d2a0a1be4761f9a1e5eb702a8e5
-rw-r--r--core/java/android/view/ViewRootImpl.java2
-rw-r--r--core/java/android/widget/TextView.java46
2 files changed, 38 insertions, 10 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e7d7747044d3..380fc156a225 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -96,7 +96,7 @@ import java.util.List;
@SuppressWarnings({"EmptyCatchBlock", "PointlessBooleanExpression"})
public final class ViewRootImpl extends Handler implements ViewParent,
View.AttachInfo.Callbacks, HardwareRenderer.HardwareDrawCallbacks {
- private static final String TAG = "ViewAncestor";
+ private static final String TAG = "ViewRootImpl";
private static final boolean DBG = false;
private static final boolean LOCAL_LOGV = false;
/** @noinspection PointlessBooleanExpression*/
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index cec3fda44c5d..ac6b3dd22911 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4969,18 +4969,42 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
- int sel = getSelectionEnd();
- if (sel < 0) {
+ int selEnd = getSelectionEnd();
+ if (selEnd < 0) {
super.getFocusedRect(r);
return;
}
- int line = mLayout.getLineForOffset(sel);
- r.top = mLayout.getLineTop(line);
- r.bottom = mLayout.getLineBottom(line);
-
- r.left = (int) mLayout.getPrimaryHorizontal(sel);
- r.right = r.left + 1;
+ int selStart = getSelectionStart();
+ if (selStart < 0 || selStart >= selEnd) {
+ int line = mLayout.getLineForOffset(selEnd);
+ r.top = mLayout.getLineTop(line);
+ r.bottom = mLayout.getLineBottom(line);
+ r.left = (int) mLayout.getPrimaryHorizontal(selEnd) - 2;
+ r.right = r.left + 4;
+ } else {
+ int lineStart = mLayout.getLineForOffset(selStart);
+ int lineEnd = mLayout.getLineForOffset(selEnd);
+ r.top = mLayout.getLineTop(lineStart);
+ r.bottom = mLayout.getLineBottom(lineEnd);
+ if (lineStart == lineEnd) {
+ r.left = (int) mLayout.getPrimaryHorizontal(selStart);
+ r.right = (int) mLayout.getPrimaryHorizontal(selEnd);
+ } else {
+ // Selection extends across multiple lines -- the focused
+ // rect covers the entire width.
+ if (mHighlightPathBogus) {
+ mHighlightPath.reset();
+ mLayout.getSelectionPath(selStart, selEnd, mHighlightPath);
+ mHighlightPathBogus = false;
+ }
+ synchronized (sTempRect) {
+ mHighlightPath.computeBounds(sTempRect, true);
+ r.left = (int)sTempRect.left-1;
+ r.right = (int)sTempRect.right+1;
+ }
+ }
+ }
// Adjust for padding and gravity.
int paddingLeft = getCompoundPaddingLeft();
@@ -6812,7 +6836,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// requestRectangleOnScreen() is in terms of content coordinates.
if (mTempRect == null) mTempRect = new Rect();
- mTempRect.set(x, top, x + 1, bottom);
+ // The offsets here are to ensure the rectangle we are using is
+ // within our view bounds, in case the cursor is on the far left
+ // or right. If it isn't withing the bounds, then this request
+ // will be ignored.
+ mTempRect.set(x - 2, top, x + 2, bottom);
getInterestingRect(mTempRect, line);
mTempRect.offset(mScrollX, mScrollY);