summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-10-02 16:59:42 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-02 16:59:42 -0700
commit0d843dc47929ff6e3dbaa4cc1d07de7fbdba8506 (patch)
tree4615c23f50a0ef7a458728220d8b5d84d108a12c /core
parent53303da0a78da2042ec60226ee290d2c903e6023 (diff)
parentea32f94ec4c14fe21b536139762c5332d1b5484c (diff)
downloadframeworks_base-0d843dc47929ff6e3dbaa4cc1d07de7fbdba8506.zip
frameworks_base-0d843dc47929ff6e3dbaa4cc1d07de7fbdba8506.tar.gz
frameworks_base-0d843dc47929ff6e3dbaa4cc1d07de7fbdba8506.tar.bz2
am ea32f94e: Fix bug 3058082 - text anchor positioning within moving dialogs
Merge commit 'ea32f94ec4c14fe21b536139762c5332d1b5484c' into gingerbread-plus-aosp * commit 'ea32f94ec4c14fe21b536139762c5332d1b5484c': Fix bug 3058082 - text anchor positioning within moving dialogs
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/TextView.java38
1 files changed, 21 insertions, 17 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 9885838..75edfaa 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7673,8 +7673,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private int mPositionY;
private CursorController mController;
private boolean mIsDragging;
- private int mOffsetX;
- private int mOffsetY;
+ private float mOffsetX;
+ private float mOffsetY;
+ private float mHotspotX;
+ private float mHotspotY;
public HandleView(CursorController controller, Drawable handle) {
super(TextView.this.mContext);
@@ -7684,7 +7686,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
com.android.internal.R.attr.textSelectHandleWindowStyle);
mContainer.setSplitTouchEnabled(true);
mContainer.setClippingEnabled(false);
- mContainer.setLayoutInScreenEnabled(true);
+ mHotspotX = mDrawable.getIntrinsicWidth() * 0.5f;
+ mHotspotY = -mDrawable.getIntrinsicHeight() * 0.2f;
}
@Override
@@ -7700,7 +7703,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
mContainer.setContentView(this);
final int[] coords = mTempCoords;
- TextView.this.getLocationOnScreen(coords);
+ TextView.this.getLocationInWindow(coords);
coords[0] += mPositionX;
coords[1] += mPositionY;
mContainer.showAtLocation(TextView.this, 0, coords[0], coords[1]);
@@ -7743,7 +7746,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (isPositionInBounds()) {
if (mContainer.isShowing()){
final int[] coords = mTempCoords;
- TextView.this.getLocationOnScreen(coords);
+ TextView.this.getLocationInWindow(coords);
coords[0] += mPositionX;
coords[1] += mPositionY;
mContainer.update(coords[0], coords[1], mRight - mLeft, mBottom - mTop);
@@ -7771,24 +7774,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getActionMasked()) {
- case MotionEvent.ACTION_DOWN:
- mOffsetX = (int) (ev.getX() - mDrawable.getIntrinsicWidth() / 2.f + 0.5f);
- mOffsetY = (int) (ev.getY() - mDrawable.getIntrinsicHeight() / 2.f + 0.5f);
+ case MotionEvent.ACTION_DOWN: {
+ final float rawX = ev.getRawX();
+ final float rawY = ev.getRawY();
+ mOffsetX = rawX - mPositionX;
+ mOffsetY = rawY - mPositionY;
mIsDragging = true;
break;
-
- case MotionEvent.ACTION_MOVE:
+ }
+ case MotionEvent.ACTION_MOVE: {
final float rawX = ev.getRawX();
final float rawY = ev.getRawY();
- final int[] coords = mTempCoords;
- TextView.this.getLocationOnScreen(coords);
- final int x = (int) (rawX - coords[0] + 0.5f) - mOffsetX;
- final int y = (int) (rawY - coords[1] + 0.5f) -
- (int) (mDrawable.getIntrinsicHeight() * 0.8f) - mOffsetY;
+ final float newPosX = rawX - mOffsetX + mHotspotX;
+ final float newPosY = rawY - mOffsetY + mHotspotY;
- mController.updatePosition(this, x, y);
- break;
+ mController.updatePosition(this, (int) Math.round(newPosX),
+ (int) Math.round(newPosY));
+ break;
+ }
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsDragging = false;