Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2e20ba7 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin Committed by Ale Nijamkin
Browse files

User switcher dialog morphs again.

The refactor dropped support for the dialog "morphing" animation that's
suppored by the pre-refactor code. This CL adds it back.

Essentially, we just pass the DialogShower to the coordinator through
the dialog showing request.

Fix: 254527458
Test: manually verified that the dialog morphs exactly the same whether
the refactor flags are on or off.

Change-Id: If382c2e7afab7063aa252510f6a280a31c755eff
parent 4017df44
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ constructor(
                        isGuestEphemeral = currentlySelectedUserInfo.isEphemeral,
                        isKeyguardShowing = keyguardInteractor.isKeyguardShowing(),
                        onExitGuestUser = this::exitGuestUser,
                        dialogShower = dialogShower,
                    )
                )
                return
@@ -443,6 +444,7 @@ constructor(
                        isGuestEphemeral = currentlySelectedUserInfo.isEphemeral,
                        isKeyguardShowing = keyguardInteractor.isKeyguardShowing(),
                        onExitGuestUser = this::exitGuestUser,
                        dialogShower = dialogShower,
                    )
                )
                return
@@ -477,6 +479,7 @@ constructor(
                            userHandle = currentUser.userHandle,
                            isKeyguardShowing = keyguardInteractor.isKeyguardShowing(),
                            showEphemeralMessage = currentUser.isGuest && currentUser.isEphemeral,
                            dialogShower = dialogShower,
                        )
                    )
                }
+8 −3
Original line number Diff line number Diff line
@@ -18,14 +18,18 @@
package com.android.systemui.user.domain.model

import android.os.UserHandle
import com.android.systemui.qs.user.UserSwitchDialogController

/** Encapsulates a request to show a dialog. */
sealed class ShowDialogRequestModel {
sealed class ShowDialogRequestModel(
    open val dialogShower: UserSwitchDialogController.DialogShower? = null,
) {
    data class ShowAddUserDialog(
        val userHandle: UserHandle,
        val isKeyguardShowing: Boolean,
        val showEphemeralMessage: Boolean,
    ) : ShowDialogRequestModel()
        override val dialogShower: UserSwitchDialogController.DialogShower?,
    ) : ShowDialogRequestModel(dialogShower)

    data class ShowUserCreationDialog(
        val isGuest: Boolean,
@@ -37,5 +41,6 @@ sealed class ShowDialogRequestModel {
        val isGuestEphemeral: Boolean,
        val isKeyguardShowing: Boolean,
        val onExitGuestUser: (guestId: Int, targetId: Int, forceRemoveGuest: Boolean) -> Unit,
    ) : ShowDialogRequestModel()
        override val dialogShower: UserSwitchDialogController.DialogShower?,
    ) : ShowDialogRequestModel(dialogShower)
}
+50 −22
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@ package com.android.systemui.user.ui.dialog

import android.app.Dialog
import android.content.Context
import com.android.internal.jank.InteractionJankMonitor
import com.android.settingslib.users.UserCreatingDialog
import com.android.systemui.CoreStartable
import com.android.systemui.animation.DialogCuj
import com.android.systemui.animation.DialogLaunchAnimator
import com.android.systemui.broadcast.BroadcastSender
import com.android.systemui.dagger.SysUISingleton
@@ -71,9 +73,10 @@ constructor(
                    }
                }

                currentDialog =
                val (dialog, dialogCuj) =
                    when (request) {
                        is ShowDialogRequestModel.ShowAddUserDialog ->
                            Pair(
                                AddUserDialog(
                                    context = context.get(),
                                    userHandle = request.userHandle,
@@ -82,13 +85,22 @@ constructor(
                                    falsingManager = falsingManager.get(),
                                    broadcastSender = broadcastSender.get(),
                                    dialogLaunchAnimator = dialogLaunchAnimator.get(),
                                ),
                                DialogCuj(
                                    InteractionJankMonitor.CUJ_USER_DIALOG_OPEN,
                                    INTERACTION_JANK_ADD_NEW_USER_TAG,
                                ),
                            )
                        is ShowDialogRequestModel.ShowUserCreationDialog ->
                            Pair(
                                UserCreatingDialog(
                                    context.get(),
                                    request.isGuest,
                                ),
                                null,
                            )
                        is ShowDialogRequestModel.ShowExitGuestDialog ->
                            Pair(
                                ExitGuestDialog(
                                    context = context.get(),
                                    guestUserId = request.guestUserId,
@@ -98,10 +110,21 @@ constructor(
                                    falsingManager = falsingManager.get(),
                                    dialogLaunchAnimator = dialogLaunchAnimator.get(),
                                    onExitGuestUserListener = request.onExitGuestUser,
                                ),
                                DialogCuj(
                                    InteractionJankMonitor.CUJ_USER_DIALOG_OPEN,
                                    INTERACTION_JANK_EXIT_GUEST_MODE_TAG,
                                ),
                            )
                    }
                currentDialog = dialog

                if (request.dialogShower != null && dialogCuj != null) {
                    request.dialogShower?.showDialog(dialog, dialogCuj)
                } else {
                    dialog.show()
                }

                currentDialog?.show()
                interactor.get().onDialogShown()
            }
        }
@@ -120,4 +143,9 @@ constructor(
            }
        }
    }

    companion object {
        private const val INTERACTION_JANK_ADD_NEW_USER_TAG = "add_new_user"
        private const val INTERACTION_JANK_EXIT_GUEST_MODE_TAG = "exit_guest_mode"
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.test.filters.SmallTest
import com.android.internal.R.drawable.ic_account_circle
import com.android.systemui.R
import com.android.systemui.common.shared.model.Text
import com.android.systemui.qs.user.UserSwitchDialogController
import com.android.systemui.user.data.model.UserSwitcherSettingsModel
import com.android.systemui.user.data.source.UserRecord
import com.android.systemui.user.domain.model.ShowDialogRequestModel
@@ -316,14 +317,16 @@ class UserInteractorRefactoredTest : UserInteractorTest() {
            keyguardRepository.setKeyguardShowing(false)
            var dialogRequest: ShowDialogRequestModel? = null
            val job = underTest.dialogShowRequests.onEach { dialogRequest = it }.launchIn(this)
            val dialogShower: UserSwitchDialogController.DialogShower = mock()

            underTest.executeAction(UserActionModel.ADD_USER)
            underTest.executeAction(UserActionModel.ADD_USER, dialogShower)
            assertThat(dialogRequest)
                .isEqualTo(
                    ShowDialogRequestModel.ShowAddUserDialog(
                        userHandle = userInfos[0].userHandle,
                        isKeyguardShowing = false,
                        showEphemeralMessage = false,
                        dialogShower = dialogShower,
                    )
                )