diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/FragmentBreadCrumbs.java | 64 | ||||
-rw-r--r-- | core/java/android/os/UserManager.java | 2 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewClassic.java | 41 |
3 files changed, 86 insertions, 21 deletions
diff --git a/core/java/android/app/FragmentBreadCrumbs.java b/core/java/android/app/FragmentBreadCrumbs.java index df64035..b810b89 100644 --- a/core/java/android/app/FragmentBreadCrumbs.java +++ b/core/java/android/app/FragmentBreadCrumbs.java @@ -19,7 +19,9 @@ package android.app; import android.animation.LayoutTransition; import android.app.FragmentManager.BackStackEntry; import android.content.Context; +import android.content.res.TypedArray; import android.util.AttributeSet; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -51,7 +53,11 @@ public class FragmentBreadCrumbs extends ViewGroup private OnClickListener mParentClickListener; private OnBreadCrumbClickListener mOnBreadCrumbClickListener; - + + private int mGravity; + + private static final int DEFAULT_GRAVITY = Gravity.START | Gravity.CENTER_VERTICAL; + /** * Interface to intercept clicks on the bread crumbs. */ @@ -80,6 +86,14 @@ public class FragmentBreadCrumbs extends ViewGroup public FragmentBreadCrumbs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.FragmentBreadCrumbs, defStyle, 0); + + mGravity = a.getInt(com.android.internal.R.styleable.FragmentBreadCrumbs_gravity, + DEFAULT_GRAVITY); + + a.recycle(); } /** @@ -159,16 +173,50 @@ public class FragmentBreadCrumbs extends ViewGroup @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { - // Eventually we should implement our own layout of the views, - // rather than relying on a linear layout. + // Eventually we should implement our own layout of the views, rather than relying on + // a single linear layout. final int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); + if (childCount == 0) { + return; + } + + final View child = getChildAt(0); - int childRight = mPaddingLeft + child.getMeasuredWidth() - mPaddingRight; - int childBottom = mPaddingTop + child.getMeasuredHeight() - mPaddingBottom; - child.layout(mPaddingLeft, mPaddingTop, childRight, childBottom); + final int childTop = mPaddingTop; + final int childBottom = mPaddingTop + child.getMeasuredHeight() - mPaddingBottom; + + int childLeft; + int childRight; + + final int layoutDirection = getLayoutDirection(); + final int horizontalGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK; + switch (Gravity.getAbsoluteGravity(horizontalGravity, layoutDirection)) { + case Gravity.RIGHT: + childRight = mRight - mLeft - mPaddingRight; + childLeft = childRight - child.getMeasuredWidth(); + break; + + case Gravity.CENTER_HORIZONTAL: + childLeft = mPaddingLeft + (mRight - mLeft - child.getMeasuredWidth()) / 2; + childRight = childLeft + child.getMeasuredWidth(); + break; + + case Gravity.LEFT: + default: + childLeft = mPaddingLeft; + childRight = childLeft + child.getMeasuredWidth(); + break; } + + if (childLeft < mPaddingLeft) { + childLeft = mPaddingLeft; + } + + if (childRight > mRight - mLeft - mPaddingRight) { + childRight = mRight - mLeft - mPaddingRight; + } + + child.layout(childLeft, childTop, childRight, childBottom); } @Override diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 2739cac..898c766 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -320,6 +320,8 @@ public class UserManager { * @return a value greater than or equal to 1 */ public static int getMaxSupportedUsers() { + // Don't allow multiple users on certain builds + if (android.os.Build.ID.startsWith("JVP")) return 1; return SystemProperties.getInt("fw.max_users", Resources.getSystem().getInteger(R.integer.config_multiuserMaximumUsers)); } diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java index 6a505e1..0f8966e 100644 --- a/core/java/android/webkit/WebViewClassic.java +++ b/core/java/android/webkit/WebViewClassic.java @@ -5187,7 +5187,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc if (cm.hasPrimaryClip()) { Point cursorPoint = new Point(contentToViewX(mSelectCursorBase.x), contentToViewY(mSelectCursorBase.y)); - Point cursorTop = calculateCaretTop(); + Point cursorTop = calculateBaseCaretTop(); cursorTop.set(contentToViewX(cursorTop.x), contentToViewY(cursorTop.y)); @@ -5231,17 +5231,22 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc return scale; } + private Point calculateBaseCaretTop() { + return calculateCaretTop(mSelectCursorBase, mSelectCursorBaseTextQuad); + } + + private Point calculateDraggingCaretTop() { + return calculateCaretTop(mSelectDraggingCursor, mSelectDraggingTextQuad); + } + /** * Assuming arbitrary shape of a quadralateral forming text bounds, this * calculates the top of a caret. */ - private Point calculateCaretTop() { - float scale = scaleAlongSegment(mSelectCursorBase.x, mSelectCursorBase.y, - mSelectCursorBaseTextQuad.p4, mSelectCursorBaseTextQuad.p3); - int x = Math.round(scaleCoordinate(scale, - mSelectCursorBaseTextQuad.p1.x, mSelectCursorBaseTextQuad.p2.x)); - int y = Math.round(scaleCoordinate(scale, - mSelectCursorBaseTextQuad.p1.y, mSelectCursorBaseTextQuad.p2.y)); + private static Point calculateCaretTop(Point base, QuadF quad) { + float scale = scaleAlongSegment(base.x, base.y, quad.p4, quad.p3); + int x = Math.round(scaleCoordinate(scale, quad.p1.x, quad.p2.x)); + int y = Math.round(scaleCoordinate(scale, quad.p1.y, quad.p2.y)); return new Point(x, y); } @@ -5271,12 +5276,20 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc return true; } - private void updateWebkitSelection() { + private void updateWebkitSelection(boolean isSnapped) { int handleId = (mSelectDraggingCursor == mSelectCursorBase) ? HANDLE_ID_BASE : HANDLE_ID_EXTENT; + int x = mSelectDraggingCursor.x; + int y = mSelectDraggingCursor.y; + if (isSnapped) { + // "center" the cursor in the snapping quad + Point top = calculateDraggingCaretTop(); + x = Math.round((top.x + x) / 2); + y = Math.round((top.y + y) / 2); + } mWebViewCore.removeMessages(EventHub.SELECT_TEXT); mWebViewCore.sendMessageAtFrontOfQueue(EventHub.SELECT_TEXT, - mSelectDraggingCursor.x, mSelectDraggingCursor.y, (Integer)handleId); + x, y, (Integer)handleId); } private void resetCaretTimer() { @@ -5614,7 +5627,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc Math.max(0, mEditTextContentBounds.top - buffer), mEditTextContentBounds.right + buffer, mEditTextContentBounds.bottom + buffer); - Point caretTop = calculateCaretTop(); + Point caretTop = calculateBaseCaretTop(); if (visibleRect.width() < mEditTextContentBounds.width()) { // The whole edit won't fit in the width, so use the caret rect if (mSelectCursorBase.x < caretTop.x) { @@ -5945,10 +5958,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc } else { endScrollEdit(); } + boolean snapped = false; if (inCursorText || (mIsEditingText && !inEditBounds)) { snapDraggingCursor(); + snapped = true; } - updateWebkitSelection(); + updateWebkitSelection(snapped); if (!inCursorText && mIsEditingText && inEditBounds) { // Visually snap even if we have moved the handle. snapDraggingCursor(); @@ -6275,7 +6290,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc int oldX = mSelectDraggingCursor.x; int oldY = mSelectDraggingCursor.y; mSelectDraggingCursor.set(selectionX, selectionY); - updateWebkitSelection(); + updateWebkitSelection(false); scrollEditText(scrollX, scrollY); mSelectDraggingCursor.set(oldX, oldY); } |