summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2010-09-09 10:04:32 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-09 10:04:32 -0700
commitff5453809692a86093d65b8943186ac12890d123 (patch)
tree0b69564deafb8463d78a9821de9f4a47b89214b8
parentf0eab98c4ef7449eb5a5ef659cd794e0003216b3 (diff)
parentab86b782fd2c8c7b1e6b50d30482aa2b8f890e80 (diff)
downloadframeworks_base-ff5453809692a86093d65b8943186ac12890d123.zip
frameworks_base-ff5453809692a86093d65b8943186ac12890d123.tar.gz
frameworks_base-ff5453809692a86093d65b8943186ac12890d123.tar.bz2
am ab86b782: Merge "Fix for text selection in horizontally scrolled TextViews." into gingerbread
Merge commit 'ab86b782fd2c8c7b1e6b50d30482aa2b8f890e80' into gingerbread-plus-aosp * commit 'ab86b782fd2c8c7b1e6b50d30482aa2b8f890e80': Fix for text selection in horizontally scrolled TextViews.
-rw-r--r--core/java/android/widget/TextView.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7d3e917..f95a0dd 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5766,18 +5766,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private void convertFromViewportToContentCoordinates(Rect r) {
- int paddingTop = getExtendedPaddingTop();
- if ((mGravity & Gravity.VERTICAL_GRAVITY_MASK) != Gravity.TOP) {
- paddingTop += getVerticalOffset(false);
- }
- r.top += paddingTop;
- r.bottom += paddingTop;
+ final int horizontalOffset = viewportToContentHorizontalOffset();
+ r.left += horizontalOffset;
+ r.right += horizontalOffset;
- int paddingLeft = getCompoundPaddingLeft();
- r.left += paddingLeft;
- r.right += paddingLeft;
+ final int verticalOffset = viewportToContentVerticalOffset();
+ r.top += verticalOffset;
+ r.bottom += verticalOffset;
+ }
- r.offset(-mScrollX, -mScrollY);
+ private int viewportToContentHorizontalOffset() {
+ return getCompoundPaddingLeft() - mScrollX;
+ }
+
+ private int viewportToContentVerticalOffset() {
+ int offset = getExtendedPaddingTop() - mScrollY;
+ if ((mGravity & Gravity.VERTICAL_GRAVITY_MASK) != Gravity.TOP) {
+ offset += getVerticalOffset(false);
+ }
+ return offset;
}
@Override
@@ -7656,9 +7663,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
bounds.right = bounds.left + drawableWidth;
bounds.bottom = bounds.top + drawableHeight;
- int boundTopBefore = bounds.top;
convertFromViewportToContentCoordinates(bounds);
- mHotSpotVerticalPosition += bounds.top - boundTopBefore;
mDrawable.setBounds(bounds);
postInvalidate();
}
@@ -7802,6 +7807,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mOffsetX = (bounds.left + bounds.right) / 2.0f - x;
mOffsetY = mHandle.mHotSpotVerticalPosition - y;
+ mOffsetX += viewportToContentHorizontalOffset();
+ mOffsetY += viewportToContentVerticalOffset();
+
mOnDownTimerStart = event.getEventTime();
}
break;
@@ -7991,6 +7999,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mOffsetX = (bounds.left + bounds.right) / 2.0f - x;
mOffsetY = draggedHandle.mHotSpotVerticalPosition - y;
+ mOffsetX += viewportToContentHorizontalOffset();
+ mOffsetY += viewportToContentVerticalOffset();
+
mOnDownTimerStart = event.getEventTime();
((ArrowKeyMovementMethod)mMovement).setCursorController(this);
}