Skip to content

Commit

Permalink
fix: avs and cc versions in new section about this app (WPB-5935) (#3181
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yamilmedina authored Jul 15, 2024
1 parent 3a803c8 commit 68d134b
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ object TermsOfUseScreenDestination : ExternalUriStringResDirection {
get() = R.string.url_terms_of_use_legal
}

object WireWebsiteScreenDestination : ExternalUriStringResDirection {
override val uriStringRes: Int
get() = R.string.url_wire_website
}

object GiveFeedbackDestination : IntentDirection {
override fun intent(context: Context): Intent {
val intent = Intent(Intent.ACTION_SEND)
Expand Down
40 changes: 0 additions & 40 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.wire.android.BuildConfig
Expand All @@ -50,8 +48,6 @@ import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.e2ei.usecase.E2EIEnrollmentResult
import com.wire.kalium.logic.functional.Either
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentMapOf

@Composable
fun DebugDataOptions(
Expand All @@ -76,7 +72,6 @@ fun DebugDataOptions(
handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult,
dismissCertificateDialog = viewModel::dismissCertificateDialog,
checkCrlRevocationList = viewModel::checkCrlRevocationList,
dependenciesMap = viewModel.state().dependencies
)
}

Expand All @@ -96,7 +91,6 @@ fun DebugDataOptionsContent(
handleE2EIEnrollmentResult: (Either<CoreFailure, E2EIEnrollmentResult>) -> Unit,
dismissCertificateDialog: () -> Unit,
checkCrlRevocationList: () -> Unit,
dependenciesMap: ImmutableMap<String, String?>
) {
Column {

Expand Down Expand Up @@ -131,7 +125,6 @@ fun DebugDataOptionsContent(
onClick = { onCopyText(state.commitish) }
)
)
DependenciesItem(dependenciesMap)
if (BuildConfig.PRIVATE_BUILD) {

SettingsItem(
Expand Down Expand Up @@ -427,29 +420,6 @@ private fun DebugToolsOptions(
}
}

/**
* Compose function that will display the list of dependencies
* @param dependencies an Immutable map of a dependency name to its version number
*/
@Composable
fun DependenciesItem(dependencies: ImmutableMap<String, String?>) {
val title = stringResource(id = R.string.item_dependencies_title)
val text = remember {
prettyPrintMap(dependencies, title)
}
RowItemTemplate(
modifier = Modifier.wrapContentWidth(),
title = {
Text(
style = MaterialTheme.wireTypography.body01,
color = MaterialTheme.wireColorScheme.onBackground,
text = text,
modifier = Modifier.padding(start = dimensions().spacing8x)
)
}
)
}

@Composable
private fun DisableEventProcessingSwitch(
isEnabled: Boolean = false,
Expand Down Expand Up @@ -478,15 +448,6 @@ private fun DisableEventProcessingSwitch(
}
)
}

@Stable
private fun prettyPrintMap(map: ImmutableMap<String, String?>, title: String): String = StringBuilder().apply {
append("$title\n")
map.forEach { (key, value) ->
append("$key: $value\n")
}
}.toString()

//endregion

@PreviewMultipleThemes
Expand Down Expand Up @@ -514,6 +475,5 @@ fun PreviewOtherDebugOptions() {
handleE2EIEnrollmentResult = {},
dismissCertificateDialog = {},
checkCrlRevocationList = {},
dependenciesMap = persistentMapOf()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
*/
package com.wire.android.ui.debug

import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentMapOf

data class DebugDataOptionsState(
val isEncryptedProteusStorageEnabled: Boolean = false,
val isEventProcessingDisabled: Boolean = false,
Expand All @@ -32,5 +29,4 @@ data class DebugDataOptionsState(
val certificate: String = "null",
val showCertificate: Boolean = false,
val startGettingE2EICertificate: Boolean = false,
val dependencies: ImmutableMap<String, String?> = persistentMapOf()
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.wire.android.di.CurrentAccount
import com.wire.android.di.ScopedArgs
import com.wire.android.di.ViewModelScopedPreview
import com.wire.android.migration.failure.UserMigrationStatus
import com.wire.android.util.getDependenciesVersion
import com.wire.android.util.getDeviceIdString
import com.wire.android.util.getGitBuildId
import com.wire.kalium.logic.CoreFailure
Expand All @@ -44,7 +43,6 @@ import com.wire.kalium.logic.sync.periodic.UpdateApiVersionsScheduler
import com.wire.kalium.logic.sync.slow.RestartSlowSyncProcessForRecoveryUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -87,16 +85,6 @@ class DebugDataOptionsViewModelImpl
observeMlsMetadata()
checkIfCanTriggerManualMigration()
setGitHashAndDeviceId()
checkDependenciesVersion()
}

private fun checkDependenciesVersion() {
viewModelScope.launch {
val dependencies = context.getDependenciesVersion().toImmutableMap()
state = state.copy(
dependencies = dependencies
)
}
}

private fun setGitHashAndDeviceId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.wire.android.navigation.PrivacyPolicyScreenDestination
import com.wire.android.navigation.ReportBugDestination
import com.wire.android.navigation.SupportScreenDestination
import com.wire.android.navigation.TermsOfUseScreenDestination
import com.wire.android.navigation.WireWebsiteScreenDestination
import com.wire.android.ui.common.RowItemTemplate
import com.wire.android.ui.common.clickable
import com.wire.android.ui.common.dimensions
Expand All @@ -45,6 +46,7 @@ import com.wire.android.ui.destinations.AppSettingsScreenDestination
import com.wire.android.ui.destinations.AppearanceScreenDestination
import com.wire.android.ui.destinations.BackupAndRestoreScreenDestination
import com.wire.android.ui.destinations.DebugScreenDestination
import com.wire.android.ui.destinations.DependenciesScreenDestination
import com.wire.android.ui.destinations.LicensesScreenDestination
import com.wire.android.ui.destinations.MyAccountScreenDestination
import com.wire.android.ui.destinations.NetworkSettingsScreenDestination
Expand Down Expand Up @@ -156,6 +158,12 @@ sealed class SettingsItem(open val id: String, open val title: UIText) {
direction = TermsOfUseScreenDestination
)

data object WireWebsite : DirectionItem(
id = "terms_of_use",
title = UIText.StringResource(R.string.settings_wire_website_label),
direction = WireWebsiteScreenDestination
)

data object PrivacyPolicy : DirectionItem(
id = "privacy_policy",
title = UIText.StringResource(R.string.settings_privacy_policy_label),
Expand All @@ -168,6 +176,12 @@ sealed class SettingsItem(open val id: String, open val title: UIText) {
direction = LicensesScreenDestination
)

data object Dependencies : DirectionItem(
id = "other_licenses",
title = UIText.StringResource(R.string.settings_dependencies_label),
direction = DependenciesScreenDestination
)

data object BackupAndRestore : DirectionItem(
id = "backups_backup_and_restore",
title = UIText.StringResource(R.string.backup_and_restore_screen_title),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.settings.about.dependencies

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.wire.android.R
import com.wire.android.navigation.Navigator
import com.wire.android.ui.common.RowItemTemplate
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.scaffold.WireScaffold
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.immutableMapOf

@Composable
@Destination
@RootNavGraph
fun DependenciesScreen(
navigator: Navigator,
viewModel: DependenciesViewModel = hiltViewModel()
) {
WireScaffold(topBar = {
WireCenterAlignedTopAppBar(
onNavigationPressed = navigator::navigateBack,
elevation = 0.dp,
title = stringResource(id = R.string.settings_dependencies_label)
)
}) { internalPadding ->
DependenciesContent(
internalPadding = internalPadding,
dependencies = viewModel.state.dependencies
)
}
}

@Composable
private fun DependenciesContent(
internalPadding: PaddingValues,
dependencies: ImmutableMap<String, String?>,
) {
val lazyListState = rememberLazyListState()
LazyColumn(
Modifier.fillMaxSize(),
state = lazyListState,
contentPadding = internalPadding
) {
dependencies.entries.forEach {
item {
DependenciesItem(dependencyName = it.key, dependencyVersion = it.value.orEmpty())
}
}
}
}

@Composable
private fun DependenciesItem(
dependencyName: String,
dependencyVersion: String
) {
RowItemTemplate(
modifier = Modifier.wrapContentWidth(),
title = {
Text(
style = MaterialTheme.wireTypography.body01,
color = MaterialTheme.wireColorScheme.onBackground,
text = "${dependencyName.uppercase()}: $dependencyVersion",
)
}
)
}

@Composable
@PreviewMultipleThemes
fun DependenciesContentPreview() {
DependenciesContent(
internalPadding = PaddingValues(dimensions().spacing8x),
dependencies = immutableMapOf("avs" to "4.10.1", "cc" to "0.0.1")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.settings.about.dependencies

import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentMapOf

data class DependenciesState(
val dependencies: ImmutableMap<String, String?> = persistentMapOf()
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.settings.about.dependencies

import android.content.Context
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.util.getDependenciesVersion
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class DependenciesViewModel @Inject constructor(
@ApplicationContext val context: Context
) : ViewModel() {

var state: DependenciesState by mutableStateOf(DependenciesState())
private set

init {
checkDependenciesVersion()
}

private fun checkDependenciesVersion() {
viewModelScope.launch {
val dependencies = context.getDependenciesVersion().toImmutableMap()
state = state.copy(dependencies = dependencies)
}
}
}
Loading

0 comments on commit 68d134b

Please sign in to comment.