Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display proper test name in progress views #268

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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