Fix test.
This commit is contained in:
parent
34f4078d5f
commit
3e1d6e529c
4 changed files with 57 additions and 15 deletions
|
|
@ -25,16 +25,13 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import io.element.android.features.logout.api.LogoutPreferencePresenter
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.core.meta.BuildType
|
||||
import io.element.android.libraries.matrix.api.user.CurrentUserProvider
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
|
@ -43,7 +40,8 @@ class PreferencesRootPresenter @Inject constructor(
|
|||
private val logoutPresenter: LogoutPreferencePresenter,
|
||||
private val currentUserProvider: CurrentUserProvider,
|
||||
private val sessionVerificationService: SessionVerificationService,
|
||||
private val buildMeta: BuildMeta,
|
||||
private val buildType: BuildType,
|
||||
private val versionFormatter: VersionFormatter,
|
||||
) : Presenter<PreferencesRootState> {
|
||||
|
||||
@Composable
|
||||
|
|
@ -61,17 +59,12 @@ class PreferencesRootPresenter @Inject constructor(
|
|||
derivedStateOf { sessionVerifiedStatus == SessionVerifiedStatus.NotVerified }
|
||||
}
|
||||
|
||||
val version = stringResource(
|
||||
id = CommonStrings.settings_version_number,
|
||||
buildMeta.versionName,
|
||||
buildMeta.versionCode.toString()
|
||||
)
|
||||
val logoutState = logoutPresenter.present()
|
||||
val showDeveloperSettings = buildMeta.buildType != BuildType.RELEASE
|
||||
val showDeveloperSettings = buildType != BuildType.RELEASE
|
||||
return PreferencesRootState(
|
||||
logoutState = logoutState,
|
||||
myUser = matrixUser.value,
|
||||
version = version,
|
||||
version = versionFormatter.get(),
|
||||
showCompleteVerification = sessionIsNotVerified,
|
||||
showDeveloperSettings = showDeveloperSettings
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2023 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 io.element.android.features.preferences.impl.root
|
||||
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
interface VersionFormatter {
|
||||
fun get(): String
|
||||
}
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultVersionFormatter @Inject constructor(
|
||||
private val stringProvider: StringProvider,
|
||||
private val buildMeta: BuildMeta,
|
||||
) : VersionFormatter {
|
||||
override fun get(): String {
|
||||
return stringProvider.getString(
|
||||
CommonStrings.settings_version_number,
|
||||
buildMeta.versionName,
|
||||
buildMeta.versionCode.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class FakeVersionFormatter : VersionFormatter {
|
||||
override fun get(): String {
|
||||
return "A Version"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue