diff options
author | Dariusz Olszewski <starypatyk@users.noreply.github.com> | 2022-04-02 21:58:07 +0300 |
---|---|---|
committer | Marcel Hibbe <dev@mhibbe.de> | 2022-04-19 13:57:32 +0300 |
commit | 5dca8bcb7d182f4e6fe103dee6eb33855523a070 (patch) | |
tree | 3ab3fc652645816353c7f54c3c821facc6fc396e | |
parent | a37d0476cff980ca2b75801835531f5dbd2b1b0c (diff) |
Use setBackstack when starting new MainActivity from notification
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
-rw-r--r-- | app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt | 30 | ||||
-rw-r--r-- | app/src/main/java/com/nextcloud/talk/utils/ConductorRemapping.kt | 23 |
2 files changed, 31 insertions, 22 deletions
diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt index 4c825f1ee..06be3d52d 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt @@ -112,22 +112,11 @@ class MainActivity : BaseActivity(), ActionBarProvider { } if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { - if (!router!!.hasRootController()) { - router!!.setRoot( - RouterTransaction.with(ConversationsListController(Bundle())) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) - } onNewIntent(intent) } else if (!router!!.hasRootController()) { if (hasDb) { if (userUtils.anyUserExists()) { - router!!.setRoot( - RouterTransaction.with(ConversationsListController(Bundle())) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + setDefaultRootController() } else { if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) { router!!.pushController( @@ -191,13 +180,17 @@ class MainActivity : BaseActivity(), ActionBarProvider { super.onStop() } + private fun setDefaultRootController() { + router!!.setRoot( + RouterTransaction.with(ConversationsListController(Bundle())) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + fun resetConversationsList() { if (userUtils.anyUserExists()) { - router!!.setRoot( - RouterTransaction.with(ConversationsListController(Bundle())) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + setDefaultRootController() } } @@ -343,6 +336,9 @@ class MainActivity : BaseActivity(), ActionBarProvider { handleActionFromContact(intent) if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) { + if (!router!!.hasRootController()) { + setDefaultRootController() + } val callNotificationIntent = Intent(this, CallNotificationActivity::class.java) intent.extras?.let { callNotificationIntent.putExtras(it) } startActivity(callNotificationIntent) diff --git a/app/src/main/java/com/nextcloud/talk/utils/ConductorRemapping.kt b/app/src/main/java/com/nextcloud/talk/utils/ConductorRemapping.kt index 992473a85..1f95bdca2 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ConductorRemapping.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ConductorRemapping.kt @@ -26,6 +26,7 @@ import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler import com.nextcloud.talk.controllers.ChatController +import com.nextcloud.talk.controllers.ConversationsListController object ConductorRemapping { @@ -68,11 +69,23 @@ object ConductorRemapping { HorizontalChangeHandler() } if (!replaceTop) { - router.pushController( - RouterTransaction.with(ChatController(bundle)) - .pushChangeHandler(pushChangeHandler) - .popChangeHandler(HorizontalChangeHandler()).tag(tag) - ) + if (!router.hasRootController()) { + val newBackstack = listOf( + RouterTransaction.with(ConversationsListController(Bundle())) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()), + RouterTransaction.with(ChatController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()).tag(tag) + ) + router.setBackstack(newBackstack, SimpleSwapChangeHandler()) + } else { + router.pushController( + RouterTransaction.with(ChatController(bundle)) + .pushChangeHandler(pushChangeHandler) + .popChangeHandler(HorizontalChangeHandler()).tag(tag) + ) + } } else { router.replaceTopController( RouterTransaction.with(ChatController(bundle)) |