From be07ccf0aa60e5ee241c36e96cd2ef5a659d7cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=8B=D1=82=D0=BA=D0=BE=D0=B2=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD?= Date: Tue, 21 Apr 2026 02:29:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B1=D0=B5=D1=81=D0=BA=D0=BE=D0=BD=D0=B5=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/screens/tasks/TaskPipelineScreen.kt | 25 ++++++++++++++++++- .../screens/tasks/TaskPipelineViewModel.kt | 9 ++++--- presentation/src/main/res/values/strings.xml | 1 + 3 files changed, 31 insertions(+), 4 deletions(-) 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