diff --git a/composeApp/src/commonMain/kotlin/org/ooni/engine/models/TestType.kt b/composeApp/src/commonMain/kotlin/org/ooni/engine/models/TestType.kt index 949590b9..4d9f3bc8 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/engine/models/TestType.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/engine/models/TestType.kt @@ -1,5 +1,6 @@ package org.ooni.engine.models +import androidx.compose.runtime.Composable import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.descriptors.PrimitiveKind @@ -30,6 +31,7 @@ import ooniprobe.composeapp.generated.resources.test_websites import ooniprobe.composeapp.generated.resources.test_whatsapp import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.stringResource import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds @@ -42,6 +44,10 @@ sealed class TestType { abstract fun runtime(inputs: List?): Duration + val displayName: String + @Composable + get() = (if (this is Experimental) name else stringResource(labelRes)) + data object Dash : TestType() { override val name: String = "dash" override val labelRes: StringResource = Res.string.Test_Dash_Fullname diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/data/disk/WriteFile.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/data/disk/WriteFile.kt index de7753de..a3c8af04 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/data/disk/WriteFile.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/data/disk/WriteFile.kt @@ -34,12 +34,16 @@ class WriteFileOkio( return } - fileSystem - .run { if (append) appendingSink(absolutePath) else sink(absolutePath) } - .use { sink -> - sink.buffer().use { - it.writeUtf8(contents) + try { + fileSystem + .run { if (append) appendingSink(absolutePath) else sink(absolutePath) } + .use { sink -> + sink.buffer().use { + it.writeUtf8(contents) + } } - } + } catch (e: Exception) { + Logger.e("Could not update file $path", e) + } } } diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/dashboard/DashboardScreen.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/dashboard/DashboardScreen.kt index d3e596b8..c2605032 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/dashboard/DashboardScreen.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/dashboard/DashboardScreen.kt @@ -52,7 +52,6 @@ import ooniprobe.composeapp.generated.resources.dashboard_arc import ooniprobe.composeapp.generated.resources.ic_timer import ooniprobe.composeapp.generated.resources.ic_warning import ooniprobe.composeapp.generated.resources.logo_probe -import ooniprobe.composeapp.generated.resources.ooni_empty_state import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview @@ -223,13 +222,15 @@ private fun TestRunStateSection( style = MaterialTheme.typography.bodyLarge, ) state.testType?.let { testType -> - Icon( - painterResource(testType.iconRes ?: Res.drawable.ooni_empty_state), - contentDescription = null, - modifier = Modifier.padding(horizontal = 4.dp).size(24.dp), - ) + testType.iconRes?.let { + Icon( + painterResource(it), + contentDescription = null, + modifier = Modifier.padding(horizontal = 4.dp).size(24.dp), + ) + } Text( - text = stringResource(testType.labelRes), + text = testType.displayName, style = MaterialTheme.typography.bodyLarge, fontWeight = FontWeight.Bold, ) diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/running/RunningScreen.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/running/RunningScreen.kt index d2d2bdff..8dbbcbcd 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/running/RunningScreen.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/running/RunningScreen.kt @@ -121,7 +121,7 @@ private fun TestRunning( style = MaterialTheme.typography.bodyLarge, ) Text( - text = stringResource(testType.labelRes), + text = testType.displayName, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold, )