diff --git a/app/src/main/java/app/pachli/MainActivity.kt b/app/src/main/java/app/pachli/MainActivity.kt index b8eb1da5b..7dd8bc675 100644 --- a/app/src/main/java/app/pachli/MainActivity.kt +++ b/app/src/main/java/app/pachli/MainActivity.kt @@ -557,7 +557,11 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider { } } startActivity(composeIntent) - finish() + + // Recreate the activity to ensure it is using the correct active account + // (which may have changed while processing the compose intent) and so + // the user returns to the timeline when they finish ComposeActivity. + recreate() } private fun setupDrawer( diff --git a/app/src/main/java/app/pachli/components/notifications/NotificationHelper.kt b/app/src/main/java/app/pachli/components/notifications/NotificationHelper.kt index d8d2b4d7e..0ed90cb60 100644 --- a/app/src/main/java/app/pachli/components/notifications/NotificationHelper.kt +++ b/app/src/main/java/app/pachli/components/notifications/NotificationHelper.kt @@ -431,9 +431,13 @@ private fun getStatusComposeIntent( language = language, kind = ComposeOptions.ComposeKind.NEW, ) - val composeIntent = - MainActivityIntent.openCompose(context, composeOptions, account.id, body.id, account.id.toInt()) - composeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + val composeIntent = MainActivityIntent.openCompose( + context, + composeOptions, + account.id, + body.id, + account.id.toInt(), + ) return PendingIntent.getActivity( context.applicationContext, notificationId, diff --git a/app/src/main/java/app/pachli/service/PachliTileService.kt b/app/src/main/java/app/pachli/service/PachliTileService.kt index 65a346e28..597dfa580 100644 --- a/app/src/main/java/app/pachli/service/PachliTileService.kt +++ b/app/src/main/java/app/pachli/service/PachliTileService.kt @@ -36,7 +36,6 @@ class PachliTileService : TileService() { @SuppressLint("StartActivityAndCollapseDeprecated") override fun onClick() { val intent = MainActivityIntent.openCompose(this, ComposeOptions()) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { startActivityAndCollapse(getActivityPendingIntent(this, 0, intent)) } else { diff --git a/core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt b/core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt index 00945753e..6d3cbca6d 100644 --- a/core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt +++ b/core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt @@ -268,7 +268,7 @@ class MainActivityIntent(context: Context) : Intent() { /** * Switches the active account to the provided accountId and then stays on MainActivity */ - fun switchAccount(context: Context, pachliAccountId: Long) = MainActivityIntent(context).apply { + private fun switchAccount(context: Context, pachliAccountId: Long) = MainActivityIntent(context).apply { putExtra(EXTRA_PACHLI_ACCOUNT_ID, pachliAccountId) } @@ -300,6 +300,7 @@ class MainActivityIntent(context: Context) : Intent() { putExtra(EXTRA_COMPOSE_OPTIONS, options) putExtra(EXTRA_NOTIFICATION_TAG, notificationTag) putExtra(EXTRA_NOTIFICATION_ID, notificationId) + flags = FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_CLEAR_TASK } /**