BG protection for user switcher on Keyguard.
Also fixes the position. Bug: 15757197 Bug: 15545213 Change-Id: I9fab98652ab1ccad4e02d5cfa17b212a72a0a0b3
This commit is contained in:
@@ -50,12 +50,8 @@
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<include
|
||||
layout="@layout/keyguard_status_bar"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
|
||||
android:layout_width="@dimen/notification_panel_width"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="@integer/notification_panel_layout_gravity"
|
||||
android:id="@+id/notification_container_parent"
|
||||
@@ -64,8 +60,9 @@
|
||||
|
||||
<com.android.systemui.statusbar.phone.ObservableScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/notification_panel_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="@integer/notification_panel_layout_gravity"
|
||||
android:scrollbars="none"
|
||||
android:overScrollMode="never"
|
||||
android:fillViewport="true">
|
||||
@@ -97,8 +94,9 @@
|
||||
|
||||
<com.android.systemui.statusbar.stack.NotificationStackScrollLayout
|
||||
android:id="@+id/notification_stack_scroller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/notification_panel_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="@integer/notification_panel_layout_gravity"
|
||||
android:layout_marginBottom="@dimen/close_handle_underlap"/>
|
||||
|
||||
<ViewStub
|
||||
@@ -109,6 +107,10 @@
|
||||
android:layout_gravity="end"
|
||||
android:layout="@layout/keyguard_user_switcher" />
|
||||
|
||||
<include
|
||||
layout="@layout/keyguard_status_bar"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer>
|
||||
|
||||
<include layout="@layout/status_bar_expanded_header" />
|
||||
|
||||
@@ -72,9 +72,6 @@
|
||||
<!-- Margin on the left side of the carrier text on Keyguard -->
|
||||
<dimen name="keyguard_carrier_text_margin">24dp</dimen>
|
||||
|
||||
<!-- end margin for system icons if multi user switch is hidden -->
|
||||
<dimen name="system_icons_switcher_hidden_expanded_margin">20dp</dimen>
|
||||
|
||||
<!-- The width/height of the phone/camera/unlock icon on keyguard. -->
|
||||
<dimen name="keyguard_affordance_height">80dp</dimen>
|
||||
<dimen name="keyguard_affordance_width">120dp</dimen>
|
||||
|
||||
@@ -103,4 +103,6 @@
|
||||
<color name="notification_guts_btn_color">#FFFFFFFF</color>
|
||||
|
||||
<color name="search_panel_card_color">#ffffff</color>
|
||||
|
||||
<color name="keyguard_user_switcher_background_gradient_color">#77000000</color>
|
||||
</resources>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user