Use setBackstack when starting new MainActivity from notification

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2022-04-02 20:58:07 +02:00 committed by Marcel Hibbe
parent a37d0476cf
commit 5dca8bcb7d
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 31 additions and 22 deletions

View File

@ -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)

View File

@ -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))