From 564d92f7a7f34510bdaa86c224c5f137a0366343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 1 Aug 2023 10:30:20 +0200 Subject: [PATCH] Add animation on home button if no other app was on top --- .../launcher/activities/MainActivity.kt | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index 058c5d8..ba45e34 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -33,6 +33,7 @@ import androidx.core.graphics.drawable.toBitmap import androidx.core.view.GestureDetectorCompat import androidx.core.view.WindowCompat import androidx.core.view.isVisible +import androidx.lifecycle.Lifecycle import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.launcher.BuildConfig @@ -69,6 +70,7 @@ class MainActivity : SimpleActivity(), FlingListener { private var mActionOnCanBindWidget: ((granted: Boolean) -> Unit)? = null private var mActionOnWidgetConfiguredWidget: ((granted: Boolean) -> Unit)? = null private var mActionOnAddShortcut: ((shortcutId: String, label: String, icon: Drawable) -> Unit)? = null + private var wasJustPaused: Boolean = false private lateinit var mDetector: GestureDetectorCompat @@ -113,8 +115,17 @@ class MainActivity : SimpleActivity(), FlingListener { override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) - closeAppDrawer() - closeWidgetsFragment() + if (wasJustPaused) { + if (isAllAppsFragmentExpanded()) { + hideFragment(all_apps_fragment) + } + if (isWidgetsFragmentExpanded()) { + hideFragment(widgets_fragment) + } + } else { + closeAppDrawer() + closeWidgetsFragment() + } if (intent != null) { handleIntentAction(intent) } @@ -200,6 +211,7 @@ class MainActivity : SimpleActivity(), FlingListener { override fun onResume() { super.onResume() + wasJustPaused = false updateStatusbarColor(Color.TRANSPARENT) main_holder.onGlobalLayout { @@ -249,6 +261,12 @@ class MainActivity : SimpleActivity(), FlingListener { override fun onStop() { super.onStop() home_screen_grid?.appWidgetHost?.stopListening() + wasJustPaused = false + } + + override fun onPause() { + super.onPause() + wasJustPaused = true } override fun onBackPressed() {