StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
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.ktindex 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.LiveGuidePreviewPaneimport com.streamvault.feature.live.presentation.epg.LiveGuideToolbarLabelsimport com.streamvault.feature.live.presentation.epg.LiveGuideToolbarRowimport com.streamvault.feature.live.presentation.epg.LiveGuideMessageState+import com.streamvault.feature.live.presentation.epg.LiveGuideGrid+import com.streamvault.feature.live.presentation.epg.LiveGuideGridLabelsimport com.streamvault.feature.live.presentation.epg.LiveGuideEpgOverrideDialogimport com.streamvault.feature.live.presentation.epg.LiveGuideEpgOverrideLabelsimport 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.ktindex 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.SurfaceDefaultsimport androidx.tv.material3.Textimport com.streamvault.app.Rimport com.streamvault.domain.playback.isArchivePlayable-import com.streamvault.app.ui.screens.epg.EpgGridimport com.streamvault.app.ui.screens.epg.EpgUiStateimport com.streamvault.app.ui.screens.epg.EpgViewModelimport com.streamvault.feature.live.presentation.epg.LiveGuideNowProvider@@ -42,6 +41,8 @@ import com.streamvault.feature.live.presentation.epg.LiveCompactGuideProgramDialimport com.streamvault.feature.live.presentation.epg.LiveCompactGuideProgramLabelsimport com.streamvault.feature.live.presentation.epg.LiveGuideToolbarButtonimport com.streamvault.feature.live.presentation.epg.LiveGuideMessageState+import com.streamvault.feature.live.presentation.epg.LiveGuideGrid+import com.streamvault.feature.live.presentation.epg.LiveGuideGridLabelsimport com.streamvault.feature.live.presentation.epg.currentLiveGuideNowimport com.streamvault.app.ui.screens.epg.isGuideCategoryLockedimport 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.mdindex 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 categoryorganizer dialog, M3U series-assignment dialogs, EPG search overlay, guidecategory picker, compact guide-program dialog, guide control rows, EPG previewpane, 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-ownedwhile the Home and EPGscreen/dialog composition remains in `:app` for the remaining app-specificdialogs.@@ -151,7 +152,7 @@ and the rename-group dialog, M3U category organizer dialog, and M3Useries-assignment dialogs, the EPG search overlay, guide category picker, andcompact guide-program dialog, guide control rows, EPG preview pane, guidetoolbar, 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 cleanupremain 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.mdindex 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 categoryorganizer dialog, M3U series-assignment dialogs, EPG search overlay, guidecategory picker, compact guide-program dialog, guide control rows, EPG previewpane, 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-ownedand their feature checks are green. Home screen/dialog composition, theremaining live cards/rows, complete locale resource migration, and acceptancegates remain open.@@ -715,9 +716,11 @@ callers supply the text and optional accent. Stable EPG channel-key generationand timeline marker calculation are feature-owned and covered by focusedidentity/timeline tests. The timeline header owns marker rendering andlive-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`. Theremaining app-owned live cards and shell/dialog composition still requirecompatibility 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.ktsimilarity index 84%rename from app/src/main/java/com/streamvault/app/ui/screens/epg/EpgGridComponents.ktrename to feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideGrid.ktindex 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.epgimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.BoxWithConstraintsimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Spacerimport androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.lazy.LazyColumn@@ -17,22 +16,25 @@ import androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.rememberimport androidx.compose.ui.Modifierimport androidx.compose.ui.focus.FocusRequester-import androidx.compose.ui.res.stringResourceimport 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.guideLookupKeyimport com.streamvault.domain.model.Channelimport com.streamvault.domain.model.Program+import com.streamvault.feature.live.presentation.model.guideLookupKeyimport 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()?.idval 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.ktnew file mode 100644index 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)+ }+}