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 home filter and category dialogs

David Nashash965ce21e3350
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 9944496a..7c9f6c5c 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
@@ -1,12 +1,10 @@
package com.streamvault.app.ui.screens.home
-import androidx.compose.foundation.layout.fillMaxWidth
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.Modifier
import androidx.compose.ui.platform.LocalContext
@@ -15,12 +13,9 @@ import com.streamvault.app.R
import com.streamvault.feature.live.presentation.home.HomeUiState
import com.streamvault.feature.live.home.HomeViewModel
import com.streamvault.app.navigation.Routes
-import com.streamvault.core.ui.components.SearchInput
import com.streamvault.app.ui.components.dialogs.AddToGroupDialog
-import com.streamvault.app.ui.components.dialogs.CategoryOptionsDialog
import com.streamvault.core.ui.components.dialogs.PinDialog
import com.streamvault.core.ui.components.dialogs.PremiumDialog
-import com.streamvault.core.ui.components.dialogs.PremiumDialogActionButton
import com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButton
import com.streamvault.app.ui.components.dialogs.RenameGroupDialog
import com.streamvault.app.ui.components.dialogs.M3uCategoryOrganizerDialog
@@ -28,6 +23,10 @@ import com.streamvault.app.ui.components.dialogs.M3uCategorySeriesAssignmentDial
import com.streamvault.app.ui.components.dialogs.M3uSeriesAssignmentDialog
import com.streamvault.feature.playback.multiview.MultiViewPlannerDialog
import com.streamvault.feature.playback.multiview.MultiViewViewModel
+import com.streamvault.feature.live.home.LiveCategoryOptionsDialog
+import com.streamvault.feature.live.home.LiveCategoryOptionsDialogLabels
+import com.streamvault.feature.live.home.LiveAddQuickFilterDialog
+import com.streamvault.feature.live.home.LiveAddQuickFilterDialogLabels
import com.streamvault.domain.model.ActiveLiveSource
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.Channel
@@ -142,8 +141,24 @@ internal fun HomeDialogsHost(
(category.isAdult || category.isUserProtected) &&
uiState.parentalControlLevel in 1..2 &&
kotlin.math.abs(category.id) !in uiState.unlockedCategoryIds
- CategoryOptionsDialog(
+ LiveCategoryOptionsDialog(
category = category,
+ labels = LiveCategoryOptionsDialogLabels(
+ hint = stringResource(R.string.library_saved_manage_hint),
+ setDefault = stringResource(R.string.category_options_set_default),
+ pin = stringResource(R.string.category_options_pin),
+ unpin = stringResource(R.string.category_options_unpin),
+ rename = stringResource(R.string.category_options_rename),
+ hide = stringResource(R.string.category_options_hide),
+ hideFromLiveTv = stringResource(R.string.category_options_hide_from_live_tv),
+ clearRecent = stringResource(R.string.category_options_clear_recent),
+ reorder = stringResource(R.string.category_options_reorder),
+ organizeM3u = stringResource(R.string.m3u_organize_items),
+ lock = stringResource(R.string.category_options_lock),
+ unlock = stringResource(R.string.category_options_unlock),
+ delete = stringResource(R.string.category_options_delete),
+ cancel = stringResource(R.string.category_options_cancel)
+ ),
onDismissRequest = { viewModel.dismissCategoryOptions() },
onSetAsDefault = if (isCategoryLocked) null else {
{
@@ -204,40 +219,17 @@ internal fun HomeDialogsHost(
}
if (showAddQuickFilterDialog) {
- var pendingFilter by rememberSaveable { mutableStateOf("") }
- PremiumDialog(
- title = stringResource(R.string.home_quick_filters_add_title),
- subtitle = stringResource(R.string.home_quick_filters_add_subtitle),
- onDismissRequest = { onShowAddQuickFilterDialogChange(false) },
- widthFraction = 0.42f,
- content = {
- SearchInput(
- value = pendingFilter,
- onValueChange = { pendingFilter = it },
- placeholder = stringResource(R.string.home_quick_filters_add_placeholder),
- modifier = Modifier.fillMaxWidth()
- )
- PremiumDialogActionButton(
- label = stringResource(R.string.home_quick_filters_add_action),
- enabled = pendingFilter.isNotBlank(),
- onClick = {
- val normalized = pendingFilter.trim()
- val isDuplicate = uiState.savedCategoryFilters.any {
- it.equals(normalized, ignoreCase = true)
- }
- viewModel.addLiveTvCategoryFilter(pendingFilter)
- if (normalized.isNotBlank() && !isDuplicate) {
- onShowAddQuickFilterDialogChange(false)
- }
- }
- )
- },
- footer = {
- PremiumDialogFooterButton(
- label = stringResource(R.string.settings_cancel),
- onClick = { onShowAddQuickFilterDialogChange(false) }
- )
- }
+ LiveAddQuickFilterDialog(
+ savedFilters = uiState.savedCategoryFilters,
+ labels = LiveAddQuickFilterDialogLabels(
+ title = stringResource(R.string.home_quick_filters_add_title),
+ subtitle = stringResource(R.string.home_quick_filters_add_subtitle),
+ placeholder = stringResource(R.string.home_quick_filters_add_placeholder),
+ action = stringResource(R.string.home_quick_filters_add_action),
+ cancel = stringResource(R.string.settings_cancel)
+ ),
+ onAddFilter = viewModel::addLiveTvCategoryFilter,
+ onDismiss = { onShowAddQuickFilterDialogChange(false) }
)
}
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 6898293d..7a72945e 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -133,14 +133,16 @@ quick-filter panel/chip row, the reusable EPG guide shortcut chip, the shared
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 are now feature-owned
+and hidden category/channel dialogs, the category options dialog, and the
+quick-filter add dialog are now feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
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, and hidden collection dialogs are
-independent of app code;
+mode/density/reminder presentation models, hidden collection dialogs, the
+category options dialog, and the quick-filter add 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 00de62c4..68a86989 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -23,7 +23,8 @@ quick-filter panel/chip row, the reusable EPG guide shortcut chip, the shared
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 are now feature-owned
+and hidden category/channel dialogs, the category options dialog, and the
+quick-filter add 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.
@@ -676,7 +677,11 @@ container/key/content-type mechanics while the app retains category policy,
focus transitions, and callbacks. The
hidden category/channel dialogs now also live in `:feature:live`; `HomeScreen`
supplies app-localized labels and retains the ViewModel callbacks while other
-app-specific dialogs remain in the composition root. The
+app-specific dialogs remain in the composition root. The category options
+dialog follows the same contract: feature-owned UI receives a label bundle and
+the app retains policy/callback wiring. The
+quick-filter add dialog also owns its draft text and duplicate check while the
+app supplies the saved-filter snapshot and mutation callback. The
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/LiveAddQuickFilterDialog.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveAddQuickFilterDialog.kt
new file mode 100644
index 00000000..8ef5a16c
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveAddQuickFilterDialog.kt
@@ -0,0 +1,65 @@
+package com.streamvault.feature.live.home
+
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import com.streamvault.core.ui.components.SearchInput
+import com.streamvault.core.ui.components.dialogs.PremiumDialog
+import com.streamvault.core.ui.components.dialogs.PremiumDialogActionButton
+import com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButton
+
+data class LiveAddQuickFilterDialogLabels(
+ val title: String,
+ val subtitle: String,
+ val placeholder: String,
+ val action: String,
+ val cancel: String
+)
+
+@Composable
+fun LiveAddQuickFilterDialog(
+ savedFilters: List<String>,
+ labels: LiveAddQuickFilterDialogLabels,
+ onAddFilter: (String) -> Unit,
+ onDismiss: () -> Unit
+) {
+ var pendingFilter by rememberSaveable { mutableStateOf("") }
+ PremiumDialog(
+ title = labels.title,
+ subtitle = labels.subtitle,
+ onDismissRequest = onDismiss,
+ widthFraction = 0.42f,
+ content = {
+ SearchInput(
+ value = pendingFilter,
+ onValueChange = { pendingFilter = it },
+ placeholder = labels.placeholder,
+ modifier = Modifier.fillMaxWidth()
+ )
+ PremiumDialogActionButton(
+ label = labels.action,
+ enabled = pendingFilter.isNotBlank(),
+ onClick = {
+ val normalized = pendingFilter.trim()
+ val isDuplicate = savedFilters.any {
+ it.equals(normalized, ignoreCase = true)
+ }
+ onAddFilter(pendingFilter)
+ if (normalized.isNotBlank() && !isDuplicate) {
+ onDismiss()
+ }
+ }
+ )
+ },
+ footer = {
+ PremiumDialogFooterButton(
+ label = labels.cancel,
+ onClick = onDismiss
+ )
+ }
+ )
+}
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/home/LiveCategoryOptionsDialog.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveCategoryOptionsDialog.kt
new file mode 100644
index 00000000..6dc2d271
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/LiveCategoryOptionsDialog.kt
@@ -0,0 +1,252 @@
+package com.streamvault.feature.live.home
+
+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.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.RoundedCornerShape
+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.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.input.key.onPreviewKeyEvent
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.window.Dialog
+import androidx.compose.ui.window.DialogProperties
+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.components.dialogs.rememberDialogOpenGestureBlocker
+import com.streamvault.core.ui.interaction.mouseClickable
+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 com.streamvault.domain.model.Category
+import kotlinx.coroutines.delay
+
+data class LiveCategoryOptionsDialogLabels(
+ val hint: String,
+ val setDefault: String,
+ val pin: String,
+ val unpin: String,
+ val rename: String,
+ val hide: String,
+ val hideFromLiveTv: String,
+ val clearRecent: String,
+ val reorder: String,
+ val organizeM3u: String,
+ val lock: String,
+ val unlock: String,
+ val delete: String,
+ val cancel: String
+)
+
+@Composable
+fun LiveCategoryOptionsDialog(
+ category: Category,
+ labels: LiveCategoryOptionsDialogLabels,
+ onDismissRequest: () -> Unit,
+ onSetAsDefault: (() -> Unit)? = null,
+ isPinned: Boolean = false,
+ onTogglePinned: (() -> Unit)? = null,
+ onRename: (() -> Unit)? = null,
+ onHide: (() -> Unit)? = null,
+ onHideFromLiveTV: (() -> Unit)? = null,
+ onClearAll: (() -> Unit)? = null,
+ onToggleLock: (() -> Unit)? = null,
+ onDelete: (() -> Unit)? = null,
+ onReorderChannels: (() -> Unit)? = null,
+ onOrganizeM3u: (() -> Unit)? = null
+) {
+ var canInteract by remember { mutableStateOf(false) }
+ val blockOpenGesture = rememberDialogOpenGestureBlocker(canInteract)
+ LaunchedEffect(Unit) {
+ delay(500)
+ canInteract = true
+ }
+
+ val safeDismiss = { if (canInteract) onDismissRequest() }
+
+ Dialog(
+ onDismissRequest = safeDismiss,
+ properties = DialogProperties(
+ dismissOnBackPress = canInteract,
+ dismissOnClickOutside = canInteract,
+ usePlatformDefaultWidth = false
+ )
+ ) {
+ BoxWithConstraints(
+ modifier = Modifier.fillMaxWidth(),
+ contentAlignment = Alignment.Center
+ ) {
+ val dialogWidth = when {
+ maxWidth < 700.dp -> 0.9f
+ maxWidth < 1280.dp -> 0.56f
+ else -> 0.38f
+ }
+ Surface(
+ modifier = Modifier
+ .fillMaxWidth(dialogWidth)
+ .onPreviewKeyEvent(blockOpenGesture),
+ 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(12.dp)
+ ) {
+ Text(
+ text = category.name,
+ style = MaterialTheme.typography.headlineMedium,
+ color = OnSurface
+ )
+ Text(
+ text = labels.hint,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurfaceDim
+ )
+
+ if (onSetAsDefault != null) {
+ LiveCategoryOptionsAction(
+ label = labels.setDefault,
+ onClick = { if (canInteract) onSetAsDefault() }
+ )
+ }
+
+ if (onTogglePinned != null) {
+ LiveCategoryOptionsAction(
+ label = if (isPinned) labels.unpin else labels.pin,
+ onClick = { if (canInteract) onTogglePinned() }
+ )
+ }
+
+ if (onRename != null) {
+ LiveCategoryOptionsAction(
+ label = labels.rename,
+ onClick = { if (canInteract) onRename() }
+ )
+ }
+
+ if (onHide != null) {
+ LiveCategoryOptionsAction(
+ label = labels.hide,
+ onClick = {
+ if (canInteract) {
+ onHide()
+ onDismissRequest()
+ }
+ }
+ )
+ }
+
+ if (onHideFromLiveTV != null) {
+ LiveCategoryOptionsAction(
+ label = labels.hideFromLiveTv,
+ onClick = { if (canInteract) onHideFromLiveTV() }
+ )
+ }
+
+ if (onClearAll != null) {
+ LiveCategoryOptionsAction(
+ label = labels.clearRecent,
+ onClick = { if (canInteract) onClearAll() },
+ destructive = true
+ )
+ }
+
+ if (onReorderChannels != null) {
+ LiveCategoryOptionsAction(
+ label = labels.reorder,
+ onClick = {
+ if (canInteract) {
+ onReorderChannels()
+ onDismissRequest()
+ }
+ }
+ )
+ }
+
+ if (onOrganizeM3u != null) {
+ LiveCategoryOptionsAction(
+ label = labels.organizeM3u,
+ onClick = { if (canInteract) onOrganizeM3u() }
+ )
+ }
+
+ if (onToggleLock != null) {
+ LiveCategoryOptionsAction(
+ label = if (category.isUserProtected) labels.unlock else labels.lock,
+ onClick = { if (canInteract) onToggleLock() }
+ )
+ }
+
+ if (onDelete != null) {
+ LiveCategoryOptionsAction(
+ label = labels.delete,
+ onClick = { if (canInteract) onDelete() },
+ destructive = true
+ )
+ }
+
+ Button(
+ onClick = safeDismiss,
+ modifier = Modifier.mouseClickable(onClick = safeDismiss),
+ colors = ButtonDefaults.colors(
+ containerColor = Color.White.copy(alpha = 0.08f),
+ contentColor = OnSurface
+ )
+ ) {
+ Text(labels.cancel)
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun LiveCategoryOptionsAction(
+ label: String,
+ onClick: () -> Unit,
+ destructive: Boolean = false
+) {
+ Button(
+ onClick = onClick,
+ modifier = Modifier.fillMaxWidth().mouseClickable(onClick = onClick),
+ colors = ButtonDefaults.colors(
+ containerColor = if (destructive) {
+ MaterialTheme.colorScheme.errorContainer
+ } else {
+ Color.White.copy(alpha = 0.08f)
+ },
+ contentColor = if (destructive) {
+ MaterialTheme.colorScheme.onErrorContainer
+ } else {
+ OnSurface
+ }
+ )
+ ) {
+ Text(label)
+ }
+}