diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index cd4481efea..98d055bee7 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -17,6 +17,7 @@ package im.vector.matrix.rx import androidx.paging.PagedList +import im.vector.matrix.android.api.extensions.orFalse import im.vector.matrix.android.api.query.QueryStringValue import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME @@ -172,16 +173,6 @@ class RxSession(private val session: Session) { } } - data class SecretsSynchronisationInfo( - val isBackupSetup: Boolean = false, - val isCrossSigningEnabled: Boolean = false, - val isCrossSigningTrusted: Boolean = false, - val allPrivateKeysKnown: Boolean = false, - val megolmBackupAvailable: Boolean = false, - val megolmSecretKnown: Boolean = false, - val isMegolmKeyIn4S: Boolean = false - ) - fun liveSecretSynchronisationInfo(): Observable { return Observable.combineLatest, Optional, Optional, SecretsSynchronisationInfo>( liveAccountData(setOf(MASTER_KEY_SSSS_NAME, USER_SIGNING_KEY_SSSS_NAME, SELF_SIGNING_KEY_SSSS_NAME, KEYBACKUP_SECRET_SSSS_NAME)), @@ -192,9 +183,9 @@ class RxSession(private val session: Session) { val is4SSetup = session.sharedSecretStorageService.isRecoverySetup() val isCrossSigningEnabled = crossSigningInfo.getOrNull() != null val isCrossSigningTrusted = crossSigningInfo.getOrNull()?.isTrusted() == true - val allPrivateKeysKnown = pInfo.getOrNull()?.master != null - && pInfo.getOrNull()?.selfSigned != null - && pInfo.getOrNull()?.user != null + val allPrivateKeysKnown = pInfo.getOrNull() + ?.let { it.master != null && it.selfSigned != null && it.user != null } + .orFalse() val keysBackupService = session.cryptoService().keysBackupService() val currentBackupVersion = keysBackupService.currentBackupVersion diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/SecretsSynchronisationInfo.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/SecretsSynchronisationInfo.kt new file mode 100644 index 0000000000..616783706b --- /dev/null +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/SecretsSynchronisationInfo.kt @@ -0,0 +1,27 @@ +/* + * 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.matrix.rx + +data class SecretsSynchronisationInfo( + val isBackupSetup: Boolean, + val isCrossSigningEnabled: Boolean, + val isCrossSigningTrusted: Boolean, + val allPrivateKeysKnown: Boolean, + val megolmBackupAvailable: Boolean, + val megolmSecretKnown: Boolean, + val isMegolmKeyIn4S: Boolean +) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 0c4a0404d7..858b5eee76 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -33,7 +33,7 @@ import im.vector.matrix.android.internal.crypto.crosssigning.isVerified import im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse -import im.vector.matrix.rx.RxSession +import im.vector.matrix.rx.SecretsSynchronisationInfo import im.vector.matrix.rx.rx import im.vector.riotx.R import im.vector.riotx.core.di.ActiveSessionHolder @@ -128,7 +128,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( disposables.clear() } - private fun refresh4SSection(state: RxSession.SecretsSynchronisationInfo) { + private fun refresh4SSection(state: SecretsSynchronisationInfo) { secureBackupCategory?.isVisible = false // it's a lot of if / else if / else