diff --git a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineScreen.kt b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineScreen.kt
index 773adae..83b8545 100644
--- a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineScreen.kt
+++ b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineScreen.kt
@@ -1,7 +1,9 @@
package com.github.nullptroma.wallenc.presentation.screens.main.screens.tasks
+import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@@ -10,6 +12,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
+import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
@@ -23,6 +26,7 @@ import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
@@ -45,6 +49,7 @@ fun TaskPipelineScreen(
val runningTaskIds = pipeline.runningTaskIds
var showTestDialog by remember { mutableStateOf(false) }
var testDurationSec by remember { mutableFloatStateOf(10f) }
+ var testInfinity by remember { mutableStateOf(false) }
Scaffold(
modifier = modifier,
@@ -128,12 +133,30 @@ fun TaskPipelineScreen(
onValueChange = { testDurationSec = it },
valueRange = 0f..60f,
)
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Checkbox(
+ checked = testInfinity,
+ onCheckedChange = { testInfinity = it },
+ )
+ Text(
+ stringResource(R.string.task_pipeline_test_dialog_infinity),
+ modifier = Modifier
+ .clickable { testInfinity = !testInfinity }
+ .weight(1f),
+ )
+ }
}
},
confirmButton = {
Button(
onClick = {
- viewModel.startTestTask(testDurationSec.toInt())
+ viewModel.startTestTask(
+ testDurationSec.toInt(),
+ testInfinity,
+ )
showTestDialog = false
},
) {
diff --git a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineViewModel.kt b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineViewModel.kt
index 5a59016..a3c5549 100644
--- a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineViewModel.kt
+++ b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/screens/main/screens/tasks/TaskPipelineViewModel.kt
@@ -14,10 +14,13 @@ class TaskPipelineViewModel @Inject constructor(
val orchestrator: ITaskOrchestrator,
) : ViewModel() {
- fun startTestTask(durationSec: Int) {
+ fun startTestTask(durationSec: Int, infinityIndeterminateProgress: Boolean) {
val safeDurationSec = durationSec.coerceIn(0, 60)
+ val title =
+ if (infinityIndeterminateProgress) "Test task (${safeDurationSec}s, ∞)"
+ else "Test task (${safeDurationSec}s)"
orchestrator.enqueue(
- title = "Test task (${safeDurationSec}s)",
+ title = title,
dispatcher = Dispatchers.Default,
work = { ctx ->
val steps = if (safeDurationSec == 0) 1 else safeDurationSec * 10
@@ -26,7 +29,7 @@ class TaskPipelineViewModel @Inject constructor(
val fraction = step.toFloat() / steps.toFloat()
val elapsedMs = (fraction * safeDurationSec * 1000).toInt()
ctx.reportProgress(
- fraction = fraction,
+ fraction = if (infinityIndeterminateProgress) null else fraction,
label = "Elapsed: ${elapsedMs / 1000}s / ${safeDurationSec}s",
)
if (step < steps) delay(100)
diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml
index c8a3777..185522a 100644
--- a/presentation/src/main/res/values/strings.xml
+++ b/presentation/src/main/res/values/strings.xml
@@ -25,6 +25,7 @@
Duration: %1$d s
Start
Cancel
+ Infinity (indeterminate progress)
Queued
Running
Completed