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

Commit d6f45e8c authored by Matt Pietal's avatar Matt Pietal
Browse files

Move animation flows to immediate dispatcher

This aligns alpha and translation with the frame in which it
should be rendered, rather than potentially delaying it.

Fixes: 356100513
Test: manual, swipe up to bouncer
Flag: com.android.systemui.migrate_clocks_to_blueprint
Change-Id: I494df57b8da94e13bee78096db8f03ecdd081f79
parent 8b6d2d95
Loading
Loading
Loading
Loading
+56 −54
Original line number Diff line number Diff line
@@ -152,6 +152,62 @@ object KeyguardRootViewBinder {
                            }
                        }
                    }

                    if (
                        KeyguardBottomAreaRefactor.isEnabled || DeviceEntryUdfpsRefactor.isEnabled
                    ) {
                        launch("$TAG#alpha") {
                            viewModel.alpha(viewState).collect { alpha ->
                                view.alpha = alpha
                                if (KeyguardBottomAreaRefactor.isEnabled) {
                                    childViews[statusViewId]?.alpha = alpha
                                    childViews[burnInLayerId]?.alpha = alpha
                                }
                            }
                        }
                    }

                    if (MigrateClocksToBlueprint.isEnabled) {
                        launch("$TAG#translationY") {
                            // When translation happens in burnInLayer, it won't be weather clock
                            // large clock isn't added to burnInLayer due to its scale transition
                            // so we also need to add translation to it here
                            // same as translationX
                            viewModel.translationY.collect { y ->
                                childViews[burnInLayerId]?.translationY = y
                                childViews[largeClockId]?.translationY = y
                                childViews[aodNotificationIconContainerId]?.translationY = y
                            }
                        }

                        launch("$TAG#translationX") {
                            viewModel.translationX.collect { state ->
                                val px = state.value ?: return@collect
                                when {
                                    state.isToOrFrom(KeyguardState.AOD) -> {
                                        // Large Clock is not translated in the x direction
                                        childViews[burnInLayerId]?.translationX = px
                                        childViews[aodNotificationIconContainerId]?.translationX =
                                            px
                                    }
                                    state.isToOrFrom(KeyguardState.GLANCEABLE_HUB) -> {
                                        for ((key, childView) in childViews.entries) {
                                            when (key) {
                                                indicationArea,
                                                startButton,
                                                endButton,
                                                lockIcon,
                                                deviceEntryIcon -> {
                                                    // Do not move these views
                                                }
                                                else -> childView.translationX = px
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        disposables +=
@@ -188,20 +244,6 @@ object KeyguardRootViewBinder {
                        }
                    }

                    if (
                        KeyguardBottomAreaRefactor.isEnabled || DeviceEntryUdfpsRefactor.isEnabled
                    ) {
                        launch {
                            viewModel.alpha(viewState).collect { alpha ->
                                view.alpha = alpha
                                if (KeyguardBottomAreaRefactor.isEnabled) {
                                    childViews[statusViewId]?.alpha = alpha
                                    childViews[burnInLayerId]?.alpha = alpha
                                }
                            }
                        }
                    }

                    if (MigrateClocksToBlueprint.isEnabled) {
                        launch {
                            viewModel.burnInLayerVisibility.collect { visibility ->
@@ -221,46 +263,6 @@ object KeyguardRootViewBinder {
                            }
                        }

                        launch {
                            // When translation happens in burnInLayer, it won't be weather clock
                            // large clock isn't added to burnInLayer due to its scale transition
                            // so we also need to add translation to it here
                            // same as translationX
                            viewModel.translationY.collect { y ->
                                childViews[burnInLayerId]?.translationY = y
                                childViews[largeClockId]?.translationY = y
                                childViews[aodNotificationIconContainerId]?.translationY = y
                            }
                        }

                        launch {
                            viewModel.translationX.collect { state ->
                                val px = state.value ?: return@collect
                                when {
                                    state.isToOrFrom(KeyguardState.AOD) -> {
                                        // Large Clock is not translated in the x direction
                                        childViews[burnInLayerId]?.translationX = px
                                        childViews[aodNotificationIconContainerId]?.translationX =
                                            px
                                    }
                                    state.isToOrFrom(KeyguardState.GLANCEABLE_HUB) -> {
                                        for ((key, childView) in childViews.entries) {
                                            when (key) {
                                                indicationArea,
                                                startButton,
                                                endButton,
                                                lockIcon,
                                                deviceEntryIcon -> {
                                                    // Do not move these views
                                                }
                                                else -> childView.translationX = px
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        launch {
                            viewModel.scale.collect { scaleViewModel ->
                                if (scaleViewModel.scaleClockOnly) {