diff options
18 files changed, 207 insertions, 12 deletions
diff --git a/core/res/res/layout-land/keyguard_host_view.xml b/core/res/res/layout-land/keyguard_host_view.xml index be1d5b6c5ce6..2f6760611412 100644 --- a/core/res/res/layout-land/keyguard_host_view.xml +++ b/core/res/res/layout-land/keyguard_host_view.xml @@ -56,8 +56,8 @@ <com.android.internal.policy.impl.keyguard.KeyguardSecurityContainer android:id="@+id/keyguard_security_container" - android:layout_width="@dimen/keyguard_security_width" - android:layout_height="@dimen/keyguard_security_height" + android:layout_width="wrap_content" + android:layout_height="wrap_content" androidprv:layout_childType="challenge" androidprv:layout_centerWithinArea="0.55"> <com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper diff --git a/core/res/res/layout-port/keyguard_host_view.xml b/core/res/res/layout-port/keyguard_host_view.xml index b2bf3f147e41..73f07d587a94 100644 --- a/core/res/res/layout-port/keyguard_host_view.xml +++ b/core/res/res/layout-port/keyguard_host_view.xml @@ -62,7 +62,8 @@ <com.android.internal.policy.impl.keyguard.KeyguardSecurityContainer android:id="@+id/keyguard_security_container" android:layout_width="wrap_content" - android:layout_height="@dimen/keyguard_security_height" + android:layout_height="wrap_content" + android:layout_maxHeight="@dimen/keyguard_security_height" androidprv:layout_childType="challenge" android:padding="0dp" android:gravity="bottom|center_horizontal"> diff --git a/core/res/res/layout-sw600dp-port/keyguard_host_view.xml b/core/res/res/layout-sw600dp-port/keyguard_host_view.xml index 809104d6e0f2..a23771b6acb5 100644 --- a/core/res/res/layout-sw600dp-port/keyguard_host_view.xml +++ b/core/res/res/layout-sw600dp-port/keyguard_host_view.xml @@ -58,10 +58,8 @@ <com.android.internal.policy.impl.keyguard.KeyguardSecurityContainer android:id="@+id/keyguard_security_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - androidprv:layout_maxWidth="@dimen/keyguard_security_width" - androidprv:layout_maxHeight="@dimen/keyguard_security_height" + android:layout_width="wrap_content" + android:layout_height="wrap_content" androidprv:layout_centerWithinArea="0.5" androidprv:layout_childType="challenge" android:layout_gravity="center_horizontal|bottom"> diff --git a/core/res/res/layout/keyguard_account_view.xml b/core/res/res/layout/keyguard_account_view.xml index 78adfe754917..17175caa2dc8 100644 --- a/core/res/res/layout/keyguard_account_view.xml +++ b/core/res/res/layout/keyguard_account_view.xml @@ -21,6 +21,8 @@ android:id="@+id/keyguard_account_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:orientation="vertical"> <include layout="@layout/keyguard_message_area" diff --git a/core/res/res/layout/keyguard_face_unlock_view.xml b/core/res/res/layout/keyguard_face_unlock_view.xml index c1e35cf780d8..9f7efc4041bd 100644 --- a/core/res/res/layout/keyguard_face_unlock_view.xml +++ b/core/res/res/layout/keyguard_face_unlock_view.xml @@ -24,6 +24,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:contentDescription="@string/keyguard_accessibility_face_unlock"> <include layout="@layout/keyguard_message_area" diff --git a/core/res/res/layout/keyguard_password_view.xml b/core/res/res/layout/keyguard_password_view.xml index 2e2ada8eab1f..b9a05536afc2 100644 --- a/core/res/res/layout/keyguard_password_view.xml +++ b/core/res/res/layout/keyguard_password_view.xml @@ -22,6 +22,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:gravity="bottom" android:contentDescription="@string/keyguard_accessibility_password_unlock" > @@ -84,6 +86,13 @@ </LinearLayout> </FrameLayout> + + <Space + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + /> + <include layout="@layout/keyguard_emergency_carrier_area" android:id="@+id/keyguard_selector_fade_container" android:layout_width="match_parent" diff --git a/core/res/res/layout/keyguard_pattern_view.xml b/core/res/res/layout/keyguard_pattern_view.xml index 1c11fdd335ec..7eb7698aadea 100644 --- a/core/res/res/layout/keyguard_pattern_view.xml +++ b/core/res/res/layout/keyguard_pattern_view.xml @@ -26,6 +26,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:gravity="center_horizontal" android:contentDescription="@string/keyguard_accessibility_pattern_unlock"> diff --git a/core/res/res/layout/keyguard_pin_view.xml b/core/res/res/layout/keyguard_pin_view.xml index d486d5ec13f2..5c26a5321ba2 100644 --- a/core/res/res/layout/keyguard_pin_view.xml +++ b/core/res/res/layout/keyguard_pin_view.xml @@ -23,6 +23,8 @@ android:id="@+id/keyguard_pin_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:orientation="vertical" android:contentDescription="@string/keyguard_accessibility_pin_unlock" > diff --git a/core/res/res/layout/keyguard_selector_view.xml b/core/res/res/layout/keyguard_selector_view.xml index 941e78eb51dd..a36e80bd8ade 100644 --- a/core/res/res/layout/keyguard_selector_view.xml +++ b/core/res/res/layout/keyguard_selector_view.xml @@ -24,6 +24,8 @@ android:id="@+id/keyguard_selector_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:clipChildren="false" android:clipToPadding="false" android:orientation="vertical" diff --git a/core/res/res/layout/keyguard_sim_pin_view.xml b/core/res/res/layout/keyguard_sim_pin_view.xml index 67af6f9e7ad6..1c9c81e5516e 100644 --- a/core/res/res/layout/keyguard_sim_pin_view.xml +++ b/core/res/res/layout/keyguard_sim_pin_view.xml @@ -24,6 +24,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:gravity="center_horizontal"> <ImageView diff --git a/core/res/res/layout/keyguard_sim_puk_view.xml b/core/res/res/layout/keyguard_sim_puk_view.xml index b5731ecb1916..06bd0148c061 100644 --- a/core/res/res/layout/keyguard_sim_puk_view.xml +++ b/core/res/res/layout/keyguard_sim_puk_view.xml @@ -25,6 +25,8 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:gravity="center_horizontal"> <ImageView diff --git a/core/res/res/layout/keyguard_status_view.xml b/core/res/res/layout/keyguard_status_view.xml index 7467928f37d8..9e36df378f5c 100644 --- a/core/res/res/layout/keyguard_status_view.xml +++ b/core/res/res/layout/keyguard_status_view.xml @@ -23,6 +23,8 @@ android:id="@+id/keyguard_status_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_maxWidth="@dimen/keyguard_security_width" + android:layout_maxHeight="@dimen/keyguard_security_height" android:gravity="center_horizontal"> <com.android.internal.policy.impl.keyguard.KeyguardStatusView diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 6f307a7a4319..bd424b1f88d8 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -5819,6 +5819,7 @@ <declare-styleable name="SlidingChallengeLayout_Layout"> <attr name="layout_childType" /> + <attr name="layout_maxHeight" /> </declare-styleable> <!-- Attributes that can be used with <code><FragmentBreadCrumbs></code> @@ -5843,6 +5844,11 @@ <attr name="layout_maxHeight" /> </declare-styleable> + <declare-styleable name="KeyguardSecurityViewFlipper_Layout"> + <attr name="layout_maxWidth" /> + <attr name="layout_maxHeight" /> + </declare-styleable> + <declare-styleable name="NumPadKey"> <attr name="digit" format="integer" /> <attr name="textView" format="reference" /> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index b8ec138d8577..637128a53cae 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -246,7 +246,7 @@ <dimen name="kg_security_panel_height">600dp</dimen> <!-- Height of security view in keyguard. --> - <dimen name="kg_security_view_height">0dp</dimen> + <dimen name="kg_security_view_height">480dp</dimen> <!-- Width of widget view in keyguard. --> <dimen name="kg_widget_view_width">0dp</dimen> diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 1ee0e867d404..6fb84589d66f 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -688,7 +688,7 @@ public class KeyguardHostView extends KeyguardViewBase { if (view == null && layoutId != 0) { final LayoutInflater inflater = LayoutInflater.from(mContext); if (DEBUG) Log.v(TAG, "inflating id = " + layoutId); - View v = inflater.inflate(layoutId, this, false); + View v = inflater.inflate(layoutId, mSecurityViewContainer, false); mSecurityViewContainer.addView(v); updateSecurityView(v); view = (KeyguardSecurityView)v; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewFlipper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewFlipper.java index c92c7911a0ad..f9b1756219e0 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewFlipper.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewFlipper.java @@ -17,13 +17,18 @@ package com.android.internal.policy.impl.keyguard; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Log; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.FrameLayout; import android.widget.ViewFlipper; +import com.android.internal.R; import com.android.internal.widget.LockPatternUtils; /** @@ -32,6 +37,9 @@ import com.android.internal.widget.LockPatternUtils; * */ public class KeyguardSecurityViewFlipper extends ViewFlipper implements KeyguardSecurityView { + private static final String TAG = "KeyguardSecurityViewFlipper"; + private static final boolean DEBUG = false; + private Rect mTempRect = new Rect(); public KeyguardSecurityViewFlipper(Context context) { @@ -149,4 +157,119 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard } } } + + @Override + protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { + return p instanceof LayoutParams; + } + + @Override + protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { + return p instanceof LayoutParams ? new LayoutParams((LayoutParams) p) : new LayoutParams(p); + } + + @Override + public LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + @Override + protected void onMeasure(int widthSpec, int heightSpec) { + final int widthMode = MeasureSpec.getMode(widthSpec); + final int heightMode = MeasureSpec.getMode(heightSpec); + if (DEBUG && widthMode != MeasureSpec.AT_MOST) { + Log.w(TAG, "onMeasure: widthSpec " + MeasureSpec.toString(widthSpec) + + " should be AT_MOST"); + } + if (DEBUG && heightMode != MeasureSpec.AT_MOST) { + Log.w(TAG, "onMeasure: heightSpec " + MeasureSpec.toString(heightSpec) + + " should be AT_MOST"); + } + + final int widthSize = MeasureSpec.getSize(widthSpec); + final int heightSize = MeasureSpec.getSize(heightSpec); + int maxWidth = widthSize; + int maxHeight = heightSize; + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (lp.maxWidth > 0 && lp.maxWidth < maxWidth) { + maxWidth = lp.maxWidth; + } + if (lp.maxHeight > 0 && lp.maxHeight < maxHeight) { + maxHeight = lp.maxHeight; + } + } + + final int wPadding = getPaddingLeft() + getPaddingRight(); + final int hPadding = getPaddingTop() + getPaddingBottom(); + maxWidth -= wPadding; + maxHeight -= hPadding; + + int width = widthMode == MeasureSpec.EXACTLY ? widthSize : 0; + int height = heightMode == MeasureSpec.EXACTLY ? heightSize : 0; + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + final int childWidthSpec = makeChildMeasureSpec(maxWidth, lp.width); + final int childHeightSpec = makeChildMeasureSpec(maxHeight, lp.height); + + child.measure(childWidthSpec, childHeightSpec); + + width = Math.max(width, Math.min(child.getMeasuredWidth(), widthSize)); + height = Math.max(height, Math.min(child.getMeasuredHeight(), heightSize)); + } + setMeasuredDimension(width, height); + } + + private int makeChildMeasureSpec(int maxSize, int childDimen) { + final int mode; + final int size; + switch (childDimen) { + case LayoutParams.WRAP_CONTENT: + mode = MeasureSpec.AT_MOST; + size = maxSize; + break; + case LayoutParams.MATCH_PARENT: + mode = MeasureSpec.EXACTLY; + size = maxSize; + break; + default: + mode = MeasureSpec.EXACTLY; + size = Math.min(maxSize, childDimen); + break; + } + return MeasureSpec.makeMeasureSpec(size, mode); + } + + public static class LayoutParams extends FrameLayout.LayoutParams { + public int maxWidth; + public int maxHeight; + + public LayoutParams(ViewGroup.LayoutParams other) { + super(other); + } + + public LayoutParams(LayoutParams other) { + super(other); + + maxWidth = other.maxWidth; + maxHeight = other.maxHeight; + } + + public LayoutParams(Context c, AttributeSet attrs) { + super(c, attrs); + + final TypedArray a = c.obtainStyledAttributes(attrs, + R.styleable.KeyguardSecurityViewFlipper_Layout, 0, 0); + maxWidth = a.getDimensionPixelSize( + R.styleable.KeyguardSecurityViewFlipper_Layout_layout_maxWidth, 0); + maxHeight = a.getDimensionPixelSize( + R.styleable.KeyguardSecurityViewFlipper_Layout_layout_maxHeight, 0); + a.recycle(); + } + } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java b/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java index 97e7f950d90e..7b4bd6ec637b 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java @@ -392,8 +392,8 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo break; case Gravity.BOTTOM: bottom = fixedLayoutVertical - ? height - padding.bottom - (adjustedHeight - childHeight) / 2 - : height - padding.bottom; + ? padding.top + height - (adjustedHeight - childHeight) / 2 + : padding.top + height; top = bottom - childHeight; if (adjustPadding && isVertical) { padding.bottom = height - top; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java b/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java index c709a5f9943d..6d7d0f03c6f6 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java @@ -754,6 +754,26 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout return horizOk && vertOk; } + private int makeChildMeasureSpec(int maxSize, int childDimen) { + final int mode; + final int size; + switch (childDimen) { + case LayoutParams.WRAP_CONTENT: + mode = MeasureSpec.AT_MOST; + size = maxSize; + break; + case LayoutParams.MATCH_PARENT: + mode = MeasureSpec.EXACTLY; + size = maxSize; + break; + default: + mode = MeasureSpec.EXACTLY; + size = Math.min(maxSize, childDimen); + break; + } + return MeasureSpec.makeMeasureSpec(size, mode); + } + @Override protected void onMeasure(int widthSpec, int heightSpec) { if (MeasureSpec.getMode(widthSpec) != MeasureSpec.EXACTLY || @@ -819,7 +839,25 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout // needs to do things its measure pass that are dependent on the challenge view // having been measured. if (mChallengeView != null && mChallengeView.getVisibility() != View.GONE) { - measureChildWithMargins(mChallengeView, widthSpec, 0, heightSpec, 0); + // This one's a little funny. If the IME is present - reported in the form + // of insets on the root view - we only give the challenge the space it would + // have had if the IME wasn't there in order to keep the rest of the layout stable. + // We base this on the layout_maxHeight on the challenge view. If it comes out + // negative or zero, either we didn't have a maxHeight or we're totally out of space, + // so give up and measure as if this rule weren't there. + int challengeHeightSpec = heightSpec; + final View root = getRootView(); + if (root != null) { + final LayoutParams lp = (LayoutParams) mChallengeView.getLayoutParams(); + final int specSize = MeasureSpec.getSize(heightSpec); + final int windowHeight = mDisplayMetrics.heightPixels - root.getPaddingTop(); + final int diff = windowHeight - specSize; + final int maxChallengeHeight = lp.maxHeight - diff; + if (maxChallengeHeight > 0) { + challengeHeightSpec = makeChildMeasureSpec(maxChallengeHeight, lp.height); + } + } + measureChildWithMargins(mChallengeView, widthSpec, 0, challengeHeightSpec, 0); } // Measure the rest of the children @@ -1151,6 +1189,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout public static final int CHILD_TYPE_WIDGETS = 5; public static final int CHILD_TYPE_EXPAND_CHALLENGE_HANDLE = 6; + public int maxHeight; + public LayoutParams() { this(MATCH_PARENT, WRAP_CONTENT); } @@ -1180,6 +1220,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout R.styleable.SlidingChallengeLayout_Layout); childType = a.getInt(R.styleable.SlidingChallengeLayout_Layout_layout_childType, CHILD_TYPE_NONE); + maxHeight = a.getDimensionPixelSize( + R.styleable.SlidingChallengeLayout_Layout_layout_maxHeight, 0); a.recycle(); } } |