summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2013-09-26 12:14:33 -0400
committerJohn Spurlock <jspurlock@google.com>2013-09-27 10:19:12 -0400
commit256ae67b9a629178b458dfc01102c9c0b9963d03 (patch)
treefeaadf5403de18e33cf8334252207f763c020a15 /packages
parent6a1e32efb686bd5606f62076c70f399ff3bdc37d (diff)
downloadframeworks_base-256ae67b9a629178b458dfc01102c9c0b9963d03.zip
frameworks_base-256ae67b9a629178b458dfc01102c9c0b9963d03.tar.gz
frameworks_base-256ae67b9a629178b458dfc01102c9c0b9963d03.tar.bz2
Restore scrim views to former place in view hierarchy.
By enabling KeyguardHostView to extend into the full screen area and updating custom measure/layout in the Challenge layouts appropriately. Bug:10939005 Change-Id: I06fb187c4100cf0f2e48b1206cc4450afa4567dd
Diffstat (limited to 'packages')
-rw-r--r--packages/Keyguard/res/layout-land/keyguard_host_view.xml5
-rw-r--r--packages/Keyguard/res/layout-port/keyguard_host_view.xml5
-rw-r--r--packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml5
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java24
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java52
-rw-r--r--packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java26
-rw-r--r--packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java43
7 files changed, 87 insertions, 73 deletions
diff --git a/packages/Keyguard/res/layout-land/keyguard_host_view.xml b/packages/Keyguard/res/layout-land/keyguard_host_view.xml
index 87b8b59..eeb9ee7 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" />
<include layout="@layout/keyguard_multi_user_selector"/>
+ <View android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ androidprv:layout_childType="scrim"
+ android:background="#99000000" />
+
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/res/layout-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-port/keyguard_host_view.xml
index 355739e..8498dcf 100644
--- a/packages/Keyguard/res/layout-port/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-port/keyguard_host_view.xml
@@ -55,6 +55,11 @@
android:layout_gravity="center"/>
</FrameLayout>
+ <View android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ androidprv:layout_childType="scrim"
+ android:background="#99000000" />
+
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
index 42dbe9d..77bc9b5 100644
--- a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
@@ -52,6 +52,11 @@
<include layout="@layout/keyguard_multi_user_selector"/>
+ <View android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ androidprv:layout_childType="scrim"
+ android:background="#99000000" />
+
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index aa43711..7e4e56c 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -127,6 +127,8 @@ public class KeyguardHostView extends KeyguardViewBase {
protected boolean mShowSecurityWhenReturn;
+ private final Rect mInsets = new Rect();
+
/*package*/ interface UserSwitcherCallback {
void hideSecurityView(int duration);
void showSecurityView();
@@ -402,11 +404,6 @@ public class KeyguardHostView extends KeyguardViewBase {
updateSecurityViews();
}
- public void setScrimView(View scrim) {
- if (mSlidingChallengeLayout != null) mSlidingChallengeLayout.setScrimView(scrim);
- if (mMultiPaneChallengeLayout != null) mMultiPaneChallengeLayout.setScrimView(scrim);
- }
-
private void setBackButtonEnabled(boolean enabled) {
if (mContext instanceof Activity) return; // always enabled in activity mode
setSystemUiVisibility(enabled ?
@@ -1348,6 +1345,7 @@ public class KeyguardHostView extends KeyguardViewBase {
static class SavedState extends BaseSavedState {
int transportState;
int appWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
+ Rect insets = new Rect();
SavedState(Parcelable superState) {
super(superState);
@@ -1357,6 +1355,7 @@ public class KeyguardHostView extends KeyguardViewBase {
super(in);
this.transportState = in.readInt();
this.appWidgetToShow = in.readInt();
+ this.insets = in.readParcelable(null);
}
@Override
@@ -1364,6 +1363,7 @@ public class KeyguardHostView extends KeyguardViewBase {
super.writeToParcel(out, flags);
out.writeInt(this.transportState);
out.writeInt(this.appWidgetToShow);
+ out.writeParcelable(insets, 0);
}
public static final Parcelable.Creator<SavedState> CREATOR
@@ -1388,6 +1388,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;
}
@@ -1401,11 +1402,24 @@ 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);
if (DEBUG) Log.d(TAG, "Window is " + (hasWindowFocus ? "focused" : "unfocused"));
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
index 177e0f8..6e6e2427 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 76a7fe3..67d0d5a 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 4a4e7fa..2e47768 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;
}