am bc87ada1: Merge "Fix text anchors" into gingerbread
Merge commit 'bc87ada10de34c2d7b1301af86d94ed7c4801120' into gingerbread-plus-aosp * commit 'bc87ada10de34c2d7b1301af86d94ed7c4801120': Fix text anchors
This commit is contained in:
@@ -86,6 +86,7 @@ public class PopupWindow {
|
||||
private boolean mOutsideTouchable = false;
|
||||
private boolean mClippingEnabled = true;
|
||||
private boolean mSplitTouchEnabled;
|
||||
private boolean mLayoutInScreen;
|
||||
|
||||
private OnTouchListener mTouchInterceptor;
|
||||
|
||||
@@ -595,6 +596,29 @@ public class PopupWindow {
|
||||
mSplitTouchEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Indicates whether the popup window will be forced into using absolute screen coordinates
|
||||
* for positioning.</p>
|
||||
*
|
||||
* @return true if the window will always be positioned in screen coordinates.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isLayoutInScreenEnabled() {
|
||||
return mLayoutInScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Allows the popup window to force the flag
|
||||
* {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN}, overriding default behavior.
|
||||
* This will cause the popup to be positioned in absolute screen coordinates.</p>
|
||||
*
|
||||
* @param enabled true if the popup should always be positioned in screen coordinates
|
||||
* @hide
|
||||
*/
|
||||
public void setLayoutInScreenEnabled(boolean enabled) {
|
||||
mLayoutInScreen = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Change the width and height measure specs that are given to the
|
||||
* window manager by the popup. By default these are 0, meaning that
|
||||
@@ -899,7 +923,8 @@ public class PopupWindow {
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
|
||||
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
|
||||
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
|
||||
WindowManager.LayoutParams.FLAG_SPLIT_TOUCH);
|
||||
if(mIgnoreCheekPress) {
|
||||
curFlags |= WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
|
||||
}
|
||||
@@ -923,6 +948,9 @@ public class PopupWindow {
|
||||
if (mSplitTouchEnabled) {
|
||||
curFlags |= WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
|
||||
}
|
||||
if (mLayoutInScreen) {
|
||||
curFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||
}
|
||||
return curFlags;
|
||||
}
|
||||
|
||||
|
||||
@@ -3768,6 +3768,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
if (mError != null) {
|
||||
hideError();
|
||||
}
|
||||
|
||||
hideControllers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4118,6 +4120,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
*/
|
||||
|
||||
canvas.restore();
|
||||
|
||||
if (mInsertionPointCursorController != null &&
|
||||
mInsertionPointCursorController.isShowing()) {
|
||||
mInsertionPointCursorController.updatePosition();
|
||||
}
|
||||
if (mSelectionModifierCursorController != null &&
|
||||
mSelectionModifierCursorController.isShowing()) {
|
||||
mSelectionModifierCursorController.updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4741,6 +4752,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
if (mInputMethodState != null) {
|
||||
mInputMethodState.mExtracting = req;
|
||||
}
|
||||
hideControllers();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6271,7 +6283,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
|
||||
sendOnTextChanged(buffer, start, before, after);
|
||||
onTextChanged(buffer, start, before, after);
|
||||
hideControllers();
|
||||
|
||||
// Hide the controller if the amount of content changed
|
||||
if (before != after) {
|
||||
hideControllers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6610,11 +6626,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
if (mInputContentType != null) {
|
||||
mInputContentType.enterDown = false;
|
||||
}
|
||||
hideControllers();
|
||||
}
|
||||
|
||||
startStopMarquee(hasWindowFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||
super.onVisibilityChanged(changedView, visibility);
|
||||
if (visibility != VISIBLE) {
|
||||
hideControllers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link BaseInputConnection#removeComposingSpans
|
||||
* BaseInputConnection.removeComposingSpans()} to remove any IME composing
|
||||
@@ -6684,8 +6709,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
|
||||
if (hasSelection()) {
|
||||
startTextSelectionMode();
|
||||
} else if (mInsertionPointCursorController != null) {
|
||||
mInsertionPointCursorController.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7650,6 +7673,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
private int mPositionY;
|
||||
private CursorController mController;
|
||||
private boolean mIsDragging;
|
||||
private int mOffsetX;
|
||||
private int mOffsetY;
|
||||
|
||||
public HandleView(CursorController controller, Drawable handle) {
|
||||
super(TextView.this.mContext);
|
||||
@@ -7658,6 +7683,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
mContainer = new PopupWindow(TextView.this.mContext, null,
|
||||
com.android.internal.R.attr.textSelectHandleWindowStyle);
|
||||
mContainer.setSplitTouchEnabled(true);
|
||||
mContainer.setClippingEnabled(false);
|
||||
mContainer.setLayoutInScreenEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -7695,19 +7722,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
final int compoundPaddingRight = getCompoundPaddingRight();
|
||||
|
||||
final TextView hostView = TextView.this;
|
||||
final int right = hostView.mRight;
|
||||
final int left = hostView.mLeft;
|
||||
final int bottom = hostView.mBottom;
|
||||
final int top = hostView.mTop;
|
||||
final int handleWidth = mDrawable.getIntrinsicWidth();
|
||||
final int left = 0;
|
||||
final int right = hostView.getWidth();
|
||||
final int top = 0;
|
||||
final int bottom = hostView.getHeight();
|
||||
|
||||
final int clipLeft = left + compoundPaddingLeft;
|
||||
final int clipLeft = left + compoundPaddingLeft - (int) (handleWidth * 0.75f);
|
||||
final int clipTop = top + extendedPaddingTop;
|
||||
final int clipRight = right - compoundPaddingRight;
|
||||
final int clipRight = right - compoundPaddingRight + (int) (handleWidth * 0.25f);
|
||||
final int clipBottom = bottom - extendedPaddingBottom;
|
||||
|
||||
final int handleWidth = mDrawable.getIntrinsicWidth();
|
||||
return mPositionX >= clipLeft - handleWidth * 0.75f &&
|
||||
mPositionX <= clipRight + handleWidth * 0.25f &&
|
||||
return mPositionX >= clipLeft && mPositionX <= clipRight &&
|
||||
mPositionY >= clipTop && mPositionY <= clipBottom;
|
||||
}
|
||||
|
||||
@@ -7746,6 +7772,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
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);
|
||||
mIsDragging = true;
|
||||
break;
|
||||
|
||||
@@ -7754,8 +7782,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
final float rawY = ev.getRawY();
|
||||
final int[] coords = mTempCoords;
|
||||
TextView.this.getLocationOnScreen(coords);
|
||||
final int x = (int) (rawX - coords[0] + 0.5f);
|
||||
final int y = (int) (rawY - coords[1] + 0.5f);
|
||||
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;
|
||||
|
||||
mController.updatePosition(this, x, y);
|
||||
break;
|
||||
|
||||
@@ -8064,7 +8094,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
final int previousLine = layout.getLineForOffset(previousOffset);
|
||||
final int previousLineTop = layout.getLineTop(previousLine);
|
||||
final int previousLineBottom = layout.getLineBottom(previousLine);
|
||||
final int hysteresisThreshold = (previousLineBottom - previousLineTop) / 2;
|
||||
final int hysteresisThreshold = (previousLineBottom - previousLineTop) / 6;
|
||||
|
||||
// If new line is just before or after previous line and y position is less than
|
||||
// hysteresisThreshold away from previous line, keep cursor on previous line.
|
||||
|
||||
Reference in New Issue
Block a user