Skip to content

Commit

Permalink
fix: display proper test name in progress views (#268)
Browse files Browse the repository at this point in the history
* fix: display proper test name in progress views
  • Loading branch information
aanorbel authored Nov 14, 2024
1 parent 83c6aa8 commit 4d2a0d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand All @@ -42,6 +44,10 @@ sealed class TestType {

abstract fun runtime(inputs: List<String>?): 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit 4d2a0d8

Please sign in to comment.