From c0a97d0d6739a3ed1c8aecf7a169ac974dedffa5 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:22:42 +0200 Subject: [PATCH] Don't play enter transtition when launcher is already in foreground --- .../launcher2/ui/launcher/SharedLauncherActivity.kt | 11 +++++++---- .../ui/launcher/transitions/EnterHomeTransition.kt | 4 ++-- .../transitions/EnterHomeTransitionManager.kt | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt index 2a07c0fb..05bbeff3 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/SharedLauncherActivity.kt @@ -143,10 +143,12 @@ abstract class SharedLauncherActivity( .currentTransition .flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED) .collect { - enterTransitionProgress.value = 0f - enterTransition = it - enterTransitionProgress.animateTo(1f) - enterTransition = null + if (it != null) { + enterTransitionProgress.value = 0f + enterTransition = it + enterTransitionProgress.animateTo(1f) + enterTransition = null + } } } @@ -230,6 +232,7 @@ abstract class SharedLauncherActivity( .imePadding() ) enterTransition?.let { + if (it.startBounds == null || it.targetBounds == null) return@let val dX = it.startBounds.center.x - it.targetBounds.center.x val dY = it.startBounds.center.y - it.targetBounds.center.y val s = diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransition.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransition.kt index 1ee3cdb5..6e6bcd65 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransition.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransition.kt @@ -5,7 +5,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect data class EnterHomeTransition( - val startBounds: Rect, - val targetBounds: Rect, + val startBounds: Rect? = null, + val targetBounds: Rect? = null, val icon: (@Composable (animVector: Offset, progress: () -> Float) -> Unit)? = null ) \ No newline at end of file diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransitionManager.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransitionManager.kt index d2c4e3fc..f15befb2 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransitionManager.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/transitions/EnterHomeTransitionManager.kt @@ -30,7 +30,7 @@ class EnterHomeTransitionManager { return } } - currentTransition.tryEmit(null) + currentTransition.tryEmit(EnterHomeTransition()) } fun clear() {