From 6c10a9bf2d05eb57a21a0d67fdad5ec0e12d4242 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Fri, 14 Oct 2022 18:10:18 +0300 Subject: [PATCH] Code review fixes. --- library/ui-strings/src/main/res/values/strings.xml | 2 +- .../internal/database/RealmSessionStoreMigration.kt | 4 +++- .../homeserver/GetHomeServerCapabilitiesTask.kt | 6 +++--- .../debug/features/DebugFeaturesStateFactory.kt | 8 ++++---- .../features/debug/features/DebugVectorFeatures.kt | 12 ++++++------ .../java/im/vector/app/features/VectorFeatures.kt | 8 ++++---- .../app/features/onboarding/OnboardingViewModel.kt | 2 +- .../devices/v2/VectorSettingsDevicesFragment.kt | 2 +- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 2bee5a0e9c..a13db6a6db 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3331,7 +3331,7 @@ Session name Custom session names can help you recognize your devices more easily. Please be aware that session names are also visible to people you communicate with. - SIGN IN WITH QR CODE + Sign in with QR Code You can use this device to sign in a mobile or web device with a QR code. There are two ways to do this: Inactive sessions diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt index aef482ae2e..9a2c32f97c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt @@ -55,6 +55,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo035 import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo036 import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo037 import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo038 +import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo039 import org.matrix.android.sdk.internal.util.Normalizer import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration import javax.inject.Inject @@ -63,7 +64,7 @@ internal class RealmSessionStoreMigration @Inject constructor( private val normalizer: Normalizer ) : MatrixRealmMigration( dbName = "Session", - schemaVersion = 38L, + schemaVersion = 39L, ) { /** * Forces all RealmSessionStoreMigration instances to be equal. @@ -111,5 +112,6 @@ internal class RealmSessionStoreMigration @Inject constructor( if (oldVersion < 36) MigrateSessionTo036(realm).perform() if (oldVersion < 37) MigrateSessionTo037(realm).perform() if (oldVersion < 38) MigrateSessionTo038(realm).perform() + if (oldVersion < 39) MigrateSessionTo039(realm).perform() } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt index c9a342777b..d65e629b71 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt @@ -133,9 +133,6 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor( homeServerCapabilitiesEntity.roomVersionsJson = capabilities?.roomVersions?.let { MoshiProvider.providesMoshi().adapter(RoomVersions::class.java).toJson(it) } - homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */ - getVersionResult?.doesServerSupportThreads().orFalse() - homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult?.doesServerSupportQrCodeLogin().orFalse() } if (getMediaConfigResult != null) { @@ -146,6 +143,9 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor( if (getVersionResult != null) { homeServerCapabilitiesEntity.lastVersionIdentityServerSupported = getVersionResult.isLoginAndRegistrationSupportedBySdk() homeServerCapabilitiesEntity.canControlLogoutDevices = getVersionResult.doesServerSupportLogoutDevices() + homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */ + getVersionResult.doesServerSupportThreads().orFalse() + homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult.doesServerSupportQrCodeLogin().orFalse() } if (getWellknownResult != null && getWellknownResult is WellknownResult.Prompt) { diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index 30019a630d..16e26ff3b5 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -92,13 +92,13 @@ class DebugFeaturesStateFactory @Inject constructor( ), createBooleanFeature( label = "Allow QR Code Login for all servers", - key = DebugFeatureKeys.allowQrCodeLoginForAllServers, - factory = VectorFeatures::allowQrCodeLoginForAllServers + key = DebugFeatureKeys.qrCodeLoginForAllServers, + factory = VectorFeatures::isQrCodeLoginForAllServers ), createBooleanFeature( label = "Show QR Code Login in Device Manager", - key = DebugFeatureKeys.allowReciprocateQrCodeLogin, - factory = VectorFeatures::allowReciprocateQrCodeLogin + key = DebugFeatureKeys.reciprocateQrCodeLogin, + factory = VectorFeatures::isReciprocateQrCodeLogin ), createBooleanFeature( label = "Enable Voice Broadcast", diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 1bff0ffdb2..5c497c24ec 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -79,11 +79,11 @@ class DebugVectorFeatures( override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled) ?: vectorFeatures.isQrCodeLoginEnabled() - override fun allowQrCodeLoginForAllServers() = read(DebugFeatureKeys.allowQrCodeLoginForAllServers) - ?: vectorFeatures.allowQrCodeLoginForAllServers() + override fun isQrCodeLoginForAllServers() = read(DebugFeatureKeys.qrCodeLoginForAllServers) + ?: vectorFeatures.isQrCodeLoginForAllServers() - override fun allowReciprocateQrCodeLogin() = read(DebugFeatureKeys.allowReciprocateQrCodeLogin) - ?: vectorFeatures.allowReciprocateQrCodeLogin() + override fun isReciprocateQrCodeLogin() = read(DebugFeatureKeys.reciprocateQrCodeLogin) + ?: vectorFeatures.isReciprocateQrCodeLogin() override fun isVoiceBroadcastEnabled(): Boolean = read(DebugFeatureKeys.voiceBroadcastEnabled) ?: vectorFeatures.isVoiceBroadcastEnabled() @@ -148,7 +148,7 @@ object DebugFeatureKeys { val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder") val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled") val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled") - val allowQrCodeLoginForAllServers = booleanPreferencesKey("allow-qr-code-login-for-all-servers") - val allowReciprocateQrCodeLogin = booleanPreferencesKey("allow-reciprocate-qr-code-login") + val qrCodeLoginForAllServers = booleanPreferencesKey("qr-code-login-for-all-servers") + val reciprocateQrCodeLogin = booleanPreferencesKey("reciprocate-qr-code-login") val voiceBroadcastEnabled = booleanPreferencesKey("voice-broadcast-enabled") } diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 92bd90ab29..d41b5ac226 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -41,8 +41,8 @@ interface VectorFeatures { */ fun isNewAppLayoutFeatureEnabled(): Boolean fun isQrCodeLoginEnabled(): Boolean - fun allowQrCodeLoginForAllServers(): Boolean - fun allowReciprocateQrCodeLogin(): Boolean + fun isQrCodeLoginForAllServers(): Boolean + fun isReciprocateQrCodeLogin(): Boolean fun isVoiceBroadcastEnabled(): Boolean } @@ -60,7 +60,7 @@ class DefaultVectorFeatures : VectorFeatures { override fun forceUsageOfOpusEncoder(): Boolean = false override fun isNewAppLayoutFeatureEnabled(): Boolean = true override fun isQrCodeLoginEnabled(): Boolean = false - override fun allowQrCodeLoginForAllServers(): Boolean = false - override fun allowReciprocateQrCodeLogin(): Boolean = false + override fun isQrCodeLoginForAllServers(): Boolean = false + override fun isReciprocateQrCodeLogin(): Boolean = false override fun isVoiceBroadcastEnabled(): Boolean = false } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index d42644de7d..fb8c29f39f 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -125,7 +125,7 @@ class OnboardingViewModel @AssistedInject constructor( canLoginWithQrCode = false ) } - } else if (vectorFeatures.allowQrCodeLoginForAllServers()) { + } else if (vectorFeatures.isQrCodeLoginForAllServers()) { // allow for all servers setState { copy( diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt index 7e6da851dd..d4ee1d92eb 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt @@ -158,7 +158,7 @@ class VectorSettingsDevicesFragment : } private fun initQrLoginView() { - if (!vectorFeatures.allowReciprocateQrCodeLogin()) { + if (!vectorFeatures.isReciprocateQrCodeLogin()) { views.deviceListHeaderSignInWithQrCode.isVisible = false views.deviceListHeaderScanQrCodeButton.isVisible = false views.deviceListHeaderShowQrCodeButton.isVisible = false