diff --git a/packages/Keyguard/res/layout-land/keyguard_host_view.xml b/packages/Keyguard/res/layout-land/keyguard_host_view.xml
index 87b8b59fad62c..eeb9ee7998c11 100644
--- a/packages/Keyguard/res/layout-land/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-land/keyguard_host_view.xml
@@ -51,6 +51,11 @@
androidprv:layout_maxHeight="480dp" />
+
+
+
+
+
+
CREATOR
@@ -1391,6 +1391,7 @@ public class KeyguardHostView extends KeyguardViewBase {
&& mAppWidgetContainer.getWidgetPageIndex(mTransportControl) >= 0;
ss.transportState = showing ? TRANSPORT_VISIBLE : mTransportState;
ss.appWidgetToShow = mAppWidgetToShow;
+ ss.insets.set(mInsets);
return ss;
}
@@ -1404,10 +1405,23 @@ public class KeyguardHostView extends KeyguardViewBase {
super.onRestoreInstanceState(ss.getSuperState());
mTransportState = (ss.transportState);
mAppWidgetToShow = ss.appWidgetToShow;
+ setInsets(ss.insets);
if (DEBUG) Log.d(TAG, "onRestoreInstanceState, transport=" + mTransportState);
post(mSwitchPageRunnable);
}
+ @Override
+ protected boolean fitSystemWindows(Rect insets) {
+ setInsets(insets);
+ return true;
+ }
+
+ private void setInsets(Rect insets) {
+ mInsets.set(insets);
+ if (mSlidingChallengeLayout != null) mSlidingChallengeLayout.setInsets(mInsets);
+ if (mMultiPaneChallengeLayout != null) mMultiPaneChallengeLayout.setInsets(mInsets);
+ }
+
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
index a0e44d75247c9..910ad9dc980d4 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
@@ -139,6 +139,7 @@ public class KeyguardViewManager {
class ViewManagerHost extends FrameLayout {
private static final int BACKGROUND_COLOR = 0x70000000;
+
// This is a faster way to draw the background on devices without hardware acceleration
private final Drawable mBackgroundDrawable = new Drawable() {
@Override
@@ -159,54 +160,10 @@ public class KeyguardViewManager {
return PixelFormat.TRANSLUCENT;
}
};
- private final View mScrimView;
- private boolean mExtendIntoPadding;
- public ViewManagerHost(Context context, boolean extendIntoPadding) {
+
+ public ViewManagerHost(Context context) {
super(context);
- mExtendIntoPadding = extendIntoPadding;
- setFitsSystemWindows(true);
- setClipToPadding(!mExtendIntoPadding);
setBackground(mBackgroundDrawable);
-
- mScrimView = new View(context);
- mScrimView.setVisibility(View.GONE);
- mScrimView.setBackgroundColor(0x99000000);
- addView(mScrimView);
- }
-
- private boolean considerPadding(View child) {
- return !mExtendIntoPadding || child instanceof KeyguardHostView;
- }
-
- @Override
- protected void measureChildWithMargins(View child,
- int parentWidthMeasureSpec, int widthUsed,
- int parentHeightMeasureSpec, int heightUsed) {
- if (considerPadding(child)) {
- // don't extend into padding (default behavior)
- super.measureChildWithMargins(child,
- parentWidthMeasureSpec, widthUsed,
- parentHeightMeasureSpec, heightUsed);
- } else {
- // allowed to extend into padding (scrim / camera preview)
- child.measure(parentWidthMeasureSpec, parentHeightMeasureSpec);
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- int cl = l, ct = t, cr = r, cb = b;
- if (considerPadding(child)) {
- cl += mPaddingLeft;
- ct += mPaddingTop;
- cr -= mPaddingRight;
- cb -= mPaddingBottom;
- }
- child.layout(cl, ct, cr, cb);
- }
}
@Override
@@ -252,7 +209,7 @@ public class KeyguardViewManager {
if (mKeyguardHost == null) {
if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");
- mKeyguardHost = new ViewManagerHost(mContext, shouldEnableTransparentBars());
+ mKeyguardHost = new ViewManagerHost(mContext);
int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
@@ -306,7 +263,6 @@ public class KeyguardViewManager {
mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
mKeyguardView.initializeSwitchingUserState(options != null &&
options.getBoolean(IS_SWITCHING_USER));
- mKeyguardView.setScrimView(mKeyguardHost.mScrimView);
// HACK
// The keyguard view will have set up window flags in onFinishInflate before we set
diff --git a/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java b/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
index 76a7fe3fa5108..67d0d5a67d714 100644
--- a/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
+++ b/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
@@ -28,6 +28,7 @@ import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
+import android.view.View.MeasureSpec;
import android.widget.LinearLayout;
public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayout {
@@ -47,6 +48,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
private final Rect mTempRect = new Rect();
private final Rect mZeroPadding = new Rect();
+ private final Rect mInsets = new Rect();
private final DisplayMetrics mDisplayMetrics;
@@ -80,6 +82,10 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ }
+
@Override
public boolean isChallengeShowing() {
return true;
@@ -187,7 +193,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
// This calculation is super dodgy and relies on several assumptions.
// Specifically that the root of the window will be padded in for insets
// and that the window is LAYOUT_IN_SCREEN.
- virtualHeight = mDisplayMetrics.heightPixels - root.getPaddingTop();
+ virtualHeight = mDisplayMetrics.heightPixels - root.getPaddingTop() - mInsets.top;
}
if (lp.childType == LayoutParams.CHILD_TYPE_WIDGET ||
lp.childType == LayoutParams.CHILD_TYPE_USER_SWITCHER) {
@@ -213,6 +219,9 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
final int height = MeasureSpec.getSize(heightSpec);
setMeasuredDimension(width, height);
+ final int insetHeight = height - mInsets.top - mInsets.bottom;
+ final int insetHeightSpec = MeasureSpec.makeMeasureSpec(insetHeight, MeasureSpec.EXACTLY);
+
int widthUsed = 0;
int heightUsed = 0;
@@ -245,14 +254,14 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
if (child.getVisibility() == GONE) continue;
int adjustedWidthSpec = widthSpec;
- int adjustedHeightSpec = heightSpec;
+ int adjustedHeightSpec = insetHeightSpec;
if (lp.maxWidth >= 0) {
adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
Math.min(lp.maxWidth, width), MeasureSpec.EXACTLY);
}
if (lp.maxHeight >= 0) {
adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
- Math.min(lp.maxHeight, height), MeasureSpec.EXACTLY);
+ Math.min(lp.maxHeight, insetHeight), MeasureSpec.EXACTLY);
}
// measureChildWithMargins will resolve layout direction for the LayoutParams
measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0);
@@ -282,7 +291,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
continue;
}
- final int virtualHeight = getVirtualHeight(lp, height, heightUsed);
+ final int virtualHeight = getVirtualHeight(lp, insetHeight, heightUsed);
int adjustedWidthSpec;
int adjustedHeightSpec;
@@ -330,11 +339,12 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
padding.bottom = getPaddingBottom();
final int width = r - l;
final int height = b - t;
+ final int insetHeight = height - mInsets.top - mInsets.bottom;
// Reserve extra space in layout for the user switcher by modifying
// local padding during this layout pass
if (mUserSwitcherView != null && mUserSwitcherView.getVisibility() != GONE) {
- layoutWithGravity(width, height, mUserSwitcherView, padding, true);
+ layoutWithGravity(width, insetHeight, mUserSwitcherView, padding, true);
}
final int count = getChildCount();
@@ -349,11 +359,11 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
child.layout(0, 0, width, height);
continue;
} else if (lp.childType == LayoutParams.CHILD_TYPE_PAGE_DELETE_DROP_TARGET) {
- layoutWithGravity(width, height, child, mZeroPadding, false);
+ layoutWithGravity(width, insetHeight, child, mZeroPadding, false);
continue;
}
- layoutWithGravity(width, height, child, padding, false);
+ layoutWithGravity(width, insetHeight, child, padding, false);
}
}
@@ -445,6 +455,8 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
right = left + childWidth;
break;
}
+ top += mInsets.top;
+ bottom += mInsets.top;
child.layout(left, top, right, bottom);
}
diff --git a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
index 4a4e7fa907e53..2e47768220d8d 100644
--- a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
+++ b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
@@ -24,6 +24,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.FloatProperty;
@@ -125,6 +126,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
private ObjectAnimator mFrameAnimation;
private boolean mHasGlowpad;
+ private final Rect mInsets = new Rect();
// We have an internal and external version, and we and them together.
private boolean mChallengeInteractiveExternal = true;
@@ -261,6 +263,10 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ }
+
public void setHandleAlpha(float alpha) {
if (mExpandChallengeView != null) {
mExpandChallengeView.setAlpha(alpha);
@@ -797,11 +803,13 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
throw new IllegalArgumentException(
"SlidingChallengeLayout must be measured with an exact size");
}
-
final int width = MeasureSpec.getSize(widthSpec);
final int height = MeasureSpec.getSize(heightSpec);
setMeasuredDimension(width, height);
+ final int insetHeight = height - mInsets.top - mInsets.bottom;
+ final int insetHeightSpec = MeasureSpec.makeMeasureSpec(insetHeight, MeasureSpec.EXACTLY);
+
// Find one and only one challenge view.
final View oldChallengeView = mChallengeView;
final View oldExpandChallengeView = mChallengeView;
@@ -861,13 +869,13 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
// 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;
+ int challengeHeightSpec = insetHeightSpec;
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 windowHeight = mDisplayMetrics.heightPixels
+ - root.getPaddingTop() - mInsets.top;
+ final int diff = windowHeight - insetHeight;
final int maxChallengeHeight = lp.maxHeight - diff;
if (maxChallengeHeight > 0) {
challengeHeightSpec = makeChildMeasureSpec(maxChallengeHeight, lp.height);
@@ -887,7 +895,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
// Measure children. Widget frame measures special, so that we can ignore
// insets for the IME.
- int parentWidthSpec = widthSpec, parentHeightSpec = heightSpec;
+ int parentWidthSpec = widthSpec, parentHeightSpec = insetHeightSpec;
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (lp.childType == LayoutParams.CHILD_TYPE_WIDGETS) {
final View root = getRootView();
@@ -896,12 +904,17 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
// Specifically that the root of the window will be padded in for insets
// and that the window is LAYOUT_IN_SCREEN.
final int windowWidth = mDisplayMetrics.widthPixels;
- final int windowHeight = mDisplayMetrics.heightPixels - root.getPaddingTop();
+ final int windowHeight = mDisplayMetrics.heightPixels
+ - root.getPaddingTop() - mInsets.top;
parentWidthSpec = MeasureSpec.makeMeasureSpec(
windowWidth, MeasureSpec.EXACTLY);
parentHeightSpec = MeasureSpec.makeMeasureSpec(
windowHeight, MeasureSpec.EXACTLY);
}
+ } else if (lp.childType == LayoutParams.CHILD_TYPE_SCRIM) {
+ // Allow scrim views to extend into the insets
+ parentWidthSpec = widthSpec;
+ parentHeightSpec = heightSpec;
}
measureChildWithMargins(child, parentWidthSpec, 0, parentHeightSpec, 0);
}
@@ -931,7 +944,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
final int childWidth = child.getMeasuredWidth();
final int childHeight = child.getMeasuredHeight();
final int left = center - childWidth / 2;
- final int layoutBottom = height - paddingBottom - lp.bottomMargin;
+ final int layoutBottom = height - paddingBottom - lp.bottomMargin - mInsets.bottom;
// We use the top of the challenge view to position the handle, so
// we never want less than the handle size showing at the bottom.
final int bottom = layoutBottom + (int) ((childHeight - mChallengeBottomBound)
@@ -942,15 +955,18 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
final int center = (paddingLeft + width - paddingRight) / 2;
final int left = center - child.getMeasuredWidth() / 2;
final int right = left + child.getMeasuredWidth();
- final int bottom = height - paddingBottom - lp.bottomMargin;
+ final int bottom = height - paddingBottom - lp.bottomMargin - mInsets.bottom;
final int top = bottom - child.getMeasuredHeight();
child.layout(left, top, right, bottom);
+ } else if (lp.childType == LayoutParams.CHILD_TYPE_SCRIM) {
+ // Scrim views use the entire area, including padding & insets
+ child.layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
} else {
// Non-challenge views lay out from the upper left, layered.
child.layout(paddingLeft + lp.leftMargin,
- paddingTop + lp.topMargin,
+ paddingTop + lp.topMargin + mInsets.top,
paddingLeft + child.getMeasuredWidth(),
- paddingTop + child.getMeasuredHeight());
+ paddingTop + child.getMeasuredHeight() + mInsets.top);
}
}
@@ -1076,7 +1092,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
final int layoutBottom = getLayoutBottom();
final int challengeHeight = mChallengeView.getMeasuredHeight();
- return layoutBottom - challengeHeight;
+ return layoutBottom - challengeHeight - mInsets.top;
}
/**
@@ -1125,7 +1141,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
final int bottomMargin = (mChallengeView == null)
? 0
: ((LayoutParams) mChallengeView.getLayoutParams()).bottomMargin;
- final int layoutBottom = getMeasuredHeight() - getPaddingBottom() - bottomMargin;
+ final int layoutBottom = getMeasuredHeight() - getPaddingBottom() - bottomMargin
+ - mInsets.bottom;
return layoutBottom;
}