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.core.view.isVisible
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
|
import com.airbnb.mvrx.viewModel
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.matrix.android.api.util.toMatrixItem
|
import im.vector.matrix.android.api.util.toMatrixItem
|
||||||
@ -59,6 +60,8 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
|
|
||||||
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
||||||
|
|
||||||
|
private val homeActivityViewModel: HomeActivityViewModel by viewModel()
|
||||||
|
|
||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
|
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
|
||||||
@Inject lateinit var pushManager: PushersManager
|
@Inject lateinit var pushManager: PushersManager
|
||||||
@ -117,7 +120,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
}
|
}
|
||||||
if (intent.getBooleanExtra(EXTRA_ACCOUNT_CREATION, false)) {
|
if (intent.getBooleanExtra(EXTRA_ACCOUNT_CREATION, false)) {
|
||||||
sharedActionViewModel.post(HomeActivitySharedAction.PromptForSecurityBootstrap)
|
sharedActionViewModel.post(HomeActivitySharedAction.PromptForSecurityBootstrap)
|
||||||
sharedActionViewModel.isAccountCreation = true
|
homeActivityViewModel.isAccountCreation = true
|
||||||
intent.removeExtra(EXTRA_ACCOUNT_CREATION)
|
intent.removeExtra(EXTRA_ACCOUNT_CREATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +129,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
waiting_view.isVisible = false
|
waiting_view.isVisible = false
|
||||||
promptCompleteSecurityIfNeeded()
|
promptCompleteSecurityIfNeeded()
|
||||||
} else {
|
} else {
|
||||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = false
|
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = false
|
||||||
Timber.v("${getString(status.statusText)} ${status.percentProgress}")
|
Timber.v("${getString(status.statusText)} ${status.percentProgress}")
|
||||||
waiting_view.setOnClickListener {
|
waiting_view.setOnClickListener {
|
||||||
// block interactions
|
// block interactions
|
||||||
@ -146,7 +149,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Ask again if the app is relaunched
|
// Ask again if the app is relaunched
|
||||||
if (!sharedActionViewModel.hasDisplayedCompleteSecurityPrompt
|
if (!homeActivityViewModel.hasDisplayedCompleteSecurityPrompt
|
||||||
&& activeSessionHolder.getSafeActiveSession()?.hasAlreadySynced() == true) {
|
&& activeSessionHolder.getSafeActiveSession()?.hasAlreadySynced() == true) {
|
||||||
promptCompleteSecurityIfNeeded()
|
promptCompleteSecurityIfNeeded()
|
||||||
}
|
}
|
||||||
@ -158,7 +161,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
private fun promptCompleteSecurityIfNeeded() {
|
private fun promptCompleteSecurityIfNeeded() {
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
if (!session.hasAlreadySynced()) return
|
if (!session.hasAlreadySynced()) return
|
||||||
if (sharedActionViewModel.hasDisplayedCompleteSecurityPrompt) return
|
if (homeActivityViewModel.hasDisplayedCompleteSecurityPrompt) return
|
||||||
|
|
||||||
// ensure keys are downloaded
|
// ensure keys are downloaded
|
||||||
session.cryptoService().downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
session.cryptoService().downloadKeys(listOf(session.myUserId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {
|
||||||
@ -175,7 +178,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
.getMyCrossSigningKeys()
|
.getMyCrossSigningKeys()
|
||||||
val crossSigningEnabledOnAccount = myCrossSigningKeys != null
|
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
|
// Do not propose for SSO accounts, because we do not support yet confirming account credentials using SSO
|
||||||
if (session.getHomeServerCapabilities().canChangePassword) {
|
if (session.getHomeServerCapabilities().canChangePassword) {
|
||||||
// We need to ask
|
// We need to ask
|
||||||
@ -188,7 +191,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Do not do it again
|
// Do not do it again
|
||||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true
|
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||||
}
|
}
|
||||||
} else if (myCrossSigningKeys?.isTrusted() == false) {
|
} else if (myCrossSigningKeys?.isTrusted() == false) {
|
||||||
// We need to ask
|
// 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)) {
|
private fun promptSecurityEvent(session: Session, titleRes: Int, descRes: Int, action: ((VectorBaseActivity) -> Unit)) {
|
||||||
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true
|
homeActivityViewModel.hasDisplayedCompleteSecurityPrompt = true
|
||||||
popupAlertManager.postVectorAlert(
|
popupAlertManager.postVectorAlert(
|
||||||
VerificationVectorAlert(
|
VerificationVectorAlert(
|
||||||
uid = "upgradeSecurity",
|
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 im.vector.riotx.core.platform.VectorSharedActionViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>() {
|
class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel<HomeActivitySharedAction>()
|
||||||
var hasDisplayedCompleteSecurityPrompt : Boolean = false
|
|
||||||
var isAccountCreation : Boolean = false
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user