diff --git a/apps/multiplatform/android/src/main/java/chat/simplex/app/MainActivity.kt b/apps/multiplatform/android/src/main/java/chat/simplex/app/MainActivity.kt index 512e9efc1..2dff3d604 100644 --- a/apps/multiplatform/android/src/main/java/chat/simplex/app/MainActivity.kt +++ b/apps/multiplatform/android/src/main/java/chat/simplex/app/MainActivity.kt @@ -91,11 +91,11 @@ class MainActivity: FragmentActivity() { // When pressed Back and there is no one wants to process the back event, clear auth state to force re-auth on launch AppLock.clearAuthState() AppLock.laFailed.value = true - AppLock.destroyedAfterBackPress.value = true } if (!onBackPressedDispatcher.hasEnabledCallbacks()) { // Drop shared content SimplexApp.context.chatModel.sharedContent.value = null + finish() } } } diff --git a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/UI.android.kt b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/UI.android.kt index c458561f9..ca497cbc5 100644 --- a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/UI.android.kt +++ b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/platform/UI.android.kt @@ -69,3 +69,5 @@ actual fun hideKeyboard(view: Any?) { (androidAppContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(view.windowToken, 0) } } + +actual fun androidIsFinishingMainActivity(): Boolean = (mainActivity.get()?.isFinishing == true) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt index 4531f88f9..82201cce0 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt @@ -150,7 +150,7 @@ fun MainScreen() { LaunchedEffect(Unit) { // With these constrains when user presses back button while on ChatList, activity destroys and shows auth request // while the screen moves to a launcher. Detect it and prevent showing the auth - if (!(AppLock.destroyedAfterBackPress.value && chatModel.controller.appPrefs.laMode.get() == LAMode.SYSTEM)) { + if (!(androidIsFinishingMainActivity() && chatModel.controller.appPrefs.laMode.get() == LAMode.SYSTEM)) { AppLock.runAuthenticate() } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/AppLock.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/AppLock.kt index 7228f4ebf..a1d4c0c62 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/AppLock.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/AppLock.kt @@ -24,7 +24,6 @@ object AppLock { // Remember result and show it after orientation change val laFailed = mutableStateOf(false) - val destroyedAfterBackPress = mutableStateOf(false) fun clearAuthState() { userAuthorized.value = null diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/UI.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/UI.kt index 38629f038..c61d8564c 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/UI.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/UI.kt @@ -14,3 +14,5 @@ expect fun LocalMultiplatformView(): Any? @Composable expect fun getKeyboardState(): State expect fun hideKeyboard(view: Any?) + +expect fun androidIsFinishingMainActivity(): Boolean diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/UI.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/UI.desktop.kt index 1ea5018fc..94d42ba79 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/UI.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/UI.desktop.kt @@ -17,3 +17,5 @@ actual fun LocalMultiplatformView(): Any? = null @Composable actual fun getKeyboardState(): State = remember { mutableStateOf(KeyboardState.Opened) } actual fun hideKeyboard(view: Any?) {} + +actual fun androidIsFinishingMainActivity(): Boolean = false diff --git a/flake.lock b/flake.lock index 2c133a9b6..81b3f6f6b 100644 --- a/flake.lock +++ b/flake.lock @@ -288,11 +288,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1676679913, - "narHash": "sha256-nW7ApRgiA9uChV/UrW89HK75rIToLt7XtSrkodO0Nbc=", + "lastModified": 1696724662, + "narHash": "sha256-jV2ugSjZE0FjMYR2YIx0p2cDBqd+xxhZrRxp5BmieYk=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "c37cffd51315d8e27dd8d3faf75abf897e39c8c8", + "rev": "df603bff8606d8653a0876ae0c3fd1f9014882f2", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f7e86fbb6..f6a68246e 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ let pkgs = haskellNix.legacyPackages.${system}.appendOverlays [android26]; in let drv' = { extra-modules, pkgs', ... }: pkgs'.haskell-nix.project { compiler-nix-name = "ghc8107"; - index-state = "2022-06-20T00:00:00Z"; + index-state = "2023-10-06T00:00:00Z"; # We need this, to specify we want the cabal project. # If the stack.yaml was dropped, this would not be necessary. projectFileName = "cabal.project";