Merge "Fix text anchors" into gingerbread
This commit is contained in:
@@ -86,6 +86,7 @@ public class PopupWindow {
|
|||||||
private boolean mOutsideTouchable = false;
|
private boolean mOutsideTouchable = false;
|
||||||
private boolean mClippingEnabled = true;
|
private boolean mClippingEnabled = true;
|
||||||
private boolean mSplitTouchEnabled;
|
private boolean mSplitTouchEnabled;
|
||||||
|
private boolean mLayoutInScreen;
|
||||||
|
|
||||||
private OnTouchListener mTouchInterceptor;
|
private OnTouchListener mTouchInterceptor;
|
||||||
|
|
||||||
@@ -595,6 +596,29 @@ public class PopupWindow {
|
|||||||
mSplitTouchEnabled = enabled;
|
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
|
* <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
|
* 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_NOT_TOUCHABLE |
|
||||||
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
|
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
|
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) {
|
if(mIgnoreCheekPress) {
|
||||||
curFlags |= WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
|
curFlags |= WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
|
||||||
}
|
}
|
||||||
@@ -923,6 +948,9 @@ public class PopupWindow {
|
|||||||
if (mSplitTouchEnabled) {
|
if (mSplitTouchEnabled) {
|
||||||
curFlags |= WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
|
curFlags |= WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
|
||||||
}
|
}
|
||||||
|
if (mLayoutInScreen) {
|
||||||
|
curFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||||
|
}
|
||||||
return curFlags;
|
return curFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3768,6 +3768,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (mError != null) {
|
if (mError != null) {
|
||||||
hideError();
|
hideError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4118,6 +4120,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
|
||||||
|
if (mInsertionPointCursorController != null &&
|
||||||
|
mInsertionPointCursorController.isShowing()) {
|
||||||
|
mInsertionPointCursorController.updatePosition();
|
||||||
|
}
|
||||||
|
if (mSelectionModifierCursorController != null &&
|
||||||
|
mSelectionModifierCursorController.isShowing()) {
|
||||||
|
mSelectionModifierCursorController.updatePosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4736,6 +4747,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (mInputMethodState != null) {
|
if (mInputMethodState != null) {
|
||||||
mInputMethodState.mExtracting = req;
|
mInputMethodState.mExtracting = req;
|
||||||
}
|
}
|
||||||
|
hideControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6266,7 +6278,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
sendOnTextChanged(buffer, start, before, after);
|
sendOnTextChanged(buffer, start, before, after);
|
||||||
onTextChanged(buffer, start, before, after);
|
onTextChanged(buffer, start, before, after);
|
||||||
hideControllers();
|
|
||||||
|
// Hide the controller if the amount of content changed
|
||||||
|
if (before != after) {
|
||||||
|
hideControllers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6605,11 +6621,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (mInputContentType != null) {
|
if (mInputContentType != null) {
|
||||||
mInputContentType.enterDown = false;
|
mInputContentType.enterDown = false;
|
||||||
}
|
}
|
||||||
|
hideControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
startStopMarquee(hasWindowFocus);
|
startStopMarquee(hasWindowFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||||
|
super.onVisibilityChanged(changedView, visibility);
|
||||||
|
if (visibility != VISIBLE) {
|
||||||
|
hideControllers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use {@link BaseInputConnection#removeComposingSpans
|
* Use {@link BaseInputConnection#removeComposingSpans
|
||||||
* BaseInputConnection.removeComposingSpans()} to remove any IME composing
|
* BaseInputConnection.removeComposingSpans()} to remove any IME composing
|
||||||
@@ -6679,8 +6704,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
startTextSelectionMode();
|
startTextSelectionMode();
|
||||||
} else if (mInsertionPointCursorController != null) {
|
|
||||||
mInsertionPointCursorController.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7645,6 +7668,8 @@ 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 int mOffsetY;
|
||||||
|
|
||||||
public HandleView(CursorController controller, Drawable handle) {
|
public HandleView(CursorController controller, Drawable handle) {
|
||||||
super(TextView.this.mContext);
|
super(TextView.this.mContext);
|
||||||
@@ -7653,6 +7678,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
mContainer = new PopupWindow(TextView.this.mContext, null,
|
mContainer = new PopupWindow(TextView.this.mContext, null,
|
||||||
com.android.internal.R.attr.textSelectHandleWindowStyle);
|
com.android.internal.R.attr.textSelectHandleWindowStyle);
|
||||||
mContainer.setSplitTouchEnabled(true);
|
mContainer.setSplitTouchEnabled(true);
|
||||||
|
mContainer.setClippingEnabled(false);
|
||||||
|
mContainer.setLayoutInScreenEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -7690,19 +7717,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
final int compoundPaddingRight = getCompoundPaddingRight();
|
final int compoundPaddingRight = getCompoundPaddingRight();
|
||||||
|
|
||||||
final TextView hostView = TextView.this;
|
final TextView hostView = TextView.this;
|
||||||
final int right = hostView.mRight;
|
final int handleWidth = mDrawable.getIntrinsicWidth();
|
||||||
final int left = hostView.mLeft;
|
final int left = 0;
|
||||||
final int bottom = hostView.mBottom;
|
final int right = hostView.getWidth();
|
||||||
final int top = hostView.mTop;
|
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 clipTop = top + extendedPaddingTop;
|
||||||
final int clipRight = right - compoundPaddingRight;
|
final int clipRight = right - compoundPaddingRight + (int) (handleWidth * 0.25f);
|
||||||
final int clipBottom = bottom - extendedPaddingBottom;
|
final int clipBottom = bottom - extendedPaddingBottom;
|
||||||
|
|
||||||
final int handleWidth = mDrawable.getIntrinsicWidth();
|
return mPositionX >= clipLeft && mPositionX <= clipRight &&
|
||||||
return mPositionX >= clipLeft - handleWidth * 0.75f &&
|
|
||||||
mPositionX <= clipRight + handleWidth * 0.25f &&
|
|
||||||
mPositionY >= clipTop && mPositionY <= clipBottom;
|
mPositionY >= clipTop && mPositionY <= clipBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7741,6 +7767,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
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;
|
mIsDragging = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -7749,8 +7777,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
final float rawY = ev.getRawY();
|
final float rawY = ev.getRawY();
|
||||||
final int[] coords = mTempCoords;
|
final int[] coords = mTempCoords;
|
||||||
TextView.this.getLocationOnScreen(coords);
|
TextView.this.getLocationOnScreen(coords);
|
||||||
final int x = (int) (rawX - coords[0] + 0.5f);
|
final int x = (int) (rawX - coords[0] + 0.5f) - mOffsetX;
|
||||||
final int y = (int) (rawY - coords[1] + 0.5f);
|
final int y = (int) (rawY - coords[1] + 0.5f) -
|
||||||
|
(int) (mDrawable.getIntrinsicHeight() * 0.8f) - mOffsetY;
|
||||||
|
|
||||||
mController.updatePosition(this, x, y);
|
mController.updatePosition(this, x, y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -8059,7 +8089,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
final int previousLine = layout.getLineForOffset(previousOffset);
|
final int previousLine = layout.getLineForOffset(previousOffset);
|
||||||
final int previousLineTop = layout.getLineTop(previousLine);
|
final int previousLineTop = layout.getLineTop(previousLine);
|
||||||
final int previousLineBottom = layout.getLineBottom(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
|
// 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.
|
// hysteresisThreshold away from previous line, keep cursor on previous line.
|
||||||
|
|||||||
Reference in New Issue
Block a user