Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

refactor(live): extract rename group dialog

David Nashashaca496be3ae3
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
index b6fcd981..e5b68fdc 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreenDialogs.kt
@@ -14,7 +14,6 @@ import com.streamvault.feature.live.home.HomeViewModel
import com.streamvault.app.navigation.Routes
import com.streamvault.app.ui.components.dialogs.AddToGroupDialog
import com.streamvault.core.ui.components.dialogs.PinDialog
-import com.streamvault.app.ui.components.dialogs.RenameGroupDialog
import com.streamvault.app.ui.components.dialogs.M3uCategoryOrganizerDialog
import com.streamvault.app.ui.components.dialogs.M3uCategorySeriesAssignmentDialog
import com.streamvault.app.ui.components.dialogs.M3uSeriesAssignmentDialog
@@ -26,6 +25,8 @@ import com.streamvault.feature.live.home.LiveAddQuickFilterDialog
import com.streamvault.feature.live.home.LiveAddQuickFilterDialogLabels
import com.streamvault.feature.live.home.LiveDeleteGroupDialog
import com.streamvault.feature.live.home.LiveDeleteGroupDialogLabels
+import com.streamvault.feature.live.home.LiveRenameGroupDialog
+import com.streamvault.feature.live.home.LiveRenameGroupDialogLabels
import com.streamvault.domain.model.ActiveLiveSource
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.Channel
@@ -341,9 +342,16 @@ internal fun HomeDialogsHost(
val groupToRename = uiState.groupToRename
if (uiState.showRenameGroupDialog && groupToRename != null) {
- RenameGroupDialog(
+ LiveRenameGroupDialog(
initialName = groupToRename.name,
errorMessage = uiState.renameGroupError,
+ labels = LiveRenameGroupDialogLabels(
+ title = stringResource(R.string.category_options_rename),
+ hint = stringResource(R.string.library_saved_manage_hint),
+ nameLabel = stringResource(R.string.add_group_name_hint),
+ cancel = stringResource(R.string.add_group_cancel),
+ confirm = stringResource(R.string.add_group_rename)
+ ),
onDismissRequest = { viewModel.cancelRenameGroup() },
onConfirm = { name -> viewModel.confirmRenameGroup(name) }
)
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 3688cc72..b04c8d02 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -134,7 +134,8 @@ EPG guide-now ticker/provider, EPG search field/row, Home reorder top bar, and
Home channel row surface, Home channel-results header, Home category sidebar
header, channel-content state host, channel-list host, and category-list host
and hidden category/channel dialogs, the category options dialog, the
-quick-filter add dialog, and the delete-group dialog are now feature-owned
+quick-filter add dialog, delete-group dialog, and rename-group dialog are now
+feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
@@ -142,7 +143,7 @@ The source switcher receives localized labels from the app at the current
composition boundary. Live-owned
presentation primitives, `HomeUiState`, `HomePreviewUiState`, Guide
mode/density/reminder presentation models, hidden collection dialogs, the
-category options dialog, the quick-filter add dialog, and the delete-group
-dialog are independent of app code;
+category options dialog, the quick-filter add dialog, the delete-group dialog,
+and the rename-group dialog are independent of app code;
screen/resource moves, golden/runtime/performance gates, and legacy app cleanup
remain open, so no live slice acceptance gate is claimed yet.
diff --git a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
index f0541126..dae9ea4e 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -24,7 +24,8 @@ EPG guide-now ticker/provider, EPG search field/row, Home reorder top bar,
Home channel row surface, Home channel-results header, Home category sidebar
header, channel-content state host, channel-list host, and category-list host
and hidden category/channel dialogs, the category options dialog, the
-quick-filter add dialog, and the delete-group dialog are now feature-owned
+quick-filter add dialog, delete-group dialog, and rename-group dialog are now
+feature-owned
and their feature checks are green. Home screen/dialog composition, the
remaining live cards/rows, complete locale resource migration, and acceptance
gates remain open.
@@ -684,6 +685,8 @@ quick-filter add dialog also owns its draft text and duplicate check while the
app supplies the saved-filter snapshot and mutation callback. The
delete-group dialog owns its interaction guard and presentation while the app
supplies the already formatted group-specific copy and ViewModel callbacks.
+The rename-group dialog owns draft text, focus, and device sizing while the app
+supplies validation text and rename/cancel callbacks.
quick-filter key/selection rules are covered by `LiveQuickFiltersTest`. The
remaining app-owned live cards and shell/dialog composition still require
compatibility seams before the full Home move.
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/home/LiveRenameGroupDialog.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveRenameGroupDialog.kt
new file mode 100644
index 00000000..771aac61
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveRenameGroupDialog.kt
@@ -0,0 +1,232 @@
+package com.streamvault.feature.live.home
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.text.KeyboardActions
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.OutlinedTextFieldDefaults
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.window.Dialog
+import androidx.compose.ui.window.DialogProperties
+import androidx.tv.material3.Border
+import androidx.tv.material3.Button
+import androidx.tv.material3.ButtonDefaults
+import androidx.tv.material3.MaterialTheme
+import androidx.tv.material3.Surface
+import androidx.tv.material3.SurfaceDefaults
+import androidx.tv.material3.Text
+import com.streamvault.core.ui.design.FocusSpec
+import com.streamvault.core.ui.design.requestFocusSafely
+import com.streamvault.core.ui.device.rememberIsTelevisionDevice
+import com.streamvault.core.ui.interaction.mouseClickable
+import com.streamvault.core.ui.theme.FocusBorder
+import com.streamvault.core.ui.theme.OnSurface
+import com.streamvault.core.ui.theme.OnSurfaceDim
+import com.streamvault.core.ui.theme.Primary
+import com.streamvault.core.ui.theme.SurfaceElevated
+import kotlinx.coroutines.delay
+
+data class LiveRenameGroupDialogLabels(
+ val title: String,
+ val hint: String,
+ val nameLabel: String,
+ val cancel: String,
+ val confirm: String
+)
+
+@Composable
+fun LiveRenameGroupDialog(
+ initialName: String,
+ errorMessage: String?,
+ labels: LiveRenameGroupDialogLabels,
+ onDismissRequest: () -> Unit,
+ onConfirm: (String) -> Unit
+) {
+ var value by rememberSaveable(initialName) { mutableStateOf(initialName) }
+ var canInteract by remember { mutableStateOf(false) }
+ val focusRequester = remember { FocusRequester() }
+ val keyboardController = LocalSoftwareKeyboardController.current
+ val isTelevisionDevice = rememberIsTelevisionDevice()
+
+ LaunchedEffect(Unit) {
+ focusRequester.requestFocusSafely(tag = "LiveRenameGroupDialog", target = "Rename group field")
+ keyboardController?.show()
+ delay(500)
+ canInteract = true
+ }
+
+ val safeDismiss = {
+ if (canInteract) {
+ keyboardController?.hide()
+ onDismissRequest()
+ }
+ }
+
+ Dialog(
+ onDismissRequest = safeDismiss,
+ properties = DialogProperties(usePlatformDefaultWidth = false)
+ ) {
+ val dialogContent: @Composable (Modifier) -> Unit = { resolvedModifier ->
+ Surface(
+ modifier = resolvedModifier,
+ shape = RoundedCornerShape(24.dp),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated)
+ ) {
+ Column(
+ modifier = Modifier
+ .background(
+ Brush.verticalGradient(
+ listOf(
+ Primary.copy(alpha = 0.08f),
+ Color.Transparent
+ )
+ )
+ )
+ .padding(28.dp),
+ verticalArrangement = Arrangement.spacedBy(16.dp)
+ ) {
+ Text(
+ text = labels.title,
+ style = MaterialTheme.typography.headlineMedium,
+ color = OnSurface
+ )
+ Text(
+ text = labels.hint,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+ OutlinedTextField(
+ value = value,
+ onValueChange = { value = it },
+ modifier = Modifier
+ .fillMaxWidth()
+ .focusRequester(focusRequester),
+ singleLine = true,
+ label = { Text(labels.nameLabel) },
+ colors = OutlinedTextFieldDefaults.colors(
+ focusedTextColor = OnSurface,
+ unfocusedTextColor = OnSurface,
+ cursorColor = Primary,
+ focusedBorderColor = Primary,
+ unfocusedBorderColor = Primary.copy(alpha = 0.55f),
+ focusedLabelColor = Primary,
+ unfocusedLabelColor = OnSurfaceDim,
+ focusedContainerColor = Color.Transparent,
+ unfocusedContainerColor = Color.Transparent
+ ),
+ keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
+ keyboardActions = KeyboardActions(
+ onDone = {
+ val normalized = value.trim()
+ if (canInteract && normalized.isNotEmpty()) {
+ keyboardController?.hide()
+ onConfirm(normalized)
+ }
+ }
+ ),
+ supportingText = errorMessage?.let { message ->
+ { Text(message) }
+ }
+ )
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ val cancelHandler = {
+ if (canInteract) {
+ keyboardController?.hide()
+ onDismissRequest()
+ }
+ }
+ val renameHandler = {
+ val normalized = value.trim()
+ if (canInteract && normalized.isNotEmpty()) {
+ keyboardController?.hide()
+ onConfirm(normalized)
+ }
+ }
+ Button(
+ onClick = cancelHandler,
+ modifier = Modifier.mouseClickable(onClick = cancelHandler),
+ colors = ButtonDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ contentColor = OnSurface,
+ focusedContainerColor = Color.White.copy(alpha = 0.16f),
+ focusedContentColor = OnSurface
+ ),
+ border = ButtonDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, FocusBorder)
+ )
+ ),
+ scale = ButtonDefaults.scale(focusedScale = FocusSpec.FocusedScale)
+ ) {
+ Text(labels.cancel)
+ }
+ Button(
+ onClick = renameHandler,
+ enabled = canInteract && value.trim().isNotEmpty(),
+ modifier = Modifier.mouseClickable(
+ enabled = canInteract && value.trim().isNotEmpty(),
+ onClick = renameHandler
+ ),
+ colors = ButtonDefaults.colors(
+ containerColor = Primary,
+ contentColor = Color.White,
+ focusedContainerColor = Primary.copy(alpha = 0.84f),
+ focusedContentColor = Color.White
+ ),
+ border = ButtonDefaults.border(
+ focusedBorder = Border(
+ border = BorderStroke(FocusSpec.BorderWidth, FocusBorder)
+ )
+ ),
+ scale = ButtonDefaults.scale(focusedScale = FocusSpec.FocusedScale)
+ ) {
+ Text(labels.confirm)
+ }
+ }
+ }
+ }
+ }
+
+ if (isTelevisionDevice) {
+ dialogContent(Modifier.fillMaxWidth(0.42f))
+ } else {
+ BoxWithConstraints(
+ modifier = Modifier.fillMaxWidth(),
+ contentAlignment = Alignment.Center
+ ) {
+ val dialogModifier = when {
+ maxWidth < 700.dp -> Modifier.fillMaxWidth(0.9f)
+ maxWidth < 1280.dp -> Modifier.fillMaxWidth(0.58f)
+ else -> Modifier.fillMaxWidth(0.42f)
+ }
+ dialogContent(dialogModifier)
+ }
+ }
+ }
+}