summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2015-05-27 19:49:34 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2015-05-27 19:49:34 +0900
commitdbe2c293e113b35b43abdb5733311782f9afe11c (patch)
treee80249c82a9d06858acd614de17c8d5600a0b8dd
parent99fbb56a0ab81ead404480f0c2df529332a93a32 (diff)
downloadframeworks_base-dbe2c293e113b35b43abdb5733311782f9afe11c.zip
frameworks_base-dbe2c293e113b35b43abdb5733311782f9afe11c.tar.gz
frameworks_base-dbe2c293e113b35b43abdb5733311782f9afe11c.tar.bz2
Fix: Drag handle jumps between bidi boundaries.
mHotspotX and mHorizontalGravity was updated even when the handle is dragging. As a result, updatePosition() can be called with the adjusted coordinate for the updated text direction. Bug: 21131463 Change-Id: Ie3c2215a0d978db655d55693ee484f04ce5b35fa
-rw-r--r--core/java/android/widget/Editor.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index fc84cf9..6c6099f 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -3501,13 +3501,24 @@ public class Editor {
}
protected void updateDrawable() {
+ if (mIsDragging) {
+ // Don't update drawable during dragging.
+ return;
+ }
final int offset = getCurrentCursorOffset();
final boolean isRtlCharAtOffset = mTextView.getLayout().isRtlCharAt(offset);
final Drawable oldDrawable = mDrawable;
mDrawable = isRtlCharAtOffset ? mDrawableRtl : mDrawableLtr;
mHotspotX = getHotspotX(mDrawable, isRtlCharAtOffset);
mHorizontalGravity = getHorizontalGravity(isRtlCharAtOffset);
- if (oldDrawable != mDrawable) {
+ final Layout layout = mTextView.getLayout();
+ if (layout != null && oldDrawable != mDrawable && isShowing()) {
+ // Update popup window position.
+ mPositionX = (int) (layout.getPrimaryHorizontal(offset) - 0.5f - mHotspotX -
+ getHorizontalOffset() + getCursorOffset());
+ mPositionX += mTextView.viewportToContentHorizontalOffset();
+ mPositionHasChanged = true;
+ updatePosition(mLastParentX, mLastParentY, false, false);
postInvalidate();
}
}
@@ -3781,10 +3792,12 @@ public class Editor {
case MotionEvent.ACTION_UP:
filterOnTouchUp();
mIsDragging = false;
+ updateDrawable();
break;
case MotionEvent.ACTION_CANCEL:
mIsDragging = false;
+ updateDrawable();
break;
}
return true;