Merge "Introduce transparent bars to the keyguard." into klp-dev

This commit is contained in:
John Spurlock
2013-09-23 20:37:29 +00:00
committed by Android (Google) Code Review
12 changed files with 114 additions and 63 deletions

View File

@ -582,9 +582,12 @@
<!-- Don't show lock screen before unlock screen (PIN/pattern/password) --> <!-- Don't show lock screen before unlock screen (PIN/pattern/password) -->
<bool name="config_enableLockBeforeUnlockScreen">false</bool> <bool name="config_enableLockBeforeUnlockScreen">false</bool>
<!-- Diable lockscreen rotation by default --> <!-- Disable lockscreen rotation by default -->
<bool name="config_enableLockScreenRotation">false</bool> <bool name="config_enableLockScreenRotation">false</bool>
<!-- Disable lockscreen transparent bars by default -->
<bool name="config_enableLockScreenTransparentBars">false</bool>
<!-- Enable puk unlockscreen by default. <!-- Enable puk unlockscreen by default.
If unlock screen is disabled, the puk should be unlocked through Emergency Dialer --> If unlock screen is disabled, the puk should be unlocked through Emergency Dialer -->
<bool name="config_enable_puk_unlock_screen">true</bool> <bool name="config_enable_puk_unlock_screen">true</bool>

View File

@ -1282,6 +1282,7 @@
<java-symbol type="bool" name="config_disableMenuKeyInLockScreen" /> <java-symbol type="bool" name="config_disableMenuKeyInLockScreen" />
<java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" /> <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
<java-symbol type="bool" name="config_enableLockScreenRotation" /> <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_lidControlsSleep" />
<java-symbol type="bool" name="config_reverseDefaultRotation" /> <java-symbol type="bool" name="config_reverseDefaultRotation" />
<java-symbol type="bool" name="config_showNavigationBar" /> <java-symbol type="bool" name="config_showNavigationBar" />

View File

@ -51,11 +51,6 @@
androidprv:layout_maxHeight="480dp" /> androidprv:layout_maxHeight="480dp" />
<include layout="@layout/keyguard_multi_user_selector"/> <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 <com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container" android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -55,11 +55,6 @@
android:layout_gravity="center"/> android:layout_gravity="center"/>
</FrameLayout> </FrameLayout>
<View android:layout_width="match_parent"
android:layout_height="match_parent"
androidprv:layout_childType="scrim"
android:background="#99000000" />
<com.android.keyguard.KeyguardSecurityContainer <com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container" android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -52,11 +52,6 @@
<include layout="@layout/keyguard_multi_user_selector"/> <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 <com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container" android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -46,6 +46,9 @@
<!-- Alias used to reference framework configuration for screen rotation. --> <!-- Alias used to reference framework configuration for screen rotation. -->
<item type="bool" name="config_enableLockScreenRotation">@*android:bool/config_enableLockScreenRotation</item> <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. --> <!-- Alias used to reference framework activity duration. -->
<item type="integer" name="config_activityDefaultDur">@*android:integer/config_activityDefaultDur</item> <item type="integer" name="config_activityDefaultDur">@*android:integer/config_activityDefaultDur</item>

View File

@ -319,6 +319,7 @@ public class KeyguardHostView extends KeyguardViewBase {
} }
private SlidingChallengeLayout mSlidingChallengeLayout; private SlidingChallengeLayout mSlidingChallengeLayout;
private MultiPaneChallengeLayout mMultiPaneChallengeLayout;
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
@ -372,8 +373,10 @@ public class KeyguardHostView extends KeyguardViewBase {
mAppWidgetContainer.setViewStateManager(mViewStateManager); mAppWidgetContainer.setViewStateManager(mViewStateManager);
mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils); mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils);
mMultiPaneChallengeLayout =
(MultiPaneChallengeLayout) findViewById(R.id.multi_pane_challenge);
ChallengeLayout challenge = mSlidingChallengeLayout != null ? mSlidingChallengeLayout : ChallengeLayout challenge = mSlidingChallengeLayout != null ? mSlidingChallengeLayout :
(ChallengeLayout) findViewById(R.id.multi_pane_challenge); mMultiPaneChallengeLayout;
challenge.setOnBouncerStateChangedListener(mViewStateManager); challenge.setOnBouncerStateChangedListener(mViewStateManager);
mAppWidgetContainer.setBouncerAnimationDuration(challenge.getBouncerAnimationDuration()); mAppWidgetContainer.setBouncerAnimationDuration(challenge.getBouncerAnimationDuration());
mViewStateManager.setPagedView(mAppWidgetContainer); mViewStateManager.setPagedView(mAppWidgetContainer);
@ -399,6 +402,11 @@ public class KeyguardHostView extends KeyguardViewBase {
updateSecurityViews(); updateSecurityViews();
} }
public void setScrimView(View scrim) {
if (mSlidingChallengeLayout != null) mSlidingChallengeLayout.setScrimView(scrim);
if (mMultiPaneChallengeLayout != null) mMultiPaneChallengeLayout.setScrimView(scrim);
}
private void setBackButtonEnabled(boolean enabled) { private void setBackButtonEnabled(boolean enabled) {
if (mContext instanceof Activity) return; // always enabled in activity mode if (mContext instanceof Activity) return; // always enabled in activity mode
setSystemUiVisibility(enabled ? setSystemUiVisibility(enabled ?

View File

@ -18,11 +18,6 @@ package com.android.keyguard;
import android.app.Activity; import android.app.Activity;
import android.content.Context; 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.AudioManager;
import android.media.IAudioService; import android.media.IAudioService;
import android.os.RemoteException; import android.os.RemoteException;
@ -45,7 +40,6 @@ import android.widget.FrameLayout;
*/ */
public abstract class KeyguardViewBase extends FrameLayout { public abstract class KeyguardViewBase extends FrameLayout {
private static final int BACKGROUND_COLOR = 0x70000000;
private AudioManager mAudioManager; private AudioManager mAudioManager;
private TelephonyManager mTelephonyManager = null; private TelephonyManager mTelephonyManager = null;
protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback; protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;
@ -55,38 +49,12 @@ public abstract class KeyguardViewBase extends FrameLayout {
// the audio service will bring up the volume dialog. // the audio service will bring up the volume dialog.
private static final boolean KEYGUARD_MANAGES_VOLUME = true; 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) { public KeyguardViewBase(Context context) {
this(context, null); this(context, null);
} }
public KeyguardViewBase(Context context, AttributeSet attrs) { public KeyguardViewBase(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
resetBackground();
}
public void resetBackground() {
setBackground(mBackgroundDrawable);
} }
/** /**

View File

@ -26,8 +26,12 @@ import android.content.Context;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.Parcelable; import android.os.Parcelable;
@ -67,7 +71,7 @@ public class KeyguardViewManager {
private WindowManager.LayoutParams mWindowLayoutParams; private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mNeedsInput = false; private boolean mNeedsInput = false;
private FrameLayout mKeyguardHost; private ViewManagerHost mKeyguardHost;
private KeyguardHostView mKeyguardView; private KeyguardHostView mKeyguardView;
private boolean mScreenOn = false; private boolean mScreenOn = false;
@ -108,7 +112,11 @@ public class KeyguardViewManager {
// useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED // 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 // activities. Other disabled bits are handled by the KeyguardViewMediator talking
// directly to the status bar service. // 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)+")"); if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")");
mKeyguardHost.setSystemUiVisibility(visFlags); mKeyguardHost.setSystemUiVisibility(visFlags);
@ -124,16 +132,81 @@ public class KeyguardViewManager {
|| res.getBoolean(R.bool.config_enableLockScreenRotation); || res.getBoolean(R.bool.config_enableLockScreenRotation);
} }
private boolean shouldEnableTransparentBars() {
Resources res = mContext.getResources();
return res.getBoolean(R.bool.config_enableLockScreenTransparentBars);
}
class ViewManagerHost extends FrameLayout { class ViewManagerHost extends FrameLayout {
public ViewManagerHost(Context context) { private static final int BACKGROUND_COLOR = 0x70000000;
super(context); // This is a faster way to draw the background on devices without hardware acceleration
setFitsSystemWindows(true); private final Drawable mBackgroundDrawable = new Drawable() {
@Override
public void draw(Canvas canvas) {
canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
} }
@Override @Override
protected boolean fitSystemWindows(Rect insets) { public void setAlpha(int alpha) {
Log.v("TAG", "bug 7643792: fitSystemWindows(" + insets.toShortString() + ")"); }
return super.fitSystemWindows(insets);
@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 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 @Override
@ -179,7 +252,7 @@ public class KeyguardViewManager {
if (mKeyguardHost == null) { if (mKeyguardHost == null) {
if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); 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 int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
@ -233,6 +306,7 @@ public class KeyguardViewManager {
mKeyguardView.setViewMediatorCallback(mViewMediatorCallback); mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
mKeyguardView.initializeSwitchingUserState(options != null && mKeyguardView.initializeSwitchingUserState(options != null &&
options.getBoolean(IS_SWITCHING_USER)); options.getBoolean(IS_SWITCHING_USER));
mKeyguardView.setScrimView(mKeyguardHost.mScrimView);
// HACK // HACK
// The keyguard view will have set up window flags in onFinishInflate before we set // The keyguard view will have set up window flags in onFinishInflate before we set

View File

@ -172,11 +172,13 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
mScrimView.setOnClickListener(null); mScrimView.setOnClickListener(null);
} }
mScrimView = scrim; mScrimView = scrim;
if (mScrimView != null) {
mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f); mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f);
mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE); mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE);
mScrimView.setFocusable(true); mScrimView.setFocusable(true);
mScrimView.setOnClickListener(mScrimClickListener); mScrimView.setOnClickListener(mScrimClickListener);
} }
}
private int getVirtualHeight(LayoutParams lp, int height, int heightUsed) { private int getVirtualHeight(LayoutParams lp, int height, int heightUsed) {
int virtualHeight = height; int virtualHeight = height;

View File

@ -367,10 +367,12 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
mScrimView.setOnClickListener(null); mScrimView.setOnClickListener(null);
} }
mScrimView = scrim; mScrimView = scrim;
if (mScrimView != null) {
mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE); mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE);
mScrimView.setFocusable(true); mScrimView.setFocusable(true);
mScrimView.setOnClickListener(mScrimClickListener); mScrimView.setOnClickListener(mScrimClickListener);
} }
}
/** /**
* Animate the bottom edge of the challenge view to the given position. * Animate the bottom edge of the challenge view to the given position.

View File

@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone; package com.android.systemui.statusbar.phone;
import android.app.StatusBarManager;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -111,6 +112,10 @@ public class StatusBarWindowView extends FrameLayout
if (!handled) { if (!handled) {
handled = super.onTouchEvent(ev); 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; return handled;
} }