summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-10-21 13:48:18 -0700
committerGilles Debunne <debunne@google.com>2011-10-28 11:08:56 -0700
commit93347c24a77489d614332b8dfa98a3a50092590c (patch)
treea9204766f181bce9fa06c80c517f0ffb161fb1aa
parentb44038fd294382d42070eb60df3bf5132eb4cb29 (diff)
downloadframeworks_base-93347c24a77489d614332b8dfa98a3a50092590c.zip
frameworks_base-93347c24a77489d614332b8dfa98a3a50092590c.tar.gz
frameworks_base-93347c24a77489d614332b8dfa98a3a50092590c.tar.bz2
Text handles do not handle scroll correctly
A recent patch taking scroll into account was applied at the wrong level. isVisible() expects positions that already take scroll into account. isOffsetVisible() is where the initial bug was. Cherry pick of 144415 from master. Change-Id: I06ceebfb3d7b24aa4adba886c24fcf9d8dd39d2e
-rw-r--r--core/java/android/widget/TextView.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7f03adf..0a2365e 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9409,8 +9409,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return false;
}
- int posX = mPositionX + positionX - getScrollX();
- int posY = mPositionY + positionY - getScrollY();
+ int posX = mPositionX + positionX;
+ int posY = mPositionY + positionY;
// Offset by 1 to take into account 0.5 and int rounding around getPrimaryHorizontal.
return posX >= clip.left - 1 && posX <= clip.right + 1 &&
@@ -9421,7 +9421,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final int line = mLayout.getLineForOffset(offset);
final int lineBottom = mLayout.getLineBottom(line);
final int primaryHorizontal = (int) mLayout.getPrimaryHorizontal(offset);
- return isVisible(primaryHorizontal, lineBottom);
+ return isVisible(primaryHorizontal + viewportToContentHorizontalOffset(),
+ lineBottom + viewportToContentVerticalOffset());
}
public void onScrollChanged() {
@@ -10561,7 +10562,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mPositionX = (int) (mLayout.getPrimaryHorizontal(offset) - 0.5f - mHotspotX);
mPositionY = mLayout.getLineBottom(line);
- // Take TextView's padding into account.
+ // Take TextView's padding and scroll into account.
mPositionX += viewportToContentHorizontalOffset();
mPositionY += viewportToContentVerticalOffset();