From a2a89c1ee8ae0ef0ba96f26513b5362e2eaf6ce6 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 3 Dec 2021 11:58:13 +0000 Subject: [PATCH] moving the soft logout activity starting to the navigator --- .../im/vector/app/features/MainActivity.kt | 19 ++++++------------- .../features/navigation/DefaultNavigator.kt | 11 +++++++++++ .../app/features/navigation/Navigator.kt | 2 ++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index f4c737c942..d3d51c3dbf 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -41,8 +41,6 @@ import im.vector.app.features.pin.UnlockedActivity import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.signout.hard.SignedOutActivity -import im.vector.app.features.signout.soft.SoftLogoutActivity -import im.vector.app.features.signout.soft.SoftLogoutActivity2 import im.vector.app.features.themes.ActivityOtherThemes import im.vector.app.features.ui.UiStateRepository import kotlinx.coroutines.Dispatchers @@ -223,9 +221,11 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity navigator.openLogin(this, null) null } - args.isSoftLogout -> + args.isSoftLogout -> { // The homeserver has invalidated the token, with a soft logout - getSoftLogoutActivityIntent() + navigator.softLogout(this) + null + } args.isUserLoggedOut -> // the homeserver has invalidated the token (password changed, device deleted, other security reasons) SignedOutActivity.newIntent(this) @@ -236,7 +236,8 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity HomeActivity.newIntent(this) } else { // The token is still invalid - getSoftLogoutActivityIntent() + navigator.softLogout(this) + null } else -> { // First start, or no active session @@ -247,12 +248,4 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity intent?.let { startActivity(it) } finish() } - - private fun getSoftLogoutActivityIntent(): Intent { - return if (resources.getBoolean(R.bool.useLoginV2)) { - SoftLogoutActivity2.newIntent(this) - } else { - SoftLogoutActivity.newIntent(this) - } - } } diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index 89a05c88da..2aec110221 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -77,6 +77,8 @@ import im.vector.app.features.roomprofile.RoomProfileActivity import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorSettingsActivity import im.vector.app.features.share.SharedData +import im.vector.app.features.signout.soft.SoftLogoutActivity +import im.vector.app.features.signout.soft.SoftLogoutActivity2 import im.vector.app.features.spaces.InviteRoomSpaceChooserBottomSheet import im.vector.app.features.spaces.SpaceExploreActivity import im.vector.app.features.spaces.SpacePreviewActivity @@ -115,6 +117,15 @@ class DefaultNavigator @Inject constructor( context.startActivity(intent) } + override fun softLogout(context: Context) { + val intent = if (context.resources.getBoolean(R.bool.useLoginV2)) { + SoftLogoutActivity2.newIntent(context) + } else { + SoftLogoutActivity.newIntent(context) + } + context.startActivity(intent) + } + override fun openRoom(context: Context, roomId: String, eventId: String?, buildTask: Boolean) { if (sessionHolder.getSafeActiveSession()?.getRoom(roomId) == null) { fatalError("Trying to open an unknown room $roomId", vectorPreferences.failFast()) diff --git a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt index 264593fe18..e0c6eb26bb 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt @@ -41,6 +41,8 @@ interface Navigator { fun openLogin(context: Context, loginConfig: LoginConfig? = null, flags: Int = 0) + fun softLogout(context: Context) + fun openRoom(context: Context, roomId: String, eventId: String? = null, buildTask: Boolean = false) sealed class PostSwitchSpaceAction {