Driven by a new framework config bool. Tested on all layouts,
but disabled by default. Can be enabled with a config overlay.
(Sliding/MultiPane)ChallengeLayout have custom measure/layout
logic that peeks at the root view's padding (!). So we must keep
the root view's padding = system window insets. However, we need
the scrims + the fullscreen camera widget preview to use the entire
display size if the bars are transparent.
So the approach is to maintain the root view's
(KeyguardViewManager$ViewManagerHost) padding as before via
setFitsSystemWindows(true) but allow non KeyguardHostViews to
extend into the padding if bars are transparent via a custom
measure/draw on the root view.
KeyguardHostView background + challege scrims moved up to the
root view.
Also:
- Remove logspam line for fixed bug.
- Fix status bar staying opaque on interaction on secure keyguard.
Known issues:
- Nav bar blip dismissing global actions, keyguard app widget picker
bars are opaque. Both will use the new inherit flag once it exists.
- Emergency dialer layout dance, will be fixed in the phone project.
Bug:
10606085
Change-Id: I2648b4ee9a54a67324ce9dcbab976ad4da4bbcfa
<!-- Don't show lock screen before unlock screen (PIN/pattern/password) -->
<bool name="config_enableLockBeforeUnlockScreen">false</bool>
- <!-- Diable lockscreen rotation by default -->
+ <!-- Disable lockscreen rotation by default -->
<bool name="config_enableLockScreenRotation">false</bool>
+ <!-- Disable lockscreen transparent bars by default -->
+ <bool name="config_enableLockScreenTransparentBars">false</bool>
+
<!-- Enable puk unlockscreen by default.
If unlock screen is disabled, the puk should be unlocked through Emergency Dialer -->
<bool name="config_enable_puk_unlock_screen">true</bool>
<java-symbol type="bool" name="config_disableMenuKeyInLockScreen" />
<java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
<java-symbol type="bool" name="config_enableLockScreenRotation" />
+ <java-symbol type="bool" name="config_enableLockScreenTransparentBars" />
<java-symbol type="bool" name="config_lidControlsSleep" />
<java-symbol type="bool" name="config_reverseDefaultRotation" />
<java-symbol type="bool" name="config_showNavigationBar" />
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"
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"
<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"
<!-- Alias used to reference framework configuration for screen rotation. -->
<item type="bool" name="config_enableLockScreenRotation">@*android:bool/config_enableLockScreenRotation</item>
+ <!-- Alias used to reference framework configuration for transparent bars. -->
+ <item type="bool" name="config_enableLockScreenTransparentBars">@*android:bool/config_enableLockScreenTransparentBars</item>
+
<!-- Alias used to reference framework activity duration. -->
<item type="integer" name="config_activityDefaultDur">@*android:integer/config_activityDefaultDur</item>
}
private SlidingChallengeLayout mSlidingChallengeLayout;
+ private MultiPaneChallengeLayout mMultiPaneChallengeLayout;
@Override
public boolean onTouchEvent(MotionEvent ev) {
mAppWidgetContainer.setViewStateManager(mViewStateManager);
mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils);
+ mMultiPaneChallengeLayout =
+ (MultiPaneChallengeLayout) findViewById(R.id.multi_pane_challenge);
ChallengeLayout challenge = mSlidingChallengeLayout != null ? mSlidingChallengeLayout :
- (ChallengeLayout) findViewById(R.id.multi_pane_challenge);
+ mMultiPaneChallengeLayout;
challenge.setOnBouncerStateChangedListener(mViewStateManager);
mAppWidgetContainer.setBouncerAnimationDuration(challenge.getBouncerAnimationDuration());
mViewStateManager.setPagedView(mAppWidgetContainer);
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 ?
import android.app.Activity;
import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.ColorFilter;
-import android.graphics.PixelFormat;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.IAudioService;
import android.os.RemoteException;
*/
public abstract class KeyguardViewBase extends FrameLayout {
- private static final int BACKGROUND_COLOR = 0x70000000;
private AudioManager mAudioManager;
private TelephonyManager mTelephonyManager = null;
protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;
// the audio service will bring up the volume dialog.
private static final boolean KEYGUARD_MANAGES_VOLUME = true;
- // This is a faster way to draw the background on devices without hardware acceleration
- private static final Drawable mBackgroundDrawable = new Drawable() {
- @Override
- public void draw(Canvas canvas) {
- canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
- }
-
- @Override
- public void setAlpha(int alpha) {
- }
-
- @Override
- public void setColorFilter(ColorFilter cf) {
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
- };
-
public KeyguardViewBase(Context context) {
this(context, null);
}
public KeyguardViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
- resetBackground();
- }
-
- public void resetBackground() {
- setBackground(mBackgroundDrawable);
}
/**
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mNeedsInput = false;
- private FrameLayout mKeyguardHost;
+ private ViewManagerHost mKeyguardHost;
private KeyguardHostView mKeyguardView;
private boolean mScreenOn = false;
// useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED
// activities. Other disabled bits are handled by the KeyguardViewMediator talking
// directly to the status bar service.
- final int visFlags = View.STATUS_BAR_DISABLE_HOME;
+ int visFlags = View.STATUS_BAR_DISABLE_HOME;
+ if (shouldEnableTransparentBars()) {
+ visFlags |= View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS
+ | View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION;
+ }
if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")");
mKeyguardHost.setSystemUiVisibility(visFlags);
|| res.getBoolean(R.bool.config_enableLockScreenRotation);
}
+ private boolean shouldEnableTransparentBars() {
+ Resources res = mContext.getResources();
+ return res.getBoolean(R.bool.config_enableLockScreenTransparentBars);
+ }
+
class ViewManagerHost extends FrameLayout {
- public ViewManagerHost(Context context) {
+ 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
+ public void draw(Canvas canvas) {
+ canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter cf) {
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+ };
+ private final View mScrimView;
+ private boolean mExtendIntoPadding;
+ public ViewManagerHost(Context context, boolean extendIntoPadding) {
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 boolean fitSystemWindows(Rect insets) {
- Log.v("TAG", "bug 7643792: fitSystemWindows(" + insets.toShortString() + ")");
- return super.fitSystemWindows(insets);
+ 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
if (mKeyguardHost == null) {
if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");
- mKeyguardHost = new ViewManagerHost(mContext);
+ mKeyguardHost = new ViewManagerHost(mContext, shouldEnableTransparentBars());
int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
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
mScrimView.setOnClickListener(null);
}
mScrimView = scrim;
- mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f);
- mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE);
- mScrimView.setFocusable(true);
- mScrimView.setOnClickListener(mScrimClickListener);
+ if (mScrimView != null) {
+ mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f);
+ mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE);
+ mScrimView.setFocusable(true);
+ mScrimView.setOnClickListener(mScrimClickListener);
+ }
}
private int getVirtualHeight(LayoutParams lp, int height, int heightUsed) {
mScrimView.setOnClickListener(null);
}
mScrimView = scrim;
- mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE);
- mScrimView.setFocusable(true);
- mScrimView.setOnClickListener(mScrimClickListener);
+ if (mScrimView != null) {
+ mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE);
+ mScrimView.setFocusable(true);
+ mScrimView.setOnClickListener(mScrimClickListener);
+ }
}
/**
package com.android.systemui.statusbar.phone;
+import android.app.StatusBarManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
if (!handled) {
handled = super.onTouchEvent(ev);
}
+ final int action = ev.getAction();
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
+ mService.setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
+ }
return handled;
}