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 epg grid host

David Nashash57b9389cc880
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
index afec50ed..59078bb7 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgScreen.kt
@@ -25,6 +25,8 @@ import com.streamvault.feature.live.presentation.epg.LiveGuidePreviewPane
import com.streamvault.feature.live.presentation.epg.LiveGuideToolbarLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideToolbarRow
import com.streamvault.feature.live.presentation.epg.LiveGuideMessageState
+import com.streamvault.feature.live.presentation.epg.LiveGuideGrid
+import com.streamvault.feature.live.presentation.epg.LiveGuideGridLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideEpgOverrideDialog
import com.streamvault.feature.live.presentation.epg.LiveGuideEpgOverrideLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideOptionsLabels
@@ -496,7 +498,7 @@ fun FullEpgScreen(
)
}
LiveGuideNowProvider {
- EpgGrid(
+ LiveGuideGrid(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
@@ -506,6 +508,11 @@ fun FullEpgScreen(
guideWindowStart = uiState.guideWindowStart,
guideWindowEnd = uiState.guideWindowEnd,
density = uiState.selectedDensity,
+ labels = LiveGuideGridLabels(
+ noSchedule = stringResource(R.string.epg_no_schedule_short),
+ archiveBadge = stringResource(R.string.player_archive_badge),
+ favoriteBadge = stringResource(R.string.epg_favorite_badge)
+ ),
onChannelClick = { channel ->
if (isGuideChannelLocked(channel, categoriesById, uiState.parentalControlLevel)) {
requestLockedGuideAction(LockedGuideAction.PlayChannel(channel, returnRoute))
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/PlayerTransparentGuideOverlay.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/PlayerTransparentGuideOverlay.kt
index 8bd93864..5428ea82 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/PlayerTransparentGuideOverlay.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/PlayerTransparentGuideOverlay.kt
@@ -30,7 +30,6 @@ import androidx.tv.material3.SurfaceDefaults
import androidx.tv.material3.Text
import com.streamvault.app.R
import com.streamvault.domain.playback.isArchivePlayable
-import com.streamvault.app.ui.screens.epg.EpgGrid
import com.streamvault.app.ui.screens.epg.EpgUiState
import com.streamvault.app.ui.screens.epg.EpgViewModel
import com.streamvault.feature.live.presentation.epg.LiveGuideNowProvider
@@ -42,6 +41,8 @@ import com.streamvault.feature.live.presentation.epg.LiveCompactGuideProgramDial
import com.streamvault.feature.live.presentation.epg.LiveCompactGuideProgramLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideToolbarButton
import com.streamvault.feature.live.presentation.epg.LiveGuideMessageState
+import com.streamvault.feature.live.presentation.epg.LiveGuideGrid
+import com.streamvault.feature.live.presentation.epg.LiveGuideGridLabels
import com.streamvault.feature.live.presentation.epg.currentLiveGuideNow
import com.streamvault.app.ui.screens.epg.isGuideCategoryLocked
import com.streamvault.core.ui.theme.OnSurfaceDim
@@ -223,13 +224,18 @@ fun PlayerTransparentGuideOverlay(
)
}
else -> {
- EpgGrid(
+ LiveGuideGrid(
channels = uiState.channels,
favoriteChannelIds = uiState.favoriteChannelIds,
programsByChannel = uiState.programsByChannel,
guideWindowStart = uiState.guideWindowStart,
guideWindowEnd = uiState.guideWindowEnd,
density = uiState.selectedDensity,
+ labels = LiveGuideGridLabels(
+ noSchedule = stringResource(R.string.epg_no_schedule_short),
+ archiveBadge = stringResource(R.string.player_archive_badge),
+ favoriteBadge = stringResource(R.string.epg_favorite_badge)
+ ),
transparentOverlay = true,
initialFocusedChannelId = currentPlayerChannelId.takeIf { it > 0L },
onChannelClick = { channel ->
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 3f1f11a4..81a2ed01 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -138,7 +138,8 @@ quick-filter add dialog, delete-group dialog, rename-group dialog, M3U category
organizer dialog, M3U series-assignment dialogs, EPG search overlay, guide
category picker, compact guide-program dialog, guide control rows, EPG preview
pane, guide toolbar, guide message state, hero badge, timeline header, grid
-rows/cells, options overlay, and EPG-match dialog are now feature-owned
+rows/cells, grid host, options overlay, and EPG-match dialog are now
+feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
@@ -151,7 +152,7 @@ and the rename-group dialog, M3U category organizer dialog, and M3U
series-assignment dialogs, the EPG search overlay, guide category picker, and
compact guide-program dialog, guide control rows, EPG preview pane, guide
toolbar, guide message state, hero badge, stable EPG channel-key helper,
-timeline header, grid rows/cells, options overlay, and EPG-match dialog are
-independent of app code;
+timeline header, grid rows/cells, grid host, options overlay, and EPG-match
+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 91d7058f..fa3b9106 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -28,7 +28,8 @@ quick-filter add dialog, delete-group dialog, rename-group dialog, M3U category
organizer dialog, M3U series-assignment dialogs, EPG search overlay, guide
category picker, compact guide-program dialog, guide control rows, EPG preview
pane, guide toolbar, guide message state, hero badge, timeline header, grid
-rows/cells, options overlay, and EPG-match dialog are now feature-owned
+rows/cells, grid host, options overlay, and EPG-match 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.
@@ -715,9 +716,11 @@ callers supply the text and optional accent. Stable EPG channel-key generation
and timeline marker calculation are feature-owned and covered by focused
identity/timeline tests. The timeline header owns marker rendering and
live-time presentation while the app supplies sizing and scroll state. Grid
-rows/cells, options overlay, and EPG-match dialog likewise own their
-presentation and focus behavior while the app supplies localized labels and
-state/action callbacks.
+rows/cells and the grid host own guide row composition, sizing, scrolling, and
+focus behavior while the app supplies localized labels, guide data, and
+state/action callbacks. The options overlay and EPG-match dialog likewise own
+their presentation and focus behavior while the app supplies localized labels
+and state/action 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/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideGrid.kt
similarity index 84%
rename from app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
rename to feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideGrid.kt
index 3ef0fa5b..8b2edb68 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.kt
+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideGrid.kt
@@ -1,11 +1,10 @@
-package com.streamvault.app.ui.screens.epg
+package com.streamvault.feature.live.presentation.epg
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
@@ -17,22 +16,25 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
-import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
-import com.streamvault.app.R
-import com.streamvault.feature.live.presentation.epg.GuideDensity
-import com.streamvault.feature.live.presentation.epg.LIVE_GUIDE_MARKER_STEP_MS
-import com.streamvault.feature.live.presentation.epg.LiveGuideGridLabels
-import com.streamvault.feature.live.presentation.epg.LiveGuideGridRow
-import com.streamvault.feature.live.presentation.epg.LiveGuideTimelineHeader
-import com.streamvault.feature.live.presentation.epg.liveEpgChannelKey
-import com.streamvault.feature.live.presentation.model.guideLookupKey
import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Program
+import com.streamvault.feature.live.presentation.model.guideLookupKey
import kotlinx.coroutines.delay
+fun liveGuideInitialFocusIndex(
+ channels: List<Channel>,
+ initialFocusedChannelId: Long?
+): Int {
+ val resolvedInitialChannelId = initialFocusedChannelId ?: channels.firstOrNull()?.id
+ return resolvedInitialChannelId
+ ?.let { channelId -> channels.indexOfFirst { it.id == channelId } }
+ ?.takeIf { it >= 0 }
+ ?: 0
+}
+
@Composable
-internal fun EpgGrid(
+fun LiveGuideGrid(
modifier: Modifier = Modifier,
channels: List<Channel>,
favoriteChannelIds: Set<Long>,
@@ -40,6 +42,7 @@ internal fun EpgGrid(
guideWindowStart: Long,
guideWindowEnd: Long,
density: GuideDensity,
+ labels: LiveGuideGridLabels,
transparentOverlay: Boolean = false,
initialFocusedChannelId: Long? = null,
onChannelClick: (Channel) -> Unit,
@@ -61,10 +64,7 @@ internal fun EpgGrid(
val resolvedInitialChannelId = initialFocusedChannelId ?: channels.firstOrNull()?.id
val initialFocusRequester = remember(resolvedInitialChannelId) { FocusRequester() }
val initialFocusIndex = remember(channels, resolvedInitialChannelId) {
- resolvedInitialChannelId
- ?.let { channelId -> channels.indexOfFirst { it.id == channelId } }
- ?.takeIf { it >= 0 }
- ?: 0
+ liveGuideInitialFocusIndex(channels, resolvedInitialChannelId)
}
LaunchedEffect(channels.size, resolvedInitialChannelId) {
@@ -79,11 +79,6 @@ internal fun EpgGrid(
.fillMaxSize()
.padding(horizontal = 12.dp, vertical = 2.dp)
) {
- val gridLabels = LiveGuideGridLabels(
- noSchedule = stringResource(R.string.epg_no_schedule_short),
- archiveBadge = stringResource(R.string.player_archive_badge),
- favoriteBadge = stringResource(R.string.epg_favorite_badge)
- )
val timelineViewportWidth = (maxWidth - channelRailWidth - timelineGap).coerceAtLeast(640.dp)
val totalDuration = (guideWindowEnd - guideWindowStart).coerceAtLeast(1L)
val visibleDurationMs = 3 * 60 * 60 * 1000L
@@ -139,7 +134,7 @@ internal fun EpgGrid(
rowHeight = rowHeight,
markerStepMs = markerStepMs,
scrollState = horizontalScrollState,
- labels = gridLabels,
+ labels = labels,
focusRequester = if (channel.id == resolvedInitialChannelId) initialFocusRequester else null,
onChannelClick = { onChannelClick(channel) },
onChannelLongClick = onChannelLongClick?.let { cb -> { prog -> cb(channel, prog) } },
diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideGridTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideGridTest.kt
new file mode 100644
index 00000000..f9ebe1d3
--- /dev/null
+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideGridTest.kt
@@ -0,0 +1,25 @@
+package com.streamvault.feature.live.presentation.epg
+
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.Channel
+import org.junit.Test
+
+class LiveGuideGridTest {
+ @Test
+ fun `initial focus index resolves a requested channel`() {
+ val channels = listOf(
+ Channel(id = 10L, name = "News"),
+ Channel(id = 20L, name = "Sports")
+ )
+
+ assertThat(liveGuideInitialFocusIndex(channels, 20L)).isEqualTo(1)
+ }
+
+ @Test
+ fun `initial focus index falls back to the first channel`() {
+ val channels = listOf(Channel(id = 10L, name = "News"))
+
+ assertThat(liveGuideInitialFocusIndex(channels, 99L)).isEqualTo(0)
+ assertThat(liveGuideInitialFocusIndex(channels, null)).isEqualTo(0)
+ }
+}