Cleanup
This commit is contained in:
parent
1cd27d7f67
commit
1365240f69
|
@ -27,6 +27,7 @@ import androidx.core.view.GravityCompat
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.lifecycle.Observer
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.util.toMatrixItem
|
||||
|
@ -59,6 +60,8 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
|
||||
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
||||
|
||||
private val homeActivityViewModel: HomeActivityViewModel by viewModel()
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
|
||||
@Inject lateinit var pushManager: PushersManager
|
||||
|
@ -117,7 +120,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
}
|
||||
if (intent.getBooleanExtra(EXTRA_ACCOUNT_CREATION, false)) {
|
||||
sharedActionViewModel.post(HomeActivitySharedAction.PromptForSecurityBootstrap)
|
||||
sharedActionViewModel.isAccountCreation = true
|
||||
homeActivityViewModel.isAccountCreation = true
|
||||
intent.removeExtra(EXTRA_ACCOUNT_CREATION)
|
||||
}
|
||||
|
||||
|
@ -126,7 +129,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
waiting_view.isVisible = false
|
||||
promptCompleteSecurityIfNeeded()
|
||||
} else {
|
||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = false
|
||||
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = false
|
||||
Timber.v("${getString(status.statusText)} ${status.percentProgress}")
|
||||
waiting_view.setOnClickListener {
|
||||
// block interactions
|
||||
|
@ -146,7 +149,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
})
|
||||
|
||||
// Ask again if the app is relaunched
|
||||
if (!sharedActionViewModel.hasDisplayedCompleteSecurityPrompt
|
||||
if (!homeActivityViewModel.hasDisplayedCompleteSecurityPrompt
|
||||
&& activeSessionHolder.getSafeActiveSession()?.hasAlreadySynced() == true) {
|
||||
promptCompleteSecurityIfNeeded()
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
private fun promptCompleteSecurityIfNeeded() {
|
||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
if (!session.hasAlreadySynced()) return
|
||||
if (sharedActionViewModel.hasDisplayedCompleteSecurityPrompt) return
|
||||
if (homeActivityViewModel.hasDisplayedCompleteSecurityPrompt) return
|
||||
|
||||
// ensure keys are downloaded
|
||||
session.cryptoService().downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||
|
@ -175,7 +178,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
.getMyCrossSigningKeys()
|
||||
val crossSigningEnabledOnAccount = myCrossSigningKeys != null
|
||||
|
||||
if (!crossSigningEnabledOnAccount && !sharedActionViewModel.isAccountCreation) {
|
||||
if (!crossSigningEnabledOnAccount && !homeActivityViewModel.isAccountCreation) {
|
||||
// Do not propose for SSO accounts, because we do not support yet confirming account credentials using SSO
|
||||
if (session.getHomeServerCapabilities().canChangePassword) {
|
||||
// We need to ask
|
||||
|
@ -188,7 +191,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
}
|
||||
} else {
|
||||
// Do not do it again
|
||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||
}
|
||||
} else if (myCrossSigningKeys?.isTrusted() == false) {
|
||||
// We need to ask
|
||||
|
@ -203,7 +206,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||
}
|
||||
|
||||
private fun promptSecurityEvent(session: Session, titleRes: Int, descRes: Int, action: ((VectorBaseActivity) -> Unit)) {
|
||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||
popupAlertManager.postVectorAlert(
|
||||
VerificationVectorAlert(
|
||||
uid = "upgradeSecurity",
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2020 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.features.home
|
||||
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
import im.vector.riotx.core.platform.EmptyAction
|
||||
import im.vector.riotx.core.platform.EmptyViewEvents
|
||||
import im.vector.riotx.core.platform.VectorViewModel
|
||||
|
||||
data class EmptyState(
|
||||
val dummy: Boolean = false
|
||||
) : MvRxState
|
||||
|
||||
class HomeActivityViewModel : VectorViewModel<EmptyState, EmptyAction, EmptyViewEvents>(EmptyState()) {
|
||||
var hasDisplayedCompleteSecurityPrompt: Boolean = false
|
||||
var isAccountCreation: Boolean = false
|
||||
|
||||
override fun handle(action: EmptyAction) {
|
||||
// NA
|
||||
}
|
||||
}
|
|
@ -19,7 +19,4 @@ package im.vector.riotx.features.home
|
|||
import im.vector.riotx.core.platform.VectorSharedActionViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>() {
|
||||
var hasDisplayedCompleteSecurityPrompt : Boolean = false
|
||||
var isAccountCreation : Boolean = false
|
||||
}
|
||||
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>()
|
||||
|
|
Loading…
Reference in New Issue