diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index fc2dc023f02d6..4eab9c73a42b2 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -50,12 +50,8 @@ android:visibility="gone" /> - - @@ -97,8 +94,9 @@ + + diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index 2d82d6e3d6ffc..7cdc078e2aa61 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -72,9 +72,6 @@ 24dp - - 20dp - 80dp 120dp diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 1cdcc2bf052bc..c3ea8f841072b 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -103,4 +103,6 @@ #FFFFFFFF #ffffff + + #77000000 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 6af2cf8d11f2b..e6b38184c280c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -44,6 +44,7 @@ import com.android.systemui.statusbar.GestureRecorder; import com.android.systemui.statusbar.KeyguardAffordanceView; import com.android.systemui.statusbar.MirrorView; import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.stack.StackStateAnimator; @@ -62,6 +63,7 @@ public class NotificationPanelView extends PanelView implements private KeyguardAffordanceHelper mAfforanceHelper; private StatusBarHeaderView mHeader; + private KeyguardUserSwitcher mKeyguardUserSwitcher; private KeyguardStatusBarView mKeyguardStatusBar; private View mQsContainer; private QSPanel mQsPanel; @@ -225,11 +227,18 @@ public class NotificationPanelView extends PanelView implements mHeader.post(mUpdateHeader); } - lp = (FrameLayout.LayoutParams) mNotificationContainerParent.getLayoutParams(); + lp = (FrameLayout.LayoutParams) mNotificationStackScroller.getLayoutParams(); if (lp.width != panelWidth) { lp.width = panelWidth; lp.gravity = panelGravity; - mNotificationContainerParent.setLayoutParams(lp); + mNotificationStackScroller.setLayoutParams(lp); + } + + lp = (FrameLayout.LayoutParams) mScrollView.getLayoutParams(); + if (lp.width != panelWidth) { + lp.width = panelWidth; + lp.gravity = panelGravity; + mScrollView.setLayoutParams(lp); } } @@ -939,6 +948,9 @@ public class NotificationPanelView extends PanelView implements && !mStackScrollerOverscrolling && mQsScrimEnabled ? View.VISIBLE : View.INVISIBLE); + if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) { + mKeyguardUserSwitcher.hide(); + } } private void setQsExpansion(float height) { @@ -1704,6 +1716,10 @@ public class NotificationPanelView extends PanelView implements } } + public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { + mKeyguardUserSwitcher = keyguardUserSwitcher; + } + private final Runnable mUpdateHeader = new Runnable() { @Override public void run() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java index 7c6e47cf257aa..57b74018d7948 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationsQuickSettingsContainer.java @@ -35,6 +35,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout private View mScrollView; private View mUserSwitcher; private View mStackScroller; + private View mKeyguardStatusBar; private boolean mInflated; public NotificationsQuickSettingsContainer(Context context, AttributeSet attrs) { @@ -46,6 +47,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout super.onFinishInflate(); mScrollView = findViewById(R.id.scroll_view); mStackScroller = findViewById(R.id.notification_stack_scroller); + mKeyguardStatusBar = findViewById(R.id.keyguard_header); ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher); userSwitcher.setOnInflateListener(this); mUserSwitcher = userSwitcher; @@ -61,18 +63,30 @@ public class NotificationsQuickSettingsContainer extends FrameLayout @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE; + boolean statusBarVisible = mKeyguardStatusBar.getVisibility() == View.VISIBLE; // Invert the order of the scroll view and user switcher such that the notifications receive // touches first but the panel gets drawn above. if (child == mScrollView) { return super.drawChild(canvas, mStackScroller, drawingTime); } else if (child == mStackScroller) { - return super.drawChild(canvas, userSwitcherVisible ? mUserSwitcher : mScrollView, + return super.drawChild(canvas, + userSwitcherVisible && statusBarVisible ? mUserSwitcher + : statusBarVisible ? mKeyguardStatusBar + : userSwitcherVisible ? mUserSwitcher + : mScrollView, drawingTime); } else if (child == mUserSwitcher) { - return super.drawChild(canvas, userSwitcherVisible ? mScrollView : mUserSwitcher, + return super.drawChild(canvas, + userSwitcherVisible && statusBarVisible ? mKeyguardStatusBar + : mScrollView, drawingTime); - } else { + } else if (child == mKeyguardStatusBar) { + return super.drawChild(canvas, + userSwitcherVisible && statusBarVisible ? mScrollView + : mScrollView, + drawingTime); + }else { return super.drawChild(canvas, child, drawingTime); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index e8b167c9ba680..1d678af18743a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -805,7 +805,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), - mKeyguardStatusBar, mUserSwitcherController); + mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); // Set up the quick settings tile panel diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java index ffc68988d7df2..203196ebe8028 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.policy; import android.content.Context; import android.database.DataSetObserver; -import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -28,6 +27,8 @@ import android.widget.TextView; import com.android.systemui.R; import com.android.systemui.qs.tiles.UserDetailItemView; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; +import com.android.systemui.statusbar.phone.NotificationPanelView; +import com.android.systemui.statusbar.phone.StatusBarHeaderView; import com.android.systemui.statusbar.phone.UserAvatarView; /** @@ -44,11 +45,14 @@ public class KeyguardUserSwitcher { private final boolean mSimpleUserSwitcher; public KeyguardUserSwitcher(Context context, ViewStub userSwitcher, - KeyguardStatusBarView statusBarView, UserSwitcherController userSwitcherController) { + KeyguardStatusBarView statusBarView, NotificationPanelView panelView, + UserSwitcherController userSwitcherController) { if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) { mUserSwitcher = (ViewGroup) userSwitcher.inflate(); + mUserSwitcher.setBackground(new KeyguardUserSwitcherScrim(mUserSwitcher)); mStatusBarView = statusBarView; mStatusBarView.setKeyguardUserSwitcher(this); + panelView.setKeyguardUserSwitcher(this); mAdapter = new Adapter(context, userSwitcherController); mAdapter.registerDataSetObserver(mDataSetObserver); mSimpleUserSwitcher = userSwitcherController.isSimpleUserSwitcher(); @@ -75,7 +79,7 @@ public class KeyguardUserSwitcher { * @see android.os.UserManager#isUserSwitcherEnabled() */ private boolean shouldExpandByDefault() { - return mSimpleUserSwitcher || mAdapter.getSwitchableUsers() > 1; + return mSimpleUserSwitcher; } public void show() { @@ -87,7 +91,7 @@ public class KeyguardUserSwitcher { } public void hide() { - if (mUserSwitcher != null) { + if (mUserSwitcher != null && mUserSwitcher.getVisibility() == View.VISIBLE) { // TODO: animate mUserSwitcher.setVisibility(View.GONE); mStatusBarView.setKeyguardUserSwitcherShowing(false); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java new file mode 100644 index 0000000000000..3356afdcb37ec --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.statusbar.policy; + +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.ColorFilter; +import android.graphics.Paint; +import android.graphics.PixelFormat; +import android.graphics.RadialGradient; +import android.graphics.Rect; +import android.graphics.Shader; +import android.graphics.drawable.Drawable; +import android.util.LayoutDirection; +import android.view.View; + +import com.android.systemui.R; + +/** + * Gradient background for the user switcher on Keyguard. + */ +public class KeyguardUserSwitcherScrim extends Drawable + implements View.OnLayoutChangeListener { + + private static final float OUTER_EXTENT = 2.5f; + private static final float INNER_EXTENT = 0.75f; + + private int mDarkColor; + private int mTop; + private Paint mRadialGradientPaint = new Paint(); + + public KeyguardUserSwitcherScrim(View host) { + host.addOnLayoutChangeListener(this); + mDarkColor = host.getResources().getColor( + R.color.keyguard_user_switcher_background_gradient_color); + } + + @Override + public void draw(Canvas canvas) { + boolean isLtr = getLayoutDirection() == LayoutDirection.LTR; + Rect bounds = getBounds(); + float width = bounds.width() * OUTER_EXTENT; + float height = (mTop + bounds.height()) * OUTER_EXTENT; + canvas.translate(0, -mTop); + canvas.scale(1, height/width); + canvas.drawRect(isLtr ? bounds.right - width : 0, 0, + isLtr ? bounds.right : bounds.left + width, width, mRadialGradientPaint); + } + + @Override + public void setAlpha(int alpha) { + } + + @Override + public void setColorFilter(ColorFilter cf) { + } + + @Override + public int getOpacity() { + return PixelFormat.TRANSLUCENT; + } + + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, + int oldTop, int oldRight, int oldBottom) { + if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) { + int width = right - left; + float radius = width * OUTER_EXTENT; + boolean isLtr = getLayoutDirection() == LayoutDirection.LTR; + mRadialGradientPaint.setShader( + new RadialGradient(isLtr ? width : 0, 0, radius, + new int[] { mDarkColor, Color.TRANSPARENT}, + new float[] { Math.max(0f, width * INNER_EXTENT / radius), 1f}, + Shader.TileMode.CLAMP)); + mTop = top; + } + } +}