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) -->
<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>

View File

@ -1282,6 +1282,7 @@
<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" />

View File

@ -51,11 +51,6 @@
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"

View File

@ -55,11 +55,6 @@
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"

View File

@ -52,11 +52,6 @@
<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"

View File

@ -46,6 +46,9 @@
<!-- 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>

View File

@ -319,6 +319,7 @@ public class KeyguardHostView extends KeyguardViewBase {
}
private SlidingChallengeLayout mSlidingChallengeLayout;
private MultiPaneChallengeLayout mMultiPaneChallengeLayout;
@Override
public boolean onTouchEvent(MotionEvent ev) {
@ -372,8 +373,10 @@ public class KeyguardHostView extends KeyguardViewBase {
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);
@ -399,6 +402,11 @@ 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 ?

View File

@ -18,11 +18,6 @@ package com.android.keyguard;
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;
@ -45,7 +40,6 @@ import android.widget.FrameLayout;
*/
public abstract class KeyguardViewBase extends FrameLayout {
private static final int BACKGROUND_COLOR = 0x70000000;
private AudioManager mAudioManager;
private TelephonyManager mTelephonyManager = null;
protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;
@ -55,38 +49,12 @@ public abstract class KeyguardViewBase extends FrameLayout {
// 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);
}
/**

View File

@ -26,8 +26,12 @@ import android.content.Context;
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;
@ -67,7 +71,7 @@ public class KeyguardViewManager {
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mNeedsInput = false;
private FrameLayout mKeyguardHost;
private ViewManagerHost mKeyguardHost;
private KeyguardHostView mKeyguardView;
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
// 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);
@ -124,16 +132,81 @@ public class KeyguardViewManager {
|| 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 boolean fitSystemWindows(Rect insets) {
Log.v("TAG", "bug 7643792: fitSystemWindows(" + insets.toShortString() + ")");
return super.fitSystemWindows(insets);
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
@ -179,7 +252,7 @@ public class KeyguardViewManager {
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
@ -233,6 +306,7 @@ 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

View File

@ -172,10 +172,12 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
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) {

View File

@ -367,9 +367,11 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
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);
}
}
/**

View File

@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
import android.app.StatusBarManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@ -111,6 +112,10 @@ public class StatusBarWindowView extends FrameLayout
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;
}