diff --git a/TCHAP_CHANGES.md b/TCHAP_CHANGES.md index c5137340c1..ea9e607660 100644 --- a/TCHAP_CHANGES.md +++ b/TCHAP_CHANGES.md @@ -1,3 +1,16 @@ +Changes in Tchap 2.7.1 (2023-02-23) +=================================== + +Bugfixes 🐛 +---------- + - Prevent selecting multiple languages ([#853](https://github.com/tchapgouv/tchap-android-v2/issues/853)) + - Crash on logout ([#857](https://github.com/tchapgouv/tchap-android-v2/issues/857)) + +SDK API changes ⚠️ +------------------ + - [Mainlining] Remove deprecated endpoint /_matrix/client/unstable/users/info ([#811](https://github.com/tchapgouv/tchap-android-v2/issues/811)) + + Changes in Tchap 2.7.0 (2023-02-13) =================================== diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/UsersInfoService.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/UsersInfoService.kt deleted file mode 100644 index 3d0efdcd3e..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/UsersInfoService.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.api.session.userinfo - -import fr.gouv.tchap.android.sdk.api.session.userinfo.model.UserInfo - -interface UsersInfoService { - /** - * Get users information. - * - * @param userIds user Matrix Ids - */ - suspend fun getUsersInfo(userIds: List): Map -} diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/model/UserInfo.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/model/UserInfo.kt deleted file mode 100644 index 9d5dc49ae1..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/api/session/userinfo/model/UserInfo.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.api.session.userinfo.model - -/** - * Ref: https://gitlab.matrix.org/new-vector/internal/-/wikis/DINSIC#get-_matrixfederationv1queryuser_info-federationsynapse - */ -data class UserInfo( - /** - * Whether the user account is expired. - */ - val expired: Boolean, - /** - * Whether the user account is deactivated. - */ - val deactivated: Boolean -) diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoParams.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoParams.kt deleted file mode 100644 index f7999830ad..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoParams.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -/** - * @property userIds Required. The list of user Matrix IDs to query information about. - */ -@JsonClass(generateAdapter = true) -internal data class GetUsersInfoParams( - @Json(name = "user_ids") val userIds: List -) diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoResult.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoResult.kt deleted file mode 100644 index ce24b61254..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoResult.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -internal data class GetUsersInfoResult( - val expired: Boolean, - val deactivated: Boolean -) diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoTask.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoTask.kt deleted file mode 100644 index 4044eae983..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/GetUsersInfoTask.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import fr.gouv.tchap.android.sdk.api.session.userinfo.model.UserInfo -import org.matrix.android.sdk.internal.network.GlobalErrorReceiver -import org.matrix.android.sdk.internal.network.executeRequest -import org.matrix.android.sdk.internal.task.Task -import javax.inject.Inject - -internal interface GetUsersInfoTask : Task> - -internal class TchapGetUsersInfoTask @Inject constructor( - private val usersAPI: UsersInfoAPI, - private val globalErrorReceiver: GlobalErrorReceiver -) : GetUsersInfoTask { - - override suspend fun execute(params: GetUsersInfoParams): Map { - val result = executeRequest(globalErrorReceiver) { - usersAPI.getUsersInfo(params) - } - - return result.mapValues { - UserInfo( - expired = it.value.expired, - deactivated = it.value.deactivated - ) - } - } -} diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoModule.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoModule.kt deleted file mode 100644 index fc7b3724ca..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoModule.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import dagger.Binds -import dagger.Module -import dagger.Provides -import fr.gouv.tchap.android.sdk.api.session.userinfo.UsersInfoService -import org.matrix.android.sdk.internal.session.SessionScope -import retrofit2.Retrofit - -@Module -internal abstract class TchapUsersInfoModule { - - @Module - companion object { - @JvmStatic - @Provides - @SessionScope - fun providesUsersInfoAPI(retrofit: Retrofit): UsersInfoAPI { - return retrofit.create(UsersInfoAPI::class.java) - } - } - - @Binds - abstract fun bindUsersInfoService(service: TchapUsersInfoService): UsersInfoService - - @Binds - abstract fun bindGetUsersInfoTask(task: TchapGetUsersInfoTask): GetUsersInfoTask -} diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoService.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoService.kt deleted file mode 100644 index 76f8d0b954..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/TchapUsersInfoService.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import fr.gouv.tchap.android.sdk.api.session.userinfo.UsersInfoService -import fr.gouv.tchap.android.sdk.api.session.userinfo.model.UserInfo -import javax.inject.Inject - -internal class TchapUsersInfoService @Inject constructor( - private val getUsersInfoTask: GetUsersInfoTask -) : UsersInfoService { - - override suspend fun getUsersInfo(userIds: List): Map { - return getUsersInfoTask.execute( - GetUsersInfoParams(userIds) - ) - } -} diff --git a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/UsersInfoAPI.kt b/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/UsersInfoAPI.kt deleted file mode 100644 index 442984b52e..0000000000 --- a/matrix-sdk-android/src/main/java/fr/gouv/tchap/android/sdk/internal/session/users/UsersInfoAPI.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 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 fr.gouv.tchap.android.sdk.internal.session.users - -import org.matrix.android.sdk.internal.network.NetworkConstants -import retrofit2.http.Body -import retrofit2.http.POST - -internal interface UsersInfoAPI { - - /** - * Get the expiration and deactivation information about the given user ids. - */ - @POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "users/info") - suspend fun getUsersInfo(@Body usersInfoParams: GetUsersInfoParams): Map -} diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt index 54558337da..5c2854aeb0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt @@ -18,7 +18,6 @@ package org.matrix.android.sdk.api.session import androidx.annotation.MainThread import fr.gouv.tchap.android.sdk.api.auth.AccountValidityService -import fr.gouv.tchap.android.sdk.api.session.userinfo.UsersInfoService import io.realm.RealmConfiguration import okhttp3.OkHttpClient import org.matrix.android.sdk.api.MatrixCoroutineDispatchers @@ -274,11 +273,6 @@ interface Session { */ fun accountDataService(): SessionAccountDataService - /** - * Returns the users info service associated with the session. - */ - fun usersInfoService(): UsersInfoService - /** * Returns the account validity service associated with the session. */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt index 1017b53e05..f88e78068d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt @@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session import androidx.annotation.MainThread import dagger.Lazy import fr.gouv.tchap.android.sdk.api.auth.AccountValidityService -import fr.gouv.tchap.android.sdk.api.session.userinfo.UsersInfoService import io.realm.RealmConfiguration import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.withContext @@ -132,7 +131,6 @@ internal class DefaultSession @Inject constructor( private val presenceService: Lazy, private val toDeviceService: Lazy, private val eventStreamService: Lazy, - private val usersInfoService: Lazy, private val accountValidityService: Lazy, @UnauthenticatedWithCertificate private val unauthenticatedWithCertificateOkHttpClient: Lazy, @@ -235,8 +233,6 @@ internal class DefaultSession @Inject constructor( override fun accountDataService(): SessionAccountDataService = accountDataService.get() override fun sharedSecretStorageService(): SharedSecretStorageService = sharedSecretStorageService.get() - override fun usersInfoService(): UsersInfoService = usersInfoService.get() - override fun accountValidityService(): AccountValidityService = accountValidityService.get() override fun getOkHttpClient(): OkHttpClient { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt index 27096524e2..3419dfcf48 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt @@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session import dagger.BindsInstance import dagger.Component import fr.gouv.tchap.android.sdk.internal.auth.TchapAccountValidityModule -import fr.gouv.tchap.android.sdk.internal.session.users.TchapUsersInfoModule import org.matrix.android.sdk.api.MatrixCoroutineDispatchers import org.matrix.android.sdk.api.auth.data.SessionParams import org.matrix.android.sdk.api.securestorage.SecureStorageModule @@ -70,7 +69,6 @@ import org.matrix.android.sdk.internal.util.system.SystemModule @Component( dependencies = [MatrixComponent::class], modules = [ - TchapUsersInfoModule::class, TchapAccountValidityModule::class, SessionModule::class, RoomModule::class, diff --git a/towncrier.toml b/towncrier.toml index 178c5c7e6b..721b430783 100644 --- a/towncrier.toml +++ b/towncrier.toml @@ -1,5 +1,5 @@ [tool.towncrier] - version = "2.7.0" + version = "2.7.1" directory = "changelog.d" filename = "TCHAP_CHANGES.md" name = "Changes in Tchap" diff --git a/vector-app/build.gradle b/vector-app/build.gradle index a33879c2f9..9253cb9b8a 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -37,7 +37,7 @@ ext.versionMinor = 7 // Note: even values are reserved for regular release, odd values for hotfix release. // When creating a hotfix, you should decrease the value, since the current value // is the value for the next regular release. -ext.versionPatch = 0 +ext.versionPatch = 1 static def getGitTimestamp() { def cmd = 'git show -s --format=%ct' @@ -158,6 +158,9 @@ android { // abiFilters "armeabi-v7a", "x86", 'arm64-v8a', 'x86_64' // } + // Tchap: Use only en and fr + resConfigs "en", "fr" + // Ref: https://developer.android.com/studio/build/configure-apk-splits.html splits { // Configures multiple APKs based on ABI. 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 40849a9558..f4be52ce1c 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 @@ -46,6 +46,8 @@ class DebugVectorFeatures( override fun tchapIsKeyBackupEnabled() = read(DebugFeatureKeys.tchapIsKeyBackupEnabled) ?: vectorFeatures.tchapIsKeyBackupEnabled() + override fun tchapIsThreadEnabled() = vectorFeatures.tchapIsThreadEnabled() + override fun onboardingVariant(): OnboardingVariant { return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() } diff --git a/vector-config/src/btchap/res/values/config-features.xml b/vector-config/src/btchap/res/values/config-features.xml index 5542daeda5..f6fda74684 100755 --- a/vector-config/src/btchap/res/values/config-features.xml +++ b/vector-config/src/btchap/res/values/config-features.xml @@ -2,4 +2,5 @@ true true + false diff --git a/vector-config/src/devTchap/res/values/config-features.xml b/vector-config/src/devTchap/res/values/config-features.xml index 5542daeda5..f6fda74684 100755 --- a/vector-config/src/devTchap/res/values/config-features.xml +++ b/vector-config/src/devTchap/res/values/config-features.xml @@ -2,4 +2,5 @@ true true + false diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index eabd576453..096d38b1e1 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -48,7 +48,7 @@ true true - true + false true false true diff --git a/vector-config/src/tchap/res/values/config-features.xml b/vector-config/src/tchap/res/values/config-features.xml index 5542daeda5..f6fda74684 100755 --- a/vector-config/src/tchap/res/values/config-features.xml +++ b/vector-config/src/tchap/res/values/config-features.xml @@ -2,4 +2,5 @@ true true + false diff --git a/vector/build.gradle b/vector/build.gradle index 100899e5de..0e6f0bc274 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -48,9 +48,6 @@ android { // abiFilters "armeabi-v7a", "x86", 'arm64-v8a', 'x86_64' // } - // Tchap: Use only en and fr - resConfigs "en", "fr" - // Generate a random app task affinity manifestPlaceholders = [appTaskAffinitySuffix: "H_${gitRevision()}"] 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 8dc93c3963..a364398449 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -28,6 +28,7 @@ interface VectorFeatures { fun tchapIsVoipSupported(): Boolean fun tchapIsCrossSigningEnabled(): Boolean fun tchapIsKeyBackupEnabled(): Boolean + fun tchapIsThreadEnabled(): Boolean fun onboardingVariant(): OnboardingVariant fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean fun isOnboardingSplashCarouselEnabled(): Boolean @@ -59,6 +60,7 @@ class DefaultVectorFeatures @Inject constructor( override fun tchapIsVoipSupported() = booleanProvider.getBoolean(R.bool.tchap_is_voip_supported) override fun tchapIsCrossSigningEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_cross_signing_enabled) override fun tchapIsKeyBackupEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_key_backup_enabled) + override fun tchapIsThreadEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_thread_enabled) override fun onboardingVariant() = Config.ONBOARDING_VARIANT override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true override fun isOnboardingSplashCarouselEnabled() = false // Tchap: no carousel diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index 007c25352a..4240217e90 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -266,6 +266,9 @@ class HomeActivityViewModel @AssistedInject constructor( // lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled()) // } + // Tchap : disable automatic thread migration + if (!vectorFeatures.tchapIsThreadEnabled()) return + when { !vectorPreferences.areThreadMessagesEnabled() && !vectorPreferences.wasThreadFlagChangedManually() -> { vectorPreferences.setThreadMessagesEnabled() diff --git a/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetDialogFragment.kt b/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetDialogFragment.kt index e94815c072..6ae24854d5 100644 --- a/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetDialogFragment.kt +++ b/vector/src/main/java/im/vector/app/features/workers/signout/SignOutBottomSheetDialogFragment.kt @@ -103,7 +103,7 @@ class SignOutBottomSheetDialogFragment : override fun invalidate() = withState(viewModel) { state -> views.signoutExportingLoading.isVisible = false - if (!state.isKeyBackupSupported) { + if (!viewModel.isKeyBackupSupported()) { views.bottomSheetSignoutWarningText.text = getString(R.string.tchap_action_sign_out_confirmation) views.setupRecoveryButton.isVisible = false diff --git a/vector/src/main/java/im/vector/app/features/workers/signout/SignoutCheckViewModel.kt b/vector/src/main/java/im/vector/app/features/workers/signout/SignoutCheckViewModel.kt index be3408a69e..aa5608dd5a 100644 --- a/vector/src/main/java/im/vector/app/features/workers/signout/SignoutCheckViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/workers/signout/SignoutCheckViewModel.kt @@ -23,16 +23,15 @@ import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.Success import com.airbnb.mvrx.Uninitialized -import com.airbnb.mvrx.ViewModelContext import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.platform.EmptyViewEvents -import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModelAction +import im.vector.app.features.VectorFeatures import im.vector.app.features.crypto.keys.KeysExporter import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map @@ -53,12 +52,12 @@ data class SignoutCheckViewState( val crossSigningSetupAllKeysKnown: Boolean = false, val keysBackupState: KeysBackupState = KeysBackupState.Unknown, val hasBeenExportedToFile: Async = Uninitialized, - val isKeyBackupSupported: Boolean = false ) : MavericksState class SignoutCheckViewModel @AssistedInject constructor( @Assisted initialState: SignoutCheckViewState, private val session: Session, + private val vectorFeatures: VectorFeatures, private val keysExporter: KeysExporter ) : VectorViewModel(initialState), KeysBackupStateListener { @@ -72,22 +71,17 @@ class SignoutCheckViewModel @AssistedInject constructor( override fun create(initialState: SignoutCheckViewState): SignoutCheckViewModel } - // Tchap: init viewState with key backup - companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() { - override fun initialState(viewModelContext: ViewModelContext): SignoutCheckViewState? { - val isKeyBackupEnabled = (viewModelContext.activity as? VectorBaseActivity<*>)?.vectorFeatures?.tchapIsKeyBackupEnabled().orFalse() - return SignoutCheckViewState(isKeyBackupSupported = isKeyBackupEnabled) - } - } + companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() init { - withState { state -> - if (state.isKeyBackupSupported) { - init() - } + // Tchap: init when key backup is supported + if (isKeyBackupSupported()) { + init() } } + fun isKeyBackupSupported() = vectorFeatures.tchapIsKeyBackupEnabled().orFalse() + fun init() { session.cryptoService().keysBackupService().addListener(this) session.cryptoService().keysBackupService().checkAndStartKeysBackup() @@ -115,10 +109,8 @@ class SignoutCheckViewModel @AssistedInject constructor( } override fun onCleared() { - withState { state -> - if (state.isKeyBackupSupported) { - session.cryptoService().keysBackupService().removeListener(this) - } + if (isKeyBackupSupported()) { + session.cryptoService().keysBackupService().removeListener(this) } super.onCleared() } @@ -132,7 +124,7 @@ class SignoutCheckViewModel @AssistedInject constructor( } fun refreshRemoteStateIfNeeded() = withState { state -> - if (state.isKeyBackupSupported && state.keysBackupState == KeysBackupState.Disabled) { + if (isKeyBackupSupported() && state.keysBackupState == KeysBackupState.Disabled) { session.cryptoService().keysBackupService().checkAndStartKeysBackup() } } diff --git a/vector/src/main/res/drawable/ic_rich_composer_send.xml b/vector/src/main/res/drawable/ic_rich_composer_send.xml index 0f99c1670e..b3df6e92dd 100644 --- a/vector/src/main/res/drawable/ic_rich_composer_send.xml +++ b/vector/src/main/res/drawable/ic_rich_composer_send.xml @@ -5,8 +5,8 @@ android:viewportHeight="36"> + android:fillColor="?colorPrimary"/> + android:fillColor="?colorOnPrimary"/> diff --git a/vector/src/main/res/xml/vector_settings_notifications.xml b/vector/src/main/res/xml/vector_settings_notifications.xml index f4d7ff8cd5..fc7069d573 100644 --- a/vector/src/main/res/xml/vector_settings_notifications.xml +++ b/vector/src/main/res/xml/vector_settings_notifications.xml @@ -43,9 +43,10 @@ - +