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 preview pane

David Nashashf56d47da33e4
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
index af58fad2..24f0dc6b 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgHeroComponents.kt
@@ -3,11 +3,8 @@ package com.streamvault.app.ui.screens.epg
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.aspectRatio
-import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -16,7 +13,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
@@ -31,10 +27,8 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.tv.material3.Border
import androidx.tv.material3.ClickableSurfaceDefaults
import androidx.tv.material3.MaterialTheme
@@ -45,7 +39,6 @@ import com.streamvault.app.R
import com.streamvault.feature.live.presentation.epg.GuideDensity
import com.streamvault.feature.live.presentation.epg.currentLiveGuideNow
import com.streamvault.core.ui.image.ChannelLogoBadge
-import com.streamvault.player.ui.PlayerRenderView
import com.streamvault.domain.playback.isArchivePlayable
import com.streamvault.core.ui.interaction.TvClickableSurface
import com.streamvault.feature.live.presentation.model.guideLookupKey
@@ -59,9 +52,6 @@ import com.streamvault.core.ui.theme.SurfaceElevated
import com.streamvault.core.ui.theme.SurfaceHighlight
import com.streamvault.domain.model.Channel
import com.streamvault.domain.model.Program
-import com.streamvault.player.PlayerEngine
-import com.streamvault.player.PlayerRenderSurfaceType
-import com.streamvault.player.PlayerSurfaceResizeMode
import java.util.Date
internal data class GuideHeroSelection(
@@ -96,7 +86,6 @@ internal fun resolveGuideHeroSelection(
isFallbackToChannel = resolvedProgram == null
)
}
-
@Composable
internal fun GuideHeroSection(
uiState: EpgUiState,
@@ -310,150 +299,6 @@ internal fun GuideHeroBadge(
}
}
-@Composable
-internal fun GuidePreviewPane(
- previewPlayerEngine: PlayerEngine?,
- isPreviewLoading: Boolean,
- focusedChannel: Channel?,
- focusedProgram: Program?,
- modifier: Modifier = Modifier
-) {
- val renderSurfaceType by (previewPlayerEngine?.renderSurfaceType)?.collectAsStateWithLifecycle(
- initialValue = PlayerRenderSurfaceType.SURFACE_VIEW
- ) ?: remember { mutableStateOf(PlayerRenderSurfaceType.SURFACE_VIEW) }
- val now = currentLiveGuideNow()
- val appTimeFormat = LocalLiveTimeFormat.current
- val timeFormat = remember(appTimeFormat) { appTimeFormat.createLiveTimeFormat() }
-
- Surface(
- modifier = modifier.height(150.dp),
- colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
- shape = RoundedCornerShape(20.dp)
- ) {
- Row(
- modifier = Modifier
- .fillMaxSize()
- .padding(10.dp),
- horizontalArrangement = Arrangement.spacedBy(14.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- // Video preview area (16:9 at 90dp height = 160dp wide)
- Box(
- modifier = Modifier
- .fillMaxHeight()
- .aspectRatio(16f / 9f)
- .background(Color.Black, RoundedCornerShape(12.dp))
- .clip(RoundedCornerShape(12.dp)),
- contentAlignment = Alignment.Center
- ) {
- if (previewPlayerEngine != null) {
- PlayerRenderView(
- playerEngine = previewPlayerEngine,
- resizeMode = PlayerSurfaceResizeMode.FIT,
- surfaceType = renderSurfaceType,
- modifier = Modifier.fillMaxSize()
- )
- if (isPreviewLoading) {
- CircularProgressIndicator(
- color = Primary,
- strokeWidth = 2.dp,
- modifier = Modifier.size(22.dp)
- )
- }
- } else {
- Column(
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(4.dp),
- modifier = Modifier.padding(horizontal = 12.dp)
- ) {
- Text(
- text = stringResource(R.string.live_preview_placeholder_title),
- style = MaterialTheme.typography.labelMedium,
- color = OnSurfaceDim,
- textAlign = TextAlign.Center
- )
- }
- }
- }
-
- // Program info
- val channel = focusedChannel
- val program = focusedProgram
- if (channel != null) {
- Column(
- modifier = Modifier.weight(1f),
- verticalArrangement = Arrangement.spacedBy(2.dp)
- ) {
- Row(
- horizontalArrangement = Arrangement.spacedBy(10.dp),
- verticalAlignment = Alignment.CenterVertically
- ) {
- ChannelLogoBadge(
- channelName = channel.name,
- logoUrl = channel.logoUrl,
- modifier = Modifier.size(32.dp),
- shape = RoundedCornerShape(8.dp)
- )
- Text(
- text = if (channel.number > 0) "${channel.number}. ${channel.name}" else channel.name,
- style = MaterialTheme.typography.titleSmall,
- color = OnSurface,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- }
- if (program != null) {
- Text(
- text = program.title,
- style = MaterialTheme.typography.bodyMedium,
- color = OnSurface,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
- Text(
- text = "${timeFormat.format(Date(program.startTime))} ג€“ ${timeFormat.format(Date(program.endTime))}",
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim
- )
- if (now in program.startTime until program.endTime) {
- LinearProgressIndicator(
- progress = { ((now - program.startTime).toFloat() / (program.endTime - program.startTime).toFloat()).coerceIn(0f, 1f) },
- modifier = Modifier
- .fillMaxWidth(0.6f)
- .height(3.dp),
- color = Primary,
- trackColor = SurfaceHighlight
- )
- }
- if (program.description.isNotBlank()) {
- Text(
- text = program.description,
- style = MaterialTheme.typography.labelSmall,
- color = OnSurfaceDim,
- maxLines = 2,
- overflow = TextOverflow.Ellipsis
- )
- }
- } else {
- Text(
- text = stringResource(R.string.epg_no_schedule),
- style = MaterialTheme.typography.bodySmall,
- color = OnSurfaceDim
- )
- }
- }
- } else {
- Text(
- text = stringResource(R.string.epg_title),
- style = MaterialTheme.typography.titleSmall,
- color = OnSurfaceDim,
- modifier = Modifier.weight(1f)
- )
- }
- }
- }
-}
-
@Composable
internal fun GuideToolbarRow(
selectedCategoryName: String,
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 81fd2305..9820b26c 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
@@ -20,6 +20,8 @@ import com.streamvault.feature.live.presentation.epg.LiveGuideFavoritesLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideModeLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideTimeControlLabels
import com.streamvault.feature.live.presentation.epg.LiveGuideViewOptionsLabels
+import com.streamvault.feature.live.presentation.epg.LiveGuidePreviewLabels
+import com.streamvault.feature.live.presentation.epg.LiveGuidePreviewPane
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -433,11 +435,16 @@ fun FullEpgScreen(
else -> {
LiveGuideNowProvider {
- GuidePreviewPane(
+ LiveGuidePreviewPane(
previewPlayerEngine = uiState.previewPlayerEngine,
isPreviewLoading = uiState.isPreviewLoading,
focusedChannel = focusedChannel,
focusedProgram = focusedProgram,
+ labels = LiveGuidePreviewLabels(
+ title = stringResource(R.string.epg_title),
+ placeholderTitle = stringResource(R.string.live_preview_placeholder_title),
+ noSchedule = stringResource(R.string.epg_no_schedule)
+ ),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 14.dp, vertical = 4.dp)
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index abacb2f1..1a6a0bd2 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -136,8 +136,8 @@ 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, delete-group dialog, rename-group dialog, M3U category
organizer dialog, M3U series-assignment dialogs, EPG search overlay, guide
-category picker, compact guide-program dialog, and the guide control rows are
-now feature-owned
+category picker, compact guide-program dialog, guide control rows, and EPG
+preview pane are now feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
@@ -148,6 +148,7 @@ mode/density/reminder presentation models, hidden collection dialogs, the
category options dialog, the quick-filter add dialog, the delete-group dialog,
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 and guide control rows are independent of app code;
+compact guide-program dialog, guide control rows, and EPG preview pane 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 db147bfa..2d1b5e5d 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -26,8 +26,8 @@ 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, delete-group dialog, rename-group dialog, M3U category
organizer dialog, M3U series-assignment dialogs, EPG search overlay, guide
-category picker, compact guide-program dialog, and guide control rows are now
-feature-owned
+category picker, compact guide-program dialog, guide control rows, and EPG
+preview pane 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.
@@ -702,7 +702,9 @@ details state, focus, and action affordances while the app supplies labels and
playback/recording callbacks.
The guide control rows (time paging, day selection, mode, density, view, and
favorites) are also feature-owned; the options shell continues to supply labels
-and ViewModel callbacks from `:app`.
+and ViewModel callbacks from `:app`. The preview pane owns render-surface
+selection, placeholder/loading states, channel/program metadata, and progress
+presentation while the app supplies the player and focused data.
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/presentation/epg/LiveGuidePreviewPane.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuidePreviewPane.kt
new file mode 100644
index 00000000..c2e7ddcd
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuidePreviewPane.kt
@@ -0,0 +1,189 @@
+package com.streamvault.feature.live.presentation.epg
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.aspectRatio
+import androidx.compose.foundation.layout.fillMaxHeight
+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.layout.size
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.LinearProgressIndicator
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+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.image.ChannelLogoBadge
+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.core.ui.theme.SurfaceHighlight
+import com.streamvault.domain.model.Channel
+import com.streamvault.domain.model.Program
+import com.streamvault.feature.live.presentation.time.LocalLiveTimeFormat
+import com.streamvault.feature.live.presentation.time.createLiveTimeFormat
+import com.streamvault.player.PlayerEngine
+import com.streamvault.player.PlayerRenderSurfaceType
+import com.streamvault.player.PlayerSurfaceResizeMode
+import com.streamvault.player.ui.PlayerRenderView
+import java.util.Date
+
+data class LiveGuidePreviewLabels(
+ val title: String,
+ val placeholderTitle: String,
+ val noSchedule: String
+)
+
+@Composable
+fun LiveGuidePreviewPane(
+ previewPlayerEngine: PlayerEngine?,
+ isPreviewLoading: Boolean,
+ focusedChannel: Channel?,
+ focusedProgram: Program?,
+ labels: LiveGuidePreviewLabels,
+ modifier: Modifier = Modifier
+) {
+ val renderSurfaceType by (previewPlayerEngine?.renderSurfaceType)?.collectAsStateWithLifecycle(
+ initialValue = PlayerRenderSurfaceType.SURFACE_VIEW
+ ) ?: remember { mutableStateOf(PlayerRenderSurfaceType.SURFACE_VIEW) }
+ val now = currentLiveGuideNow()
+ val appTimeFormat = LocalLiveTimeFormat.current
+ val timeFormat = remember(appTimeFormat) { appTimeFormat.createLiveTimeFormat() }
+
+ Surface(
+ modifier = modifier.height(150.dp),
+ colors = SurfaceDefaults.colors(containerColor = SurfaceElevated),
+ shape = RoundedCornerShape(20.dp)
+ ) {
+ Row(
+ modifier = Modifier.fillMaxSize().padding(10.dp),
+ horizontalArrangement = Arrangement.spacedBy(14.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxHeight()
+ .aspectRatio(16f / 9f)
+ .background(Color.Black, RoundedCornerShape(12.dp))
+ .clip(RoundedCornerShape(12.dp)),
+ contentAlignment = Alignment.Center
+ ) {
+ if (previewPlayerEngine != null) {
+ PlayerRenderView(
+ playerEngine = previewPlayerEngine,
+ resizeMode = PlayerSurfaceResizeMode.FIT,
+ surfaceType = renderSurfaceType,
+ modifier = Modifier.fillMaxSize()
+ )
+ if (isPreviewLoading) {
+ CircularProgressIndicator(
+ color = Primary,
+ strokeWidth = 2.dp,
+ modifier = Modifier.size(22.dp)
+ )
+ }
+ } else {
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(4.dp),
+ modifier = Modifier.padding(horizontal = 12.dp)
+ ) {
+ Text(
+ text = labels.placeholderTitle,
+ style = MaterialTheme.typography.labelMedium,
+ color = OnSurfaceDim,
+ textAlign = TextAlign.Center
+ )
+ }
+ }
+ }
+
+ val channel = focusedChannel
+ val program = focusedProgram
+ if (channel != null) {
+ Column(
+ modifier = Modifier.weight(1f),
+ verticalArrangement = Arrangement.spacedBy(2.dp)
+ ) {
+ Row(
+ horizontalArrangement = Arrangement.spacedBy(10.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ ChannelLogoBadge(
+ channelName = channel.name,
+ logoUrl = channel.logoUrl,
+ modifier = Modifier.size(32.dp),
+ shape = RoundedCornerShape(8.dp)
+ )
+ Text(
+ text = if (channel.number > 0) "${channel.number}. ${channel.name}" else channel.name,
+ style = MaterialTheme.typography.titleSmall,
+ color = OnSurface,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ if (program != null) {
+ Text(
+ text = program.title,
+ style = MaterialTheme.typography.bodyMedium,
+ color = OnSurface,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ Text(
+ text = "${timeFormat.format(Date(program.startTime))} ׳’ג‚¬ג€œ ${timeFormat.format(Date(program.endTime))}",
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim
+ )
+ if (now in program.startTime until program.endTime) {
+ LinearProgressIndicator(
+ progress = { ((now - program.startTime).toFloat() / (program.endTime - program.startTime).toFloat()).coerceIn(0f, 1f) },
+ modifier = Modifier.fillMaxWidth(0.6f).height(3.dp),
+ color = Primary,
+ trackColor = SurfaceHighlight
+ )
+ }
+ if (program.description.isNotBlank()) {
+ Text(
+ text = program.description,
+ style = MaterialTheme.typography.labelSmall,
+ color = OnSurfaceDim,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
+ } else {
+ Text(text = labels.noSchedule, style = MaterialTheme.typography.bodySmall, color = OnSurfaceDim)
+ }
+ }
+ } else {
+ Text(
+ text = labels.title,
+ style = MaterialTheme.typography.titleSmall,
+ color = OnSurfaceDim,
+ modifier = Modifier.weight(1f)
+ )
+ }
+ }
+ }
+}