summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Laird <evanlaird@google.com> 2022-12-22 10:35:17 -0500
committer Evan Laird <evanlaird@google.com> 2023-01-09 18:31:01 +0000
commitaf39f0d071852328170a6f9c087bcc22989ad59f (patch)
tree2511f788d84941d407345a08efe57a9b4c197067
parent21ce858e1f7e7dd5f075d37128b4f1f6c7ed2dda (diff)
Launch `UserSwitchDialog` using the expandable
The old `UserSwitchDialogController` class would utilize the `Expandable`, and had the dialog launch itself by creating a `DialogLaunchAnimator.Controller` from the expandable. This CL threads the expandable through to the UserSwitchDialogCoordinator so it can do something similar. Test: UserInteractorTest; manual Bug: 260874319 Change-Id: I86e7df6b8aaa1dccc0cb951c491fd8c6b30294e1 Merged-In: I86e7df6b8aaa1dccc0cb951c491fd8c6b30294e1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/domain/model/ShowDialogRequestModel.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/ui/dialog/DialogShowerImpl.kt33
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitchDialog.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitcherDialogCoordinator.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt3
7 files changed, 48 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt b/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt
index 314252bf310b..4c9c99cc16f0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt
@@ -36,6 +36,7 @@ import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.QSUserSwitcherEvent
import com.android.systemui.qs.tiles.UserDetailView
import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.android.systemui.user.ui.dialog.DialogShowerImpl
import javax.inject.Inject
import javax.inject.Provider
@@ -130,19 +131,6 @@ class UserSwitchDialogController @VisibleForTesting constructor(
}
}
- private class DialogShowerImpl(
- private val animateFrom: Dialog,
- private val dialogLaunchAnimator: DialogLaunchAnimator
- ) : DialogInterface by animateFrom, DialogShower {
- override fun showDialog(dialog: Dialog, cuj: DialogCuj) {
- dialogLaunchAnimator.showFromDialog(
- dialog,
- animateFrom = animateFrom,
- cuj
- )
- }
- }
-
interface DialogShower : DialogInterface {
fun showDialog(dialog: Dialog, cuj: DialogCuj)
}
diff --git a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
index d7b0971d9126..7a885bc8d2e2 100644
--- a/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/domain/interactor/UserInteractor.kt
@@ -115,9 +115,7 @@ constructor(
private val callbackMutex = Mutex()
private val callbacks = mutableSetOf<UserCallback>()
private val userInfos: Flow<List<UserInfo>> =
- repository.userInfos.map { userInfos ->
- userInfos.filter { it.isFull }
- }
+ repository.userInfos.map { userInfos -> userInfos.filter { it.isFull } }
/** List of current on-device users to select from. */
val users: Flow<List<UserModel>>
@@ -493,7 +491,7 @@ constructor(
fun showUserSwitcher(context: Context, expandable: Expandable) {
if (!featureFlags.isEnabled(Flags.FULL_SCREEN_USER_SWITCHER)) {
- showDialog(ShowDialogRequestModel.ShowUserSwitcherDialog)
+ showDialog(ShowDialogRequestModel.ShowUserSwitcherDialog(expandable))
return
}
diff --git a/packages/SystemUI/src/com/android/systemui/user/domain/model/ShowDialogRequestModel.kt b/packages/SystemUI/src/com/android/systemui/user/domain/model/ShowDialogRequestModel.kt
index 85c29647719b..14cc3e783fed 100644
--- a/packages/SystemUI/src/com/android/systemui/user/domain/model/ShowDialogRequestModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/domain/model/ShowDialogRequestModel.kt
@@ -18,11 +18,13 @@
package com.android.systemui.user.domain.model
import android.os.UserHandle
+import com.android.systemui.animation.Expandable
import com.android.systemui.qs.user.UserSwitchDialogController
/** Encapsulates a request to show a dialog. */
sealed class ShowDialogRequestModel(
open val dialogShower: UserSwitchDialogController.DialogShower? = null,
+ open val expandable: Expandable? = null,
) {
data class ShowAddUserDialog(
val userHandle: UserHandle,
@@ -45,5 +47,7 @@ sealed class ShowDialogRequestModel(
) : ShowDialogRequestModel(dialogShower)
/** Show the user switcher dialog */
- object ShowUserSwitcherDialog : ShowDialogRequestModel()
+ data class ShowUserSwitcherDialog(
+ override val expandable: Expandable?,
+ ) : ShowDialogRequestModel()
}
diff --git a/packages/SystemUI/src/com/android/systemui/user/ui/dialog/DialogShowerImpl.kt b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/DialogShowerImpl.kt
new file mode 100644
index 000000000000..3fe2a7b19851
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/DialogShowerImpl.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 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.user.ui.dialog
+
+import android.app.Dialog
+import android.content.DialogInterface
+import com.android.systemui.animation.DialogCuj
+import com.android.systemui.animation.DialogLaunchAnimator
+import com.android.systemui.qs.user.UserSwitchDialogController.DialogShower
+
+/** Extracted from [UserSwitchDialogController] */
+class DialogShowerImpl(
+ private val animateFrom: Dialog,
+ private val dialogLaunchAnimator: DialogLaunchAnimator,
+) : DialogInterface by animateFrom, DialogShower {
+ override fun showDialog(dialog: Dialog, cuj: DialogCuj) {
+ dialogLaunchAnimator.showFromDialog(dialog, animateFrom = animateFrom, cuj)
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitchDialog.kt b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitchDialog.kt
index ed2589889435..b8ae257aaac5 100644
--- a/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitchDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitchDialog.kt
@@ -60,6 +60,7 @@ class UserSwitchDialog(
setView(gridFrame)
adapter.linkToViewGroup(gridFrame.findViewById(R.id.grid))
+ adapter.injectDialogShower(DialogShowerImpl(this, dialogLaunchAnimator))
}
companion object {
diff --git a/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitcherDialogCoordinator.kt b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitcherDialogCoordinator.kt
index 41410542204c..d4512309f6c6 100644
--- a/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitcherDialogCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/ui/dialog/UserSwitcherDialogCoordinator.kt
@@ -133,7 +133,10 @@ constructor(
}
currentDialog = dialog
- if (request.dialogShower != null && dialogCuj != null) {
+ val controller = request.expandable?.dialogLaunchController(dialogCuj)
+ if (controller != null) {
+ dialogLaunchAnimator.get().show(dialog, controller)
+ } else if (request.dialogShower != null && dialogCuj != null) {
request.dialogShower?.showDialog(dialog, dialogCuj)
} else {
dialog.show()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
index 78b0cbe8c718..5beb2b389349 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/user/domain/interactor/UserInteractorTest.kt
@@ -813,7 +813,8 @@ class UserInteractorTest : SysuiTestCase() {
val job = underTest.dialogShowRequests.onEach { dialogRequest = it }.launchIn(this)
// Dialog is shown.
- assertThat(dialogRequest).isEqualTo(ShowDialogRequestModel.ShowUserSwitcherDialog)
+ assertThat(dialogRequest)
+ .isEqualTo(ShowDialogRequestModel.ShowUserSwitcherDialog(expandable))
underTest.onDialogShown()
assertThat(dialogRequest).isNull()