Reuse injected members in parent activity.
This commit is contained in:
parent
f95d21ef17
commit
cbd0972eca
|
@ -26,7 +26,6 @@ import androidx.core.app.Person
|
|||
import androidx.core.content.getSystemService
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.core.time.Clock
|
||||
|
@ -59,9 +58,6 @@ class DebugMenuActivity : VectorBaseActivity<ActivityDebugMenuBinding>() {
|
|||
|
||||
override fun getBinding() = ActivityDebugMenuBinding.inflate(layoutInflater)
|
||||
|
||||
@Inject
|
||||
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
@Inject
|
||||
lateinit var clock: Clock
|
||||
|
||||
|
|
|
@ -131,13 +131,10 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||
private lateinit var args: MainActivityArgs
|
||||
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||
@Inject lateinit var uiStateRepository: UiStateRepository
|
||||
@Inject lateinit var shortcutsHandler: ShortcutsHandler
|
||||
@Inject lateinit var pinCodeHelper: PinCodeHelper
|
||||
@Inject lateinit var pinLocker: PinLocker
|
||||
@Inject lateinit var popupAlertManager: PopupAlertManager
|
||||
@Inject lateinit var vectorAnalytics: VectorAnalytics
|
||||
@Inject lateinit var lockScreenKeyRepository: LockScreenKeyRepository
|
||||
|
@ -232,7 +229,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||
}
|
||||
|
||||
private fun doCleanUp() {
|
||||
val session = sessionHolder.getSafeActiveSession()
|
||||
val session = activeSessionHolder.getSafeActiveSession()
|
||||
if (session == null) {
|
||||
startNextActivityAndFinish()
|
||||
return
|
||||
|
@ -244,7 +241,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||
lifecycleScope.launch {
|
||||
// Just do the local cleanup
|
||||
Timber.w("Account deactivated, start app")
|
||||
sessionHolder.clearActiveSession()
|
||||
activeSessionHolder.clearActiveSession()
|
||||
doLocalCleanup(clearPreferences = true, onboardingStore)
|
||||
startNextActivityAndFinish()
|
||||
}
|
||||
|
@ -258,7 +255,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||
return@launch
|
||||
}
|
||||
Timber.w("SIGN_OUT: success, start app")
|
||||
sessionHolder.clearActiveSession()
|
||||
activeSessionHolder.clearActiveSession()
|
||||
doLocalCleanup(clearPreferences = true, onboardingStore)
|
||||
startNextActivityAndFinish()
|
||||
}
|
||||
|
@ -330,10 +327,10 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||
args.isUserLoggedOut ->
|
||||
// the homeserver has invalidated the token (password changed, device deleted, other security reasons)
|
||||
SignedOutActivity.newIntent(this)
|
||||
sessionHolder.hasActiveSession() ->
|
||||
activeSessionHolder.hasActiveSession() ->
|
||||
// We have a session.
|
||||
// Check it can be opened
|
||||
if (sessionHolder.getActiveSession().isOpenable) {
|
||||
if (activeSessionHolder.getActiveSession().isOpenable) {
|
||||
HomeActivity.newIntent(this, firstStartMainActivity = false, existingSession = true)
|
||||
} else {
|
||||
// The token is still invalid
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.airbnb.mvrx.viewModel
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.addFragmentToBackstack
|
||||
import im.vector.app.core.extensions.observeEvent
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
|
@ -32,7 +31,6 @@ import im.vector.app.features.crypto.quads.SharedSecureStorageActivity
|
|||
import im.vector.app.features.workers.signout.ServerBackupStatusAction
|
||||
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class KeysBackupRestoreActivity : SimpleFragmentActivity() {
|
||||
|
@ -56,8 +54,6 @@ class KeysBackupRestoreActivity : SimpleFragmentActivity() {
|
|||
super.onBackPressed()
|
||||
}
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
override fun initUiAndData() {
|
||||
super.initUiAndData()
|
||||
viewModel = viewModelProvider.get(KeysBackupRestoreSharedViewModel::class.java)
|
||||
|
|
|
@ -25,7 +25,6 @@ import androidx.lifecycle.lifecycleScope
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.dialogs.ExportKeysDialog
|
||||
import im.vector.app.core.extensions.observeEvent
|
||||
import im.vector.app.core.extensions.queryExportKeys
|
||||
|
@ -45,7 +44,6 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() {
|
|||
private lateinit var viewModel: KeysBackupSetupSharedViewModel
|
||||
|
||||
@Inject lateinit var keysExporter: KeysExporter
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
private val session by lazy {
|
||||
activeSessionHolder.getActiveSession()
|
||||
|
|
|
@ -37,7 +37,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.SpaceStateHandler
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.hideKeyboard
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
import im.vector.app.core.extensions.replaceFragment
|
||||
|
@ -77,7 +76,6 @@ import im.vector.app.features.popup.PopupAlertManager
|
|||
import im.vector.app.features.popup.VerificationVectorAlert
|
||||
import im.vector.app.features.rageshake.ReportType
|
||||
import im.vector.app.features.rageshake.VectorUncaughtExceptionHandler
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import im.vector.app.features.spaces.SpaceCreationActivity
|
||||
import im.vector.app.features.spaces.SpacePreviewActivity
|
||||
|
@ -129,11 +127,9 @@ class HomeActivity :
|
|||
|
||||
private val serverBackupStatusViewModel: ServerBackupStatusViewModel by viewModel()
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
|
||||
@Inject lateinit var pushersManager: PushersManager
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||
@Inject lateinit var popupAlertManager: PopupAlertManager
|
||||
@Inject lateinit var shortcutsHandler: ShortcutsHandler
|
||||
@Inject lateinit var permalinkHandler: PermalinkHandler
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.airbnb.mvrx.viewModel
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
|
@ -46,7 +45,6 @@ import javax.inject.Inject
|
|||
@AndroidEntryPoint
|
||||
class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
||||
|
||||
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
@Inject lateinit var permalinkHandler: PermalinkHandler
|
||||
|
||||
|
@ -103,7 +101,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
}
|
||||
|
||||
private fun handleConfigUrl(uri: Uri) {
|
||||
if (sessionHolder.hasActiveSession()) {
|
||||
if (activeSessionHolder.hasActiveSession()) {
|
||||
displayAlreadyLoginPopup(uri)
|
||||
} else {
|
||||
// user is not yet logged in, this is the nominal case
|
||||
|
@ -114,7 +112,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
private fun handleSupportedHostUrl() {
|
||||
// If we are not logged in, open login screen.
|
||||
// In the future, we might want to relaunch the process after login.
|
||||
if (!sessionHolder.hasActiveSession()) {
|
||||
if (!activeSessionHolder.hasActiveSession()) {
|
||||
startLoginActivity()
|
||||
return
|
||||
}
|
||||
|
@ -152,7 +150,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
}
|
||||
|
||||
private fun safeSignout(uri: Uri) {
|
||||
val session = sessionHolder.getSafeActiveSession()
|
||||
val session = activeSessionHolder.getSafeActiveSession()
|
||||
if (session == null) {
|
||||
// Should not happen
|
||||
startLoginActivity(uri)
|
||||
|
@ -161,7 +159,7 @@ class LinkHandlerActivity : VectorBaseActivity<ActivityProgressBinding>() {
|
|||
try {
|
||||
session.signOutService().signOut(true)
|
||||
Timber.d("## displayAlreadyLoginPopup(): logout succeeded")
|
||||
sessionHolder.clearActiveSession()
|
||||
activeSessionHolder.clearActiveSession()
|
||||
startLoginActivity(uri)
|
||||
} catch (failure: Throwable) {
|
||||
displayError(failure)
|
||||
|
|
|
@ -20,22 +20,18 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.addFragment
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivitySimpleBinding
|
||||
import im.vector.app.features.MainActivity
|
||||
import im.vector.app.features.start.StartAppViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class IncomingShareActivity : VectorBaseActivity<ActivitySimpleBinding>() {
|
||||
|
||||
private val startAppViewModel: StartAppViewModel by viewModel()
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
private val launcher = registerStartForActivityResult {
|
||||
if (it.resultCode == RESULT_OK) {
|
||||
handleAppStarted()
|
||||
|
|
|
@ -21,12 +21,10 @@ import android.content.Intent
|
|||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebView
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivityVectorWebViewBinding
|
||||
import im.vector.lib.core.utils.compat.getSerializableCompat
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* This class is responsible for managing a WebView
|
||||
|
@ -39,7 +37,6 @@ class VectorWebViewActivity : VectorBaseActivity<ActivityVectorWebViewBinding>()
|
|||
|
||||
override fun getBinding() = ActivityVectorWebViewBinding.inflate(layoutInflater)
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
val session: Session by lazy {
|
||||
activeSessionHolder.getActiveSession()
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import im.vector.app.R
|
|||
import im.vector.app.core.extensions.addFragment
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivityWidgetBinding
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet
|
||||
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewEvents
|
||||
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewModel
|
||||
|
@ -48,7 +47,6 @@ import im.vector.lib.core.utils.compat.getSerializableCompat
|
|||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.events.model.Content
|
||||
import java.io.Serializable
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
||||
|
@ -83,8 +81,6 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
|||
private val viewModel: WidgetViewModel by viewModel()
|
||||
private val permissionViewModel: RoomWidgetPermissionViewModel by viewModel()
|
||||
|
||||
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||
|
||||
override fun getBinding() = ActivityWidgetBinding.inflate(layoutInflater)
|
||||
|
||||
override fun getTitleRes() = R.string.room_widget_activity_title
|
||||
|
|
Loading…
Reference in New Issue