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
This commit is contained in:
@@ -7673,8 +7673,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
private int mPositionY;
|
private int mPositionY;
|
||||||
private CursorController mController;
|
private CursorController mController;
|
||||||
private boolean mIsDragging;
|
private boolean mIsDragging;
|
||||||
private int mOffsetX;
|
private float mOffsetX;
|
||||||
private int mOffsetY;
|
private float mOffsetY;
|
||||||
|
private float mHotspotX;
|
||||||
|
private float mHotspotY;
|
||||||
|
|
||||||
public HandleView(CursorController controller, Drawable handle) {
|
public HandleView(CursorController controller, Drawable handle) {
|
||||||
super(TextView.this.mContext);
|
super(TextView.this.mContext);
|
||||||
@@ -7684,7 +7686,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
com.android.internal.R.attr.textSelectHandleWindowStyle);
|
com.android.internal.R.attr.textSelectHandleWindowStyle);
|
||||||
mContainer.setSplitTouchEnabled(true);
|
mContainer.setSplitTouchEnabled(true);
|
||||||
mContainer.setClippingEnabled(false);
|
mContainer.setClippingEnabled(false);
|
||||||
mContainer.setLayoutInScreenEnabled(true);
|
mHotspotX = mDrawable.getIntrinsicWidth() * 0.5f;
|
||||||
|
mHotspotY = -mDrawable.getIntrinsicHeight() * 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -7700,7 +7703,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
mContainer.setContentView(this);
|
mContainer.setContentView(this);
|
||||||
final int[] coords = mTempCoords;
|
final int[] coords = mTempCoords;
|
||||||
TextView.this.getLocationOnScreen(coords);
|
TextView.this.getLocationInWindow(coords);
|
||||||
coords[0] += mPositionX;
|
coords[0] += mPositionX;
|
||||||
coords[1] += mPositionY;
|
coords[1] += mPositionY;
|
||||||
mContainer.showAtLocation(TextView.this, 0, coords[0], coords[1]);
|
mContainer.showAtLocation(TextView.this, 0, coords[0], coords[1]);
|
||||||
@@ -7743,7 +7746,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (isPositionInBounds()) {
|
if (isPositionInBounds()) {
|
||||||
if (mContainer.isShowing()){
|
if (mContainer.isShowing()){
|
||||||
final int[] coords = mTempCoords;
|
final int[] coords = mTempCoords;
|
||||||
TextView.this.getLocationOnScreen(coords);
|
TextView.this.getLocationInWindow(coords);
|
||||||
coords[0] += mPositionX;
|
coords[0] += mPositionX;
|
||||||
coords[1] += mPositionY;
|
coords[1] += mPositionY;
|
||||||
mContainer.update(coords[0], coords[1], mRight - mLeft, mBottom - mTop);
|
mContainer.update(coords[0], coords[1], mRight - mLeft, mBottom - mTop);
|
||||||
@@ -7771,24 +7774,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev) {
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
switch (ev.getActionMasked()) {
|
switch (ev.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN: {
|
||||||
mOffsetX = (int) (ev.getX() - mDrawable.getIntrinsicWidth() / 2.f + 0.5f);
|
|
||||||
mOffsetY = (int) (ev.getY() - mDrawable.getIntrinsicHeight() / 2.f + 0.5f);
|
|
||||||
mIsDragging = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
final float rawX = ev.getRawX();
|
final float rawX = ev.getRawX();
|
||||||
final float rawY = ev.getRawY();
|
final float rawY = ev.getRawY();
|
||||||
final int[] coords = mTempCoords;
|
mOffsetX = rawX - mPositionX;
|
||||||
TextView.this.getLocationOnScreen(coords);
|
mOffsetY = rawY - mPositionY;
|
||||||
final int x = (int) (rawX - coords[0] + 0.5f) - mOffsetX;
|
mIsDragging = true;
|
||||||
final int y = (int) (rawY - coords[1] + 0.5f) -
|
|
||||||
(int) (mDrawable.getIntrinsicHeight() * 0.8f) - mOffsetY;
|
|
||||||
|
|
||||||
mController.updatePosition(this, x, y);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case MotionEvent.ACTION_MOVE: {
|
||||||
|
final float rawX = ev.getRawX();
|
||||||
|
final float rawY = ev.getRawY();
|
||||||
|
final float newPosX = rawX - mOffsetX + mHotspotX;
|
||||||
|
final float newPosY = rawY - mOffsetY + mHotspotY;
|
||||||
|
|
||||||
|
mController.updatePosition(this, (int) Math.round(newPosX),
|
||||||
|
(int) Math.round(newPosY));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
mIsDragging = false;
|
mIsDragging = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user