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

Commit 877d9ecd authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Animate notif stack when OnLayoutChange detects Smartspace visibility change.

The existing `keyguardSmartspaceViewModel.bcsmartspaceVisibility`
triggers a SmartspaceVisibility transition. However,
`bcsmartspaceVisibility` is set via a `OnGlobalLayoutListener`, which is
called after the layout bounds are already applied.

Since `viewModel.onNotificationContainerBoundsChanged` is called inside
`onLayoutChange`, the only way to make this work is to detect Smartspace
visibility change inside the same function.

I also tried calling the following inside `onLayoutChange`:
    `smartspaceInteractor.setBcSmartspaceVisibility(smartspaceVisibility)
     // requestLayout()
     childViews[bcSmartspaceId]?.requestLayout()
     return;`.
My hope was that the immediate next call of `onLayoutChange` would get
the SmartspaceVisibility transtion. However, the SmartspaceVisibility
transition didn't come until a few calls later. So that didn't work.

The value of `bcsmartspaceVisibility` is updated in the immediate next
call of `onLayoutChange`, regardless of whether it's set in
`onLayoutChange` or via the `OnGlobalLayoutListener`. So I left it
untouched.

Also cleaned up some unused parameters.

Flag: EXEMPT bugfix
Fix: 393871116
Test: on device, use flashlight shortcut to turn flashlight on/off (when
there is no other content in the Lockscreen Smartspace)
Test: Presubmit

Change-Id: I8f06bf854af1c02d5e6de760cfc608a792b6c72d
parent 47bf2907
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -147,10 +147,8 @@ constructor(
                configuration,
                occludingAppDeviceEntryMessageViewModel,
                chipbarCoordinator,
                screenOffAnimationController,
                shadeInteractor,
                clockInteractor,
                keyguardClockViewModel,
                smartspaceViewModel,
                deviceEntryHapticsInteractor,
                vibratorHelper,
                falsingManager,
+13 −11
Original line number Diff line number Diff line
@@ -51,13 +51,12 @@ import com.android.systemui.common.ui.view.onLayoutChanged
import com.android.systemui.common.ui.view.onTouchListener
import com.android.systemui.customization.R as customR
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.ui.view.layout.sections.AodPromotedNotificationSection
import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessageViewModel
import com.android.systemui.keyguard.ui.viewmodel.TransitionData
import com.android.systemui.keyguard.ui.viewmodel.ViewStateAccessor
@@ -72,7 +71,6 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.CrossFadeHelper
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.temporarydisplay.ViewPriority
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
@@ -103,10 +101,8 @@ object KeyguardRootViewBinder {
        configuration: ConfigurationState,
        occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel?,
        chipbarCoordinator: ChipbarCoordinator?,
        screenOffAnimationController: ScreenOffAnimationController,
        shadeInteractor: ShadeInteractor,
        clockInteractor: KeyguardClockInteractor,
        clockViewModel: KeyguardClockViewModel,
        smartspaceViewModel: KeyguardSmartspaceViewModel,
        deviceEntryHapticsInteractor: DeviceEntryHapticsInteractor?,
        vibratorHelper: VibratorHelper?,
        falsingManager: FalsingManager?,
@@ -326,7 +322,7 @@ object KeyguardRootViewBinder {
                                if (isFullyAnyExpanded) {
                                    INVISIBLE
                                } else {
                                    View.VISIBLE
                                    VISIBLE
                                }
                        }
                    }
@@ -394,7 +390,7 @@ object KeyguardRootViewBinder {
                OnLayoutChange(
                    viewModel,
                    blueprintViewModel,
                    clockViewModel,
                    smartspaceViewModel,
                    childViews,
                    burnInParams,
                    Logger(blueprintLog, TAG),
@@ -452,7 +448,7 @@ object KeyguardRootViewBinder {
    private class OnLayoutChange(
        private val viewModel: KeyguardRootViewModel,
        private val blueprintViewModel: KeyguardBlueprintViewModel,
        private val clockViewModel: KeyguardClockViewModel,
        private val smartspaceViewModel: KeyguardSmartspaceViewModel,
        private val childViews: Map<Int, View>,
        private val burnInParams: MutableStateFlow<BurnInParameters>,
        private val logger: Logger,
@@ -470,12 +466,16 @@ object KeyguardRootViewBinder {
            oldRight: Int,
            oldBottom: Int,
        ) {
            val prevSmartspaceVisibility = smartspaceViewModel.bcSmartspaceVisibility.value
            val smartspaceVisibility = childViews[bcSmartspaceId]?.visibility ?: GONE
            val smartspaceVisibilityChanged = prevSmartspaceVisibility != smartspaceVisibility

            // After layout, ensure the notifications are positioned correctly
            childViews[nsslPlaceholderId]?.let { notificationListPlaceholder ->
                // Do not update a second time while a blueprint transition is running
                val transition = blueprintViewModel.currentTransition.value
                val shouldAnimate = transition != null && transition.config.type.animateNotifChanges
                if (prevTransition == transition && shouldAnimate) {
                if (prevTransition == transition && shouldAnimate && !smartspaceVisibilityChanged) {
                    logger.w("Skipping onNotificationContainerBoundsChanged during transition")
                    return
                }
@@ -484,7 +484,7 @@ object KeyguardRootViewBinder {
                viewModel.onNotificationContainerBoundsChanged(
                    notificationListPlaceholder.top.toFloat(),
                    notificationListPlaceholder.bottom.toFloat(),
                    animate = shouldAnimate,
                    animate = (shouldAnimate || smartspaceVisibilityChanged),
                )
            }

@@ -583,6 +583,8 @@ object KeyguardRootViewBinder {
    private val aodNotificationIconContainerId = R.id.aod_notification_icon_container
    private val largeClockId = customR.id.lockscreen_clock_view_large
    private val largeClockDateId = sharedR.id.date_smartspace_view_large
    private val largeClockWeatherId = sharedR.id.weather_smartspace_view_large
    private val bcSmartspaceId = sharedR.id.bc_smartspace_view
    private val smallClockId = customR.id.lockscreen_clock_view
    private val indicationArea = R.id.keyguard_indication_area
    private val startButton = R.id.start_button