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 home layout metrics
David Nashash979cf11c7373
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.ktindex aaee7340..185e63ec 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeScreen.kt@@ -55,6 +55,7 @@ import com.streamvault.core.ui.components.dialogs.PremiumDialogActionButtonimport com.streamvault.core.ui.components.dialogs.PremiumDialogFooterButtonimport com.streamvault.app.ui.components.dialogs.RenameGroupDialogimport com.streamvault.feature.live.presentation.components.LiveReorderTopBar+import com.streamvault.feature.live.presentation.home.liveHomeLayoutMetricsimport com.streamvault.app.ui.components.shell.AppNavigationChromeimport com.streamvault.app.ui.components.shell.AppScreenScaffoldimport com.streamvault.core.ui.design.FocusRestoreHost@@ -119,36 +120,16 @@ fun HomeScreen(val isReorderMode = uiState.isChannelReorderModeval isProMode = uiState.liveTvChannelMode == LiveTvChannelMode.PROval isDenseMode = uiState.liveTvChannelMode != LiveTvChannelMode.COMFORTABLE- val screenWidth = LocalConfiguration.current.screenWidthDp.dpval isTelevisionDevice = rememberIsTelevisionDevice()- val sidebarWidth = if (screenWidth < 900.dp) {- (screenWidth * 0.36f).coerceIn(188.dp, 220.dp)- } else if (!isTelevisionDevice && screenWidth < 1280.dp) {- (screenWidth * 0.28f).coerceIn(220.dp, 252.dp)- } else {- 272.dp- }- val channelSearchWidth = if (screenWidth < 900.dp) {- (screenWidth * 0.34f).coerceIn(170.dp, 220.dp)- } else if (!isTelevisionDevice && screenWidth < 1280.dp) {- (screenWidth * 0.28f).coerceIn(220.dp, 280.dp)- } else if (isProMode) {- 320.dp- } else if (isDenseMode) {- 300.dp- } else {- 340.dp- }- val channelRowHeight = when (uiState.liveTvChannelMode) {- LiveTvChannelMode.COMFORTABLE -> 92.dp- LiveTvChannelMode.COMPACT -> 54.dp- LiveTvChannelMode.PRO -> 52.dp- }- val channelListSpacing = when (uiState.liveTvChannelMode) {- LiveTvChannelMode.COMFORTABLE -> 8.dp- LiveTvChannelMode.COMPACT -> 2.dp- LiveTvChannelMode.PRO -> 2.dp- }+ val layoutMetrics = liveHomeLayoutMetrics(+ screenWidthDp = LocalConfiguration.current.screenWidthDp,+ isTelevisionDevice = isTelevisionDevice,+ channelMode = uiState.liveTvChannelMode+ )+ val sidebarWidth = layoutMetrics.sidebarWidth+ val channelSearchWidth = layoutMetrics.channelSearchWidth+ val channelRowHeight = layoutMetrics.channelRowHeight+ val channelListSpacing = layoutMetrics.channelListSpacingval snackbarHostState = remember { SnackbarHostState() }// Split screen statediff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.mdindex f696da3a..d27c1a03 100644--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md@@ -138,8 +138,9 @@ 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, grid host, EPG content host, and focus reconciliation are now-feature-owned, with the options overlay and EPG-match dialog also feature-owned+rows/cells, grid host, EPG content host, focus reconciliation, and Home layout+metrics are now feature-owned, with the options overlay and EPG-match dialog+also feature-ownedwhile the Home and EPGscreen/dialog composition remains in `:app` for the remaining app-specificdialogs.@@ -153,7 +154,7 @@ series-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, grid host, EPG content host, focus-reconciliation, options overlay, and EPG-match dialog are independent of app-code;+reconciliation, Home layout metrics, 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 9efc4294..82ac5952 100644--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md@@ -28,8 +28,9 @@ 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, grid host, EPG content host, and focus reconciliation are now-feature-owned, with the options overlay and EPG-match dialog also feature-owned+rows/cells, grid host, EPG content host, focus reconciliation, and Home layout+metrics are now feature-owned, with the options overlay and EPG-match dialog+also feature-ownedand their feature checks are green. Home screen/dialog composition, theremaining live cards/rows, complete locale resource migration, and acceptancegates remain open.@@ -725,6 +726,9 @@ toolbar, refresh, and grid composition while the app supplies the localizedlabel bundles, content message, state, and action callbacks. The optionsoverlay and EPG-match dialog likewise own their presentation and focus behaviorwhile the app supplies localized labels and state/action callbacks.+Home layout metrics now preserve the existing device/mode breakpoints behind a+feature-owned pure contract while `HomeScreen` supplies the configuration and+device inputs.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/feature/live/src/main/java/com/streamvault/feature/live/presentation/home/LiveHomeLayout.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/home/LiveHomeLayout.ktnew file mode 100644index 00000000..18db5d2e--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/home/LiveHomeLayout.kt@@ -0,0 +1,54 @@+package com.streamvault.feature.live.presentation.home++import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp+import com.streamvault.domain.model.LiveTvChannelMode++data class LiveHomeLayoutMetrics(+ val sidebarWidth: Dp,+ val channelSearchWidth: Dp,+ val channelRowHeight: Dp,+ val channelListSpacing: Dp+)++fun liveHomeLayoutMetrics(+ screenWidthDp: Int,+ isTelevisionDevice: Boolean,+ channelMode: LiveTvChannelMode+): LiveHomeLayoutMetrics {+ val screenWidth = screenWidthDp.dp+ val sidebarWidth = if (screenWidth < 900.dp) {+ (screenWidth * 0.36f).coerceIn(188.dp, 220.dp)+ } else if (!isTelevisionDevice && screenWidth < 1280.dp) {+ (screenWidth * 0.28f).coerceIn(220.dp, 252.dp)+ } else {+ 272.dp+ }+ val channelSearchWidth = if (screenWidth < 900.dp) {+ (screenWidth * 0.34f).coerceIn(170.dp, 220.dp)+ } else if (!isTelevisionDevice && screenWidth < 1280.dp) {+ (screenWidth * 0.28f).coerceIn(220.dp, 280.dp)+ } else if (channelMode == LiveTvChannelMode.PRO) {+ 320.dp+ } else if (channelMode != LiveTvChannelMode.COMFORTABLE) {+ 300.dp+ } else {+ 340.dp+ }+ val channelRowHeight = when (channelMode) {+ LiveTvChannelMode.COMFORTABLE -> 92.dp+ LiveTvChannelMode.COMPACT -> 54.dp+ LiveTvChannelMode.PRO -> 52.dp+ }+ val channelListSpacing = when (channelMode) {+ LiveTvChannelMode.COMFORTABLE -> 8.dp+ LiveTvChannelMode.COMPACT -> 2.dp+ LiveTvChannelMode.PRO -> 2.dp+ }+ return LiveHomeLayoutMetrics(+ sidebarWidth = sidebarWidth,+ channelSearchWidth = channelSearchWidth,+ channelRowHeight = channelRowHeight,+ channelListSpacing = channelListSpacing+ )+}diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/home/LiveHomeLayoutTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/home/LiveHomeLayoutTest.ktnew file mode 100644index 00000000..e1bb6d6a--- /dev/null+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/home/LiveHomeLayoutTest.kt@@ -0,0 +1,50 @@+package com.streamvault.feature.live.presentation.home++import com.google.common.truth.Truth.assertThat+import com.streamvault.domain.model.LiveTvChannelMode+import androidx.compose.ui.unit.dp+import org.junit.Test++class LiveHomeLayoutTest {+ @Test+ fun `compact handset metrics respect minimum widths`() {+ val metrics = liveHomeLayoutMetrics(+ screenWidthDp = 600,+ isTelevisionDevice = false,+ channelMode = LiveTvChannelMode.COMPACT+ )++ assertThat(metrics.sidebarWidth.value).isWithin(0.01f).of(216f)+ assertThat(metrics.channelSearchWidth.value).isWithin(0.01f).of(204f)+ assertThat(metrics.channelRowHeight).isEqualTo(54.dp)+ assertThat(metrics.channelListSpacing).isEqualTo(2.dp)+ }++ @Test+ fun `non television tablet metrics use proportional widths`() {+ val metrics = liveHomeLayoutMetrics(+ screenWidthDp = 1000,+ isTelevisionDevice = false,+ channelMode = LiveTvChannelMode.COMFORTABLE+ )++ assertThat(metrics.sidebarWidth).isEqualTo(252.dp)+ assertThat(metrics.channelSearchWidth).isEqualTo(280.dp)+ assertThat(metrics.channelRowHeight).isEqualTo(92.dp)+ assertThat(metrics.channelListSpacing).isEqualTo(8.dp)+ }++ @Test+ fun `television pro metrics use the fixed desktop layout`() {+ val metrics = liveHomeLayoutMetrics(+ screenWidthDp = 1920,+ isTelevisionDevice = true,+ channelMode = LiveTvChannelMode.PRO+ )++ assertThat(metrics.sidebarWidth).isEqualTo(272.dp)+ assertThat(metrics.channelSearchWidth).isEqualTo(320.dp)+ assertThat(metrics.channelRowHeight).isEqualTo(52.dp)+ assertThat(metrics.channelListSpacing).isEqualTo(2.dp)+ }+}