This commit is contained in:
valere 2023-03-14 12:07:39 +01:00
parent 5f069264d0
commit 065ee1d2f5
3 changed files with 39 additions and 27 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 New Vector Ltd
* Copyright (c) 2023 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -71,7 +71,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
userId = userId,
allowDeviceAction = args.allowDeviceAction,
userItem = session.getUserOrDefault(userId).toMatrixItem(),
myDeviceId = session.sessionParams.deviceId ?: "",
myDeviceId = session.sessionParams.deviceId,
)
}
}

View file

@ -69,9 +69,11 @@ import im.vector.app.features.pin.PinMode
import im.vector.app.features.raw.wellknown.getElementWellknown
import im.vector.app.features.raw.wellknown.isE2EByDefault
import im.vector.app.features.themes.ThemeUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.gujun.android.span.span
import org.matrix.android.sdk.api.extensions.getFingerprintHumanReadable
import org.matrix.android.sdk.api.raw.RawService
@ -175,9 +177,6 @@ class VectorSettingsSecurityPrivacyFragment :
override fun onResume() {
super.onResume()
// My device name may have been updated
refreshMyDevice()
refreshXSigningStatus()
session.liveSecretSynchronisationInfo()
.onEach {
refresh4SSection(it)
@ -288,7 +287,18 @@ class VectorSettingsSecurityPrivacyFragment :
true
}
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
refreshXSigningStatus()
}
}
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
// My device name may have been updated
refreshMyDevice()
}
}
secureBackupPreference.icon = activity?.let {
ThemeUtils.tintDrawable(
@ -349,13 +359,13 @@ class VectorSettingsSecurityPrivacyFragment :
}
// Todo this should be refactored and use same state as 4S section
private fun refreshXSigningStatus() {
lifecycleScope.launchWhenResumed {
private suspend fun refreshXSigningStatus() {
val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys()
val xSigningIsEnableInAccount = crossSigningKeys != null
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
withContext(Dispatchers.Main) {
when {
xSigningKeyCanSign -> {
mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_trusted)
@ -623,8 +633,7 @@ class VectorSettingsSecurityPrivacyFragment :
// devices list
// ==============================================================================================================
private fun refreshMyDevice() {
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
private suspend fun refreshMyDevice() {
session.cryptoService().getUserDevices(session.myUserId).map {
DeviceInfo(
userId = session.myUserId,
@ -632,10 +641,13 @@ class VectorSettingsSecurityPrivacyFragment :
displayName = it.displayName()
)
}.let {
withContext(Dispatchers.Main) {
refreshCryptographyPreference(it)
}
}
// TODO Move to a ViewModel...
val devicesList = session.cryptoService().fetchDevicesList()
withContext(Dispatchers.Main) {
refreshCryptographyPreference(devicesList)
}
}