SoftLogout: clear notifications
This commit is contained in:
parent
d2fea275d8
commit
b9e8da1fbb
|
@ -32,6 +32,7 @@ import im.vector.riotx.core.platform.VectorBaseActivity
|
||||||
import im.vector.riotx.core.utils.deleteAllFiles
|
import im.vector.riotx.core.utils.deleteAllFiles
|
||||||
import im.vector.riotx.features.home.HomeActivity
|
import im.vector.riotx.features.home.HomeActivity
|
||||||
import im.vector.riotx.features.login.LoginActivity
|
import im.vector.riotx.features.login.LoginActivity
|
||||||
|
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.riotx.features.signout.SignedOutActivity
|
import im.vector.riotx.features.signout.SignedOutActivity
|
||||||
import im.vector.riotx.features.signout.SoftLogoutActivity
|
import im.vector.riotx.features.signout.SoftLogoutActivity
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
@ -50,6 +51,11 @@ data class MainActivityArgs(
|
||||||
val isSoftLogout: Boolean = false
|
val isSoftLogout: Boolean = false
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the entry point of RiotX
|
||||||
|
* This Activity, when started with argument, is also doing some cleanup when user disconnects,
|
||||||
|
* clears cache, is logged out, or is soft logged out
|
||||||
|
*/
|
||||||
class MainActivity : VectorBaseActivity() {
|
class MainActivity : VectorBaseActivity() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -67,6 +73,7 @@ class MainActivity : VectorBaseActivity() {
|
||||||
|
|
||||||
private lateinit var args: MainActivityArgs
|
private lateinit var args: MainActivityArgs
|
||||||
|
|
||||||
|
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||||
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||||
|
|
||||||
|
@ -78,6 +85,10 @@ class MainActivity : VectorBaseActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
args = parseArgs()
|
args = parseArgs()
|
||||||
|
|
||||||
|
if (args.clearCredentials || args.isUserLoggedOut) {
|
||||||
|
clearNotifications()
|
||||||
|
}
|
||||||
|
|
||||||
// Handle some wanted cleanup
|
// Handle some wanted cleanup
|
||||||
if (args.clearCache || args.clearCredentials) {
|
if (args.clearCache || args.clearCredentials) {
|
||||||
doCleanUp()
|
doCleanUp()
|
||||||
|
@ -86,6 +97,12 @@ class MainActivity : VectorBaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun clearNotifications() {
|
||||||
|
// Dismiss all notifications
|
||||||
|
notificationDrawerManager.clearAllEvents()
|
||||||
|
notificationDrawerManager.persistInfo()
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseArgs(): MainActivityArgs {
|
private fun parseArgs(): MainActivityArgs {
|
||||||
val argsFromIntent: MainActivityArgs? = intent.getParcelableExtra(EXTRA_ARGS)
|
val argsFromIntent: MainActivityArgs? = intent.getParcelableExtra(EXTRA_ARGS)
|
||||||
Timber.w("Starting MainActivity with $argsFromIntent")
|
Timber.w("Starting MainActivity with $argsFromIntent")
|
||||||
|
@ -171,7 +188,7 @@ class MainActivity : VectorBaseActivity() {
|
||||||
sessionHolder.hasActiveSession() ->
|
sessionHolder.hasActiveSession() ->
|
||||||
// We have a session.
|
// We have a session.
|
||||||
// Check it can be opened
|
// Check it can be opened
|
||||||
if(sessionHolder.getActiveSession().isOpenable) {
|
if (sessionHolder.getActiveSession().isOpenable) {
|
||||||
HomeActivity.newIntent(this)
|
HomeActivity.newIntent(this)
|
||||||
} else {
|
} else {
|
||||||
// The token is still invalid
|
// The token is still invalid
|
||||||
|
|
|
@ -24,15 +24,12 @@ import im.vector.riotx.core.di.ActiveSessionHolder
|
||||||
import im.vector.riotx.core.extensions.vectorComponent
|
import im.vector.riotx.core.extensions.vectorComponent
|
||||||
import im.vector.riotx.features.MainActivity
|
import im.vector.riotx.features.MainActivity
|
||||||
import im.vector.riotx.features.MainActivityArgs
|
import im.vector.riotx.features.MainActivityArgs
|
||||||
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
|
||||||
|
|
||||||
class SignOutUiWorker(private val activity: FragmentActivity) {
|
class SignOutUiWorker(private val activity: FragmentActivity) {
|
||||||
|
|
||||||
lateinit var notificationDrawerManager: NotificationDrawerManager
|
|
||||||
lateinit var activeSessionHolder: ActiveSessionHolder
|
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
|
||||||
fun perform(context: Context) {
|
fun perform(context: Context) {
|
||||||
notificationDrawerManager = context.vectorComponent().notificationDrawerManager()
|
|
||||||
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
||||||
val session = activeSessionHolder.getActiveSession()
|
val session = activeSessionHolder.getActiveSession()
|
||||||
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
||||||
|
@ -55,10 +52,6 @@ class SignOutUiWorker(private val activity: FragmentActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doSignOut() {
|
private fun doSignOut() {
|
||||||
// Dismiss all notifications
|
|
||||||
notificationDrawerManager.clearAllEvents()
|
|
||||||
notificationDrawerManager.persistInfo()
|
|
||||||
|
|
||||||
MainActivity.restartApp(activity,
|
MainActivity.restartApp(activity,
|
||||||
MainActivityArgs(
|
MainActivityArgs(
|
||||||
clearCache = true,
|
clearCache = true,
|
||||||
|
|
Loading…
Reference in New Issue