mirror of
https://github.com/element-hq/element-android
synced 2024-11-25 02:45:37 +03:00
SoftLogout: clear notifications
This commit is contained in:
parent
d2fea275d8
commit
b9e8da1fbb
2 changed files with 18 additions and 8 deletions
|
@ -32,6 +32,7 @@ import im.vector.riotx.core.platform.VectorBaseActivity
|
|||
import im.vector.riotx.core.utils.deleteAllFiles
|
||||
import im.vector.riotx.features.home.HomeActivity
|
||||
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.SoftLogoutActivity
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
@ -50,6 +51,11 @@ data class MainActivityArgs(
|
|||
val isSoftLogout: Boolean = false
|
||||
) : 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() {
|
||||
|
||||
companion object {
|
||||
|
@ -67,6 +73,7 @@ class MainActivity : VectorBaseActivity() {
|
|||
|
||||
private lateinit var args: MainActivityArgs
|
||||
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
|
||||
|
@ -78,6 +85,10 @@ class MainActivity : VectorBaseActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
args = parseArgs()
|
||||
|
||||
if (args.clearCredentials || args.isUserLoggedOut) {
|
||||
clearNotifications()
|
||||
}
|
||||
|
||||
// Handle some wanted cleanup
|
||||
if (args.clearCache || args.clearCredentials) {
|
||||
doCleanUp()
|
||||
|
@ -86,6 +97,12 @@ class MainActivity : VectorBaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun clearNotifications() {
|
||||
// Dismiss all notifications
|
||||
notificationDrawerManager.clearAllEvents()
|
||||
notificationDrawerManager.persistInfo()
|
||||
}
|
||||
|
||||
private fun parseArgs(): MainActivityArgs {
|
||||
val argsFromIntent: MainActivityArgs? = intent.getParcelableExtra(EXTRA_ARGS)
|
||||
Timber.w("Starting MainActivity with $argsFromIntent")
|
||||
|
@ -171,7 +188,7 @@ class MainActivity : VectorBaseActivity() {
|
|||
sessionHolder.hasActiveSession() ->
|
||||
// We have a session.
|
||||
// Check it can be opened
|
||||
if(sessionHolder.getActiveSession().isOpenable) {
|
||||
if (sessionHolder.getActiveSession().isOpenable) {
|
||||
HomeActivity.newIntent(this)
|
||||
} else {
|
||||
// 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.features.MainActivity
|
||||
import im.vector.riotx.features.MainActivityArgs
|
||||
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
||||
|
||||
class SignOutUiWorker(private val activity: FragmentActivity) {
|
||||
|
||||
lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
fun perform(context: Context) {
|
||||
notificationDrawerManager = context.vectorComponent().notificationDrawerManager()
|
||||
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
||||
val session = activeSessionHolder.getActiveSession()
|
||||
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
||||
|
@ -55,10 +52,6 @@ class SignOutUiWorker(private val activity: FragmentActivity) {
|
|||
}
|
||||
|
||||
private fun doSignOut() {
|
||||
// Dismiss all notifications
|
||||
notificationDrawerManager.clearAllEvents()
|
||||
notificationDrawerManager.persistInfo()
|
||||
|
||||
MainActivity.restartApp(activity,
|
||||
MainActivityArgs(
|
||||
clearCache = true,
|
||||
|
|
Loading…
Reference in a new issue