moving the soft logout activity starting to the navigator

This commit is contained in:
Adam Brown 2021-12-03 11:58:13 +00:00
parent 1aa532178e
commit a2a89c1ee8
3 changed files with 19 additions and 13 deletions

View File

@ -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<ActivityMainBinding>(), 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<ActivityMainBinding>(), 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<ActivityMainBinding>(), UnlockedActivity
intent?.let { startActivity(it) }
finish()
}
private fun getSoftLogoutActivityIntent(): Intent {
return if (resources.getBoolean(R.bool.useLoginV2)) {
SoftLogoutActivity2.newIntent(this)
} else {
SoftLogoutActivity.newIntent(this)
}
}
}

View File

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

View File

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