mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 10:25:51 +03:00
cleaning
This commit is contained in:
parent
5f069264d0
commit
065ee1d2f5
3 changed files with 39 additions and 27 deletions
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -71,7 +71,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
allowDeviceAction = args.allowDeviceAction,
|
allowDeviceAction = args.allowDeviceAction,
|
||||||
userItem = session.getUserOrDefault(userId).toMatrixItem(),
|
userItem = session.getUserOrDefault(userId).toMatrixItem(),
|
||||||
myDeviceId = session.sessionParams.deviceId ?: "",
|
myDeviceId = session.sessionParams.deviceId,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.getElementWellknown
|
||||||
import im.vector.app.features.raw.wellknown.isE2EByDefault
|
import im.vector.app.features.raw.wellknown.isE2EByDefault
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import me.gujun.android.span.span
|
import me.gujun.android.span.span
|
||||||
import org.matrix.android.sdk.api.extensions.getFingerprintHumanReadable
|
import org.matrix.android.sdk.api.extensions.getFingerprintHumanReadable
|
||||||
import org.matrix.android.sdk.api.raw.RawService
|
import org.matrix.android.sdk.api.raw.RawService
|
||||||
|
@ -175,9 +177,6 @@ class VectorSettingsSecurityPrivacyFragment :
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
// My device name may have been updated
|
|
||||||
refreshMyDevice()
|
|
||||||
refreshXSigningStatus()
|
|
||||||
session.liveSecretSynchronisationInfo()
|
session.liveSecretSynchronisationInfo()
|
||||||
.onEach {
|
.onEach {
|
||||||
refresh4SSection(it)
|
refresh4SSection(it)
|
||||||
|
@ -288,7 +287,18 @@ class VectorSettingsSecurityPrivacyFragment :
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||||
refreshXSigningStatus()
|
refreshXSigningStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||||
|
// My device name may have been updated
|
||||||
|
refreshMyDevice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
secureBackupPreference.icon = activity?.let {
|
secureBackupPreference.icon = activity?.let {
|
||||||
ThemeUtils.tintDrawable(
|
ThemeUtils.tintDrawable(
|
||||||
|
@ -349,13 +359,13 @@ class VectorSettingsSecurityPrivacyFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo this should be refactored and use same state as 4S section
|
// Todo this should be refactored and use same state as 4S section
|
||||||
private fun refreshXSigningStatus() {
|
private suspend fun refreshXSigningStatus() {
|
||||||
lifecycleScope.launchWhenResumed {
|
|
||||||
val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys()
|
val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys()
|
||||||
val xSigningIsEnableInAccount = crossSigningKeys != null
|
val xSigningIsEnableInAccount = crossSigningKeys != null
|
||||||
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
|
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
|
||||||
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
|
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
|
||||||
|
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
when {
|
when {
|
||||||
xSigningKeyCanSign -> {
|
xSigningKeyCanSign -> {
|
||||||
mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_trusted)
|
mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_trusted)
|
||||||
|
@ -623,8 +633,7 @@ class VectorSettingsSecurityPrivacyFragment :
|
||||||
// devices list
|
// devices list
|
||||||
// ==============================================================================================================
|
// ==============================================================================================================
|
||||||
|
|
||||||
private fun refreshMyDevice() {
|
private suspend fun refreshMyDevice() {
|
||||||
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
|
|
||||||
session.cryptoService().getUserDevices(session.myUserId).map {
|
session.cryptoService().getUserDevices(session.myUserId).map {
|
||||||
DeviceInfo(
|
DeviceInfo(
|
||||||
userId = session.myUserId,
|
userId = session.myUserId,
|
||||||
|
@ -632,10 +641,13 @@ class VectorSettingsSecurityPrivacyFragment :
|
||||||
displayName = it.displayName()
|
displayName = it.displayName()
|
||||||
)
|
)
|
||||||
}.let {
|
}.let {
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
refreshCryptographyPreference(it)
|
refreshCryptographyPreference(it)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// TODO Move to a ViewModel...
|
// TODO Move to a ViewModel...
|
||||||
val devicesList = session.cryptoService().fetchDevicesList()
|
val devicesList = session.cryptoService().fetchDevicesList()
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
refreshCryptographyPreference(devicesList)
|
refreshCryptographyPreference(devicesList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue