From 0c27903d9d1c245dce5cacbfbafd997f89d85297 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Wed, 23 Dec 2020 15:28:49 -0800 Subject: [PATCH 1/2] Remove MultiUserSwitch from KeyguardStatusBarView Instead of MultiUserSwitch (a tappable view for opening the KeyguardUserSwitcher), use an ImageView for showing the multi-user avatar. Also, - Remove KeyguardUserSwitcher from MultiUserSwitch. MultiUserSwitch will only be used for opening the QS user switcher now. - Cleanup other dependencies. For example, NotificationPanelViewController no longer needs QSDetailDisplayer. NOTE: This change breaks KeyguardUserSwitcher since there is now no way to open it. A follow-up change will introduce a new entry-point for opening the switcher. The QS user switcher will continue to work because it is handled by a different instance of MultiUserSwitch (QSFooterView). Test: setprop fw.max_users 1, on keyguard, confirm that user icon is not in status bar Test: setprop fw.max_users 2, on keyguard, confirm that user icon is in status bar Bug: 169783558 Change-Id: If93902985c3dc22be0cfa8b91d37cd9b3deced2f --- .../res/layout/keyguard_status_bar.xml | 17 ++-- .../phone/KeyguardStatusBarView.java | 85 +++++++------------ .../statusbar/phone/MultiUserSwitch.java | 18 +--- .../NotificationPanelViewController.java | 5 -- .../phone/NotificationPanelViewTest.java | 2 - 5 files changed, 39 insertions(+), 88 deletions(-) diff --git a/packages/SystemUI/res/layout/keyguard_status_bar.xml b/packages/SystemUI/res/layout/keyguard_status_bar.xml index 416ee8147e337..2789ed125b096 100644 --- a/packages/SystemUI/res/layout/keyguard_status_bar.xml +++ b/packages/SystemUI/res/layout/keyguard_status_bar.xml @@ -43,17 +43,12 @@ - - - + + mUserManager.isUserSwitcherEnabled( + mContext.getResources().getBoolean( + R.bool.qs_show_user_switcher_for_single_user))); + if (isMultiUserEnabled) { + mMultiUserAvatar.setVisibility(View.VISIBLE); } else { - mMultiUserSwitch.setVisibility(View.GONE); + mMultiUserAvatar.setVisibility(View.GONE); } } mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable); @@ -220,7 +215,7 @@ public class KeyguardStatusBarView extends RelativeLayout (LinearLayout.LayoutParams) mSystemIconsContainer.getLayoutParams(); // If the avatar icon is gone, we need to have some end margin to display the system icons // correctly. - int baseMarginEnd = mMultiUserSwitch.getVisibility() == View.GONE + int baseMarginEnd = mMultiUserAvatar.getVisibility() == View.GONE ? mSystemIconsBaseMargin : 0; int marginEnd = mKeyguardUserSwitcherShowing ? mSystemIconsSwitcherHiddenExpandedMargin : @@ -334,20 +329,11 @@ public class KeyguardStatusBarView extends RelativeLayout } } - private void updateUserSwitcher() { - boolean keyguardSwitcherAvailable = mKeyguardUserSwitcher != null; - mMultiUserSwitch.setClickable(keyguardSwitcherAvailable); - mMultiUserSwitch.setFocusable(keyguardSwitcherAvailable); - mMultiUserSwitch.setKeyguardMode(keyguardSwitcherAvailable); - } - @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); UserInfoController userInfoController = Dependency.get(UserInfoController.class); userInfoController.addCallback(this); - mUserSwitcherController = Dependency.get(UserSwitcherController.class); - mMultiUserSwitch.setUserSwitcherController(mUserSwitcherController); userInfoController.reloadUserInfo(); Dependency.get(ConfigurationController.class).addCallback(this); mIconManager = new TintedIconManager(findViewById(R.id.statusIcons), @@ -369,11 +355,6 @@ public class KeyguardStatusBarView extends RelativeLayout mMultiUserAvatar.setImageDrawable(picture); } - /** */ - public void setQSDetailDisplayer(QSDetailDisplayer detailDisplayer) { - mMultiUserSwitch.setQSDetailDisplayer(detailDisplayer); - } - @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { if (mBatteryCharging != charging) { @@ -389,8 +370,6 @@ public class KeyguardStatusBarView extends RelativeLayout public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { mKeyguardUserSwitcher = keyguardUserSwitcher; - mMultiUserSwitch.setKeyguardUserSwitcher(keyguardUserSwitcher); - updateUserSwitcher(); } public void setKeyguardUserSwitcherShowing(boolean showing, boolean animate) { @@ -405,36 +384,36 @@ public class KeyguardStatusBarView extends RelativeLayout private void animateNextLayoutChange() { final int systemIconsCurrentX = mSystemIconsContainer.getLeft(); - final boolean userSwitcherVisible = mMultiUserSwitch.getParent() == mStatusIconArea; + final boolean userAvatarVisible = mMultiUserAvatar.getParent() == mStatusIconArea; getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); - boolean userSwitcherHiding = userSwitcherVisible - && mMultiUserSwitch.getParent() != mStatusIconArea; + boolean userAvatarHiding = userAvatarVisible + && mMultiUserAvatar.getParent() != mStatusIconArea; mSystemIconsContainer.setX(systemIconsCurrentX); mSystemIconsContainer.animate() .translationX(0) .setDuration(400) - .setStartDelay(userSwitcherHiding ? 300 : 0) + .setStartDelay(userAvatarHiding ? 300 : 0) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .start(); - if (userSwitcherHiding) { - getOverlay().add(mMultiUserSwitch); - mMultiUserSwitch.animate() + if (userAvatarHiding) { + getOverlay().add(mMultiUserAvatar); + mMultiUserAvatar.animate() .alpha(0f) .setDuration(300) .setStartDelay(0) .setInterpolator(Interpolators.ALPHA_OUT) .withEndAction(() -> { - mMultiUserSwitch.setAlpha(1f); - getOverlay().remove(mMultiUserSwitch); + mMultiUserAvatar.setAlpha(1f); + getOverlay().remove(mMultiUserAvatar); }) .start(); } else { - mMultiUserSwitch.setAlpha(0f); - mMultiUserSwitch.animate() + mMultiUserAvatar.setAlpha(0f); + mMultiUserAvatar.animate() .alpha(1f) .setDuration(300) .setStartDelay(200) @@ -452,8 +431,8 @@ public class KeyguardStatusBarView extends RelativeLayout if (visibility != View.VISIBLE) { mSystemIconsContainer.animate().cancel(); mSystemIconsContainer.setTranslationX(0); - mMultiUserSwitch.animate().cancel(); - mMultiUserSwitch.setAlpha(1f); + mMultiUserAvatar.animate().cancel(); + mMultiUserAvatar.setAlpha(1f); } else { updateVisibilities(); updateSystemIconsLayoutParams(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index 480d3f42ae77a..d9cb9ce213304 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -35,7 +35,6 @@ import com.android.systemui.Prefs.Key; import com.android.systemui.R; import com.android.systemui.plugins.qs.DetailAdapter; import com.android.systemui.qs.QSDetailDisplayer; -import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.policy.UserSwitcherController; /** @@ -44,8 +43,6 @@ import com.android.systemui.statusbar.policy.UserSwitcherController; public class MultiUserSwitch extends FrameLayout implements View.OnClickListener { protected QSDetailDisplayer mQSDetailDisplayer; - private KeyguardUserSwitcher mKeyguardUserSwitcher; - private boolean mKeyguardMode; private UserSwitcherController.BaseUserAdapter mUserListener; final UserManager mUserManager; @@ -85,15 +82,6 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener refreshContentDescription(); } - public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { - mKeyguardUserSwitcher = keyguardUserSwitcher; - } - - public void setKeyguardMode(boolean keyguardShowing) { - mKeyguardMode = keyguardShowing; - registerListener(); - } - public boolean isMultiUserEnabled() { // TODO(b/138661450) Move IPC calls to background return whitelistIpcs(() -> mUserManager.isUserSwitcherEnabled( @@ -123,11 +111,7 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener @Override public void onClick(View v) { - if (mKeyguardMode) { - if (mKeyguardUserSwitcher != null) { - mKeyguardUserSwitcher.show(true /* animate */); - } - } else if (mQSDetailDisplayer != null && mUserSwitcherController != null) { + if (mQSDetailDisplayer != null && mUserSwitcherController != null) { View center = getChildCount() > 0 ? getChildAt(0) : this; int[] tmpInt = new int[2]; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index e0ef3b6483a53..ca762a9b92133 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -95,7 +95,6 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.qs.QS; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; -import com.android.systemui.qs.QSDetailDisplayer; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.GestureRecorder; @@ -295,7 +294,6 @@ public class NotificationPanelViewController extends PanelViewController { private final MediaHierarchyManager mMediaHierarchyManager; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; - private final QSDetailDisplayer mQSDetailDisplayer; private final FeatureFlags mFeatureFlags; private final ScrimController mScrimController; private final ControlsComponent mControlsComponent; @@ -559,7 +557,6 @@ public class NotificationPanelViewController extends PanelViewController { NotificationGroupManagerLegacy groupManager, NotificationIconAreaController notificationIconAreaController, AuthController authController, - QSDetailDisplayer qsDetailDisplayer, ScrimController scrimController, MediaDataManager mediaDataManager, AmbientState ambientState, @@ -581,7 +578,6 @@ public class NotificationPanelViewController extends PanelViewController { mGroupManager = groupManager; mNotificationIconAreaController = notificationIconAreaController; mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory; - mQSDetailDisplayer = qsDetailDisplayer; mFeatureFlags = featureFlags; mView.setWillNotDraw(!DEBUG); mLayoutInflater = layoutInflater; @@ -660,7 +656,6 @@ public class NotificationPanelViewController extends PanelViewController { private void onFinishInflate() { loadDimens(); mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header); - mKeyguardStatusBar.setQSDetailDisplayer(mQSDetailDisplayer); mBigClockContainer = mView.findViewById(R.id.big_clock_container); updateViewControllers(mView.findViewById(R.id.keyguard_status_view)); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index c07ba723ab43b..89e8e49cc109a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -68,7 +68,6 @@ import com.android.systemui.controls.dagger.ControlsComponent; import com.android.systemui.doze.DozeLog; import com.android.systemui.media.MediaDataManager; import com.android.systemui.media.MediaHierarchyManager; -import com.android.systemui.qs.QSDetailDisplayer; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.KeyguardAffordanceView; @@ -302,7 +301,6 @@ public class NotificationPanelViewTest extends SysuiTestCase { mGroupManager, mNotificationAreaController, mAuthController, - new QSDetailDisplayer(), mScrimController, mMediaDataManager, mAmbientState, From 1970915c2c88c05ca8d5f669a72ff22c2f4beef2 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Wed, 23 Dec 2020 14:10:13 -0800 Subject: [PATCH 2/2] New keyguard user switcher - Use ViewController for KeyguardUserSwitcher, name this KeyguardUserSwitcherController - Create KeyguardUserSwitcherListView. Separate view container and controller code. - Daggerize KeyguardUserSwitcherController - Move KeyguardUserSwitcher from NotificationsQuickSettingsContainer to NotificationPanelView - Hide clock and notification when keyguard user switcher is open - Show "End guest session" button when switcher is open and user is guest - Introduce listener for user switcher state - Change icon of guest when current so that it does not show exit icon - Disallow guest exit via user switcher list item - Propagate dark amount to keyguard user switcher - Updated styles Known issues: - If repeatedly pressing KEYCODE_POWER while switching between users, the clock will sometimes get stuck in INVISIBLE state: b/179930842 - Multiple StrictMode violations are still present: b/179913579 Test: atest com.android.keyguard Test: Build with config_keyguardUserSwitcher=false, enable multi-user, check that user icon is in the status bar but not on the keyguard above the clock Test: Build with config_keyguardUserSwitcher=true, check that user icon is visible on keyguard above the clock Test: When config_keyguardUserSwitcher=true, tap user icon to open keyguard user switcher, then open and close QS to verify that the keyguard user switcher closes Test: Check that user switcher is always open and visible on the lock screen when simple user switcher is enabled: adb shell settings put global lockscreenSimpleUserSwitcher 1 && adb shell stop && adb shell start Bug: 169783558 Change-Id: Iaea4eae358873ae80748ca3eb9329f22bb2bb2ef --- .../kg_user_avatar_frame.xml} | 18 +- .../drawable/end_guest_button_background.xml | 25 + .../SystemUI/res/drawable/kg_bg_avatar.xml | 28 + .../res/layout/keyguard_user_switcher.xml | 54 +- .../layout/keyguard_user_switcher_item.xml | 41 +- .../res/layout/status_bar_expanded.xml | 12 +- packages/SystemUI/res/values-night/colors.xml | 2 + .../SystemUI/res/values-sw600dp/styles.xml | 7 - packages/SystemUI/res/values/colors.xml | 10 +- packages/SystemUI/res/values/dimens.xml | 13 +- packages/SystemUI/res/values/strings.xml | 3 + packages/SystemUI/res/values/styles.xml | 4 +- .../KeyguardStatusViewController.java | 94 +-- .../keyguard/KeyguardVisibilityHelper.java | 137 ++++ .../dagger/KeyguardUserSwitcherComponent.java | 40 ++ .../dagger/KeyguardUserSwitcherModule.java | 24 + .../dagger/KeyguardUserSwitcherScope.java | 32 + .../keyguard/KeyguardViewMediator.java | 2 + .../keyguard/dagger/KeyguardModule.java | 3 +- .../systemui/qs/tiles/UserDetailItemView.java | 2 +- .../phone/KeyguardClockPositionAlgorithm.java | 23 +- .../phone/KeyguardStatusBarView.java | 32 +- .../NotificationPanelViewController.java | 171 ++++- .../NotificationsQuickSettingsContainer.java | 22 +- .../systemui/statusbar/phone/StatusBar.java | 40 +- .../policy/KeyguardUserDetailItemView.java | 100 +++ .../policy/KeyguardUserSwitcher.java | 414 ------------ .../KeyguardUserSwitcherController.java | 639 ++++++++++++++++++ .../policy/KeyguardUserSwitcherListView.java | 168 +++++ .../policy/KeyguardUserSwitcherView.java | 31 + .../policy/UserSwitcherController.java | 2 +- .../KeyguardClockPositionAlgorithmTest.java | 9 +- .../phone/NotificationPanelViewTest.java | 9 + .../policy/KeyguardUserSwitcherAdapterTest.kt | 19 +- 34 files changed, 1560 insertions(+), 670 deletions(-) rename packages/SystemUI/res/{layout/keyguard_user_switcher_inner.xml => color/kg_user_avatar_frame.xml} (57%) create mode 100644 packages/SystemUI/res/drawable/end_guest_button_background.xml create mode 100644 packages/SystemUI/res/drawable/kg_bg_avatar.xml create mode 100644 packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java create mode 100644 packages/SystemUI/src/com/android/keyguard/dagger/KeyguardUserSwitcherComponent.java create mode 100644 packages/SystemUI/src/com/android/keyguard/dagger/KeyguardUserSwitcherModule.java create mode 100644 packages/SystemUI/src/com/android/keyguard/dagger/KeyguardUserSwitcherScope.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherListView.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherView.java diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml b/packages/SystemUI/res/color/kg_user_avatar_frame.xml similarity index 57% rename from packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml rename to packages/SystemUI/res/color/kg_user_avatar_frame.xml index 4c1042e70c1ac..174981e2a6600 100644 --- a/packages/SystemUI/res/layout/keyguard_user_switcher_inner.xml +++ b/packages/SystemUI/res/color/kg_user_avatar_frame.xml @@ -14,14 +14,10 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - + + + + + diff --git a/packages/SystemUI/res/drawable/end_guest_button_background.xml b/packages/SystemUI/res/drawable/end_guest_button_background.xml new file mode 100644 index 0000000000000..5644b657a609d --- /dev/null +++ b/packages/SystemUI/res/drawable/end_guest_button_background.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/packages/SystemUI/res/drawable/kg_bg_avatar.xml b/packages/SystemUI/res/drawable/kg_bg_avatar.xml new file mode 100644 index 0000000000000..addb3f7508f52 --- /dev/null +++ b/packages/SystemUI/res/drawable/kg_bg_avatar.xml @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher.xml b/packages/SystemUI/res/layout/keyguard_user_switcher.xml index 983ba6d5e2404..253c03e9effb3 100644 --- a/packages/SystemUI/res/layout/keyguard_user_switcher.xml +++ b/packages/SystemUI/res/layout/keyguard_user_switcher.xml @@ -14,10 +14,50 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - - \ No newline at end of file + + + + + + + + + + + diff --git a/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml b/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml index 1cd1a04ab4623..aaa372a5be6e2 100644 --- a/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml +++ b/packages/SystemUI/res/layout/keyguard_user_switcher_item.xml @@ -19,29 +19,30 @@ - - + android:background="@drawable/kg_user_switcher_rounded_bg" + systemui:activatedTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher" + systemui:regularTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher"> + + diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index d6385ffbcc0c9..859d9048cee3e 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -31,6 +31,12 @@ android:layout_height="match_parent" android:visibility="gone" /> + + @@ -72,12 +78,6 @@ - - diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml index 3153d0d0123d4..37ec576be4be3 100644 --- a/packages/SystemUI/res/values-night/colors.xml +++ b/packages/SystemUI/res/values-night/colors.xml @@ -89,6 +89,8 @@ @android:color/background_light #202124 + + #3C4043 @android:color/background_light diff --git a/packages/SystemUI/res/values-sw600dp/styles.xml b/packages/SystemUI/res/values-sw600dp/styles.xml index 02bd60210e815..ee2b82dca8117 100644 --- a/packages/SystemUI/res/values-sw600dp/styles.xml +++ b/packages/SystemUI/res/values-sw600dp/styles.xml @@ -23,13 +23,6 @@ 4 - -