From 56276a2cc56c215240ba22f3c81db37cecc0c7e8 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 6 Apr 2021 16:19:16 -0700 Subject: [PATCH] Move keyguard multi-user icon into container view Fix UI bug that made the lock screen unusable when toggling the multi-user setting off and on. Test: adb shell settings put global user_switcher_enabled 0 \ && adb shell settings put global user_switcher_enabled 1 Bug: 195052728 Change-Id: Iadbd29bd7c50cd20a86f966d3f7ec69cd78c9744 Merged-In: Iadbd29bd7c50cd20a86f966d3f7ec69cd78c9744 --- .../res/layout/keyguard_qs_user_switch.xml | 32 +++++++++++-------- .../dagger/KeyguardQsUserSwitchComponent.java | 6 ++-- .../NotificationPanelViewController.java | 10 +++--- .../KeyguardQsUserSwitchController.java | 20 ++++++------ 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/packages/SystemUI/res/layout/keyguard_qs_user_switch.xml b/packages/SystemUI/res/layout/keyguard_qs_user_switch.xml index a21a63c3e7c32..9cf09ff328c47 100644 --- a/packages/SystemUI/res/layout/keyguard_qs_user_switch.xml +++ b/packages/SystemUI/res/layout/keyguard_qs_user_switch.xml @@ -15,19 +15,25 @@ ~ limitations under the License --> - - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="end"> + + + \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardQsUserSwitchComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardQsUserSwitchComponent.java index 3a0357d2a2843..4331f52eb1a27 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardQsUserSwitchComponent.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardQsUserSwitchComponent.java @@ -16,7 +16,8 @@ package com.android.keyguard.dagger; -import com.android.systemui.statusbar.phone.UserAvatarView; +import android.widget.FrameLayout; + import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController; import dagger.BindsInstance; @@ -31,8 +32,7 @@ public interface KeyguardQsUserSwitchComponent { /** Simple factory for {@link KeyguardUserSwitcherComponent}. */ @Subcomponent.Factory interface Factory { - KeyguardQsUserSwitchComponent build( - @BindsInstance UserAvatarView userAvatarView); + KeyguardQsUserSwitchComponent build(@BindsInstance FrameLayout userAvatarContainer); } /** Builds a {@link KeyguardQsUserSwitchController}. */ 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 198ad98b8a376..2dd60fbd0a5ad 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -798,13 +798,13 @@ public class NotificationPanelViewController extends PanelViewController { mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header); mBigClockContainer = mView.findViewById(R.id.big_clock_container); - UserAvatarView userAvatarView = null; + FrameLayout userAvatarContainer = null; KeyguardUserSwitcherView keyguardUserSwitcherView = null; if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled()) { if (mKeyguardQsUserSwitchEnabled) { ViewStub stub = mView.findViewById(R.id.keyguard_qs_user_switch_stub); - userAvatarView = (UserAvatarView) stub.inflate(); + userAvatarContainer = (FrameLayout) stub.inflate(); } else { ViewStub stub = mView.findViewById(R.id.keyguard_user_switcher_stub); keyguardUserSwitcherView = (KeyguardUserSwitcherView) stub.inflate(); @@ -820,7 +820,7 @@ public class NotificationPanelViewController extends PanelViewController { updateViewControllers( mView.findViewById(R.id.keyguard_status_view), - userAvatarView, + userAvatarContainer, keyguardUserSwitcherView); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); NotificationStackScrollLayout stackScrollLayout = mView.findViewById( @@ -910,7 +910,7 @@ public class NotificationPanelViewController extends PanelViewController { } private void updateViewControllers(KeyguardStatusView keyguardStatusView, - UserAvatarView userAvatarView, + FrameLayout userAvatarView, KeyguardUserSwitcherView keyguardUserSwitcherView) { // Re-associate the KeyguardStatusViewController KeyguardStatusViewComponent statusViewComponent = @@ -1066,7 +1066,7 @@ public class NotificationPanelViewController extends PanelViewController { !mKeyguardQsUserSwitchEnabled && mKeyguardUserSwitcherEnabled && isUserSwitcherEnabled; - UserAvatarView userAvatarView = (UserAvatarView) reInflateStub( + FrameLayout userAvatarView = (FrameLayout) reInflateStub( R.id.keyguard_qs_user_switch_view /* viewId */, R.id.keyguard_qs_user_switch_stub /* stubId */, R.layout.keyguard_qs_user_switch /* layoutId */, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java index 5e70d0dbc4181..d838a05135e7f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java @@ -27,6 +27,7 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.FrameLayout; import com.android.keyguard.KeyguardConstants; import com.android.keyguard.KeyguardVisibilityHelper; @@ -56,7 +57,7 @@ import javax.inject.Provider; * Manages the user switch on the Keyguard that is used for opening the QS user panel. */ @KeyguardUserSwitcherScope -public class KeyguardQsUserSwitchController extends ViewController { +public class KeyguardQsUserSwitchController extends ViewController { private static final String TAG = "KeyguardQsUserSwitchController"; private static final boolean DEBUG = KeyguardConstants.DEBUG; @@ -76,6 +77,7 @@ public class KeyguardQsUserSwitchController extends ViewController { + mUserAvatarView.setOnClickListener(v -> { if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { return; } - if (isListAnimating()) { return; } @@ -163,7 +165,7 @@ public class KeyguardQsUserSwitchController extends ViewController