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 lock policy
David Nashash844a1f198e45
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 8ffb45d6..12cecdfc 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@@ -5,6 +5,7 @@ import com.streamvault.domain.playback.ArchiveReplayMechanismimport com.streamvault.domain.playback.archivePlaybackCapabilityimport com.streamvault.domain.playback.isArchivePlayableimport com.streamvault.feature.live.presentation.epg.resolveLiveGuideFocus+import com.streamvault.feature.live.presentation.epg.isLiveGuideChannelLockedimport com.streamvault.feature.live.presentation.epg.LiveGuideNowProviderimport com.streamvault.feature.live.presentation.epg.currentLiveGuideNowimport com.streamvault.feature.live.presentation.epg.LiveGuideSearchOverlay@@ -981,14 +982,6 @@ private fun isGuideChannelLocked(channel: Channel,categoriesById: Map<Long, Category>,parentalControlLevel: Int-): Boolean {- if (parentalControlLevel !in 1..2) {- return false- }- val categoryLocked = channel.categoryId?.let(categoriesById::get)?.let { category ->- category.isAdult || category.isUserProtected- } ?: false- return channel.isAdult || channel.isUserProtected || categoryLocked-}+): Boolean = isLiveGuideChannelLocked(channel, categoriesById, parentalControlLevel)diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.mdindex 90127ddb..3b0802cd 100644--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md@@ -141,6 +141,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, gridrows/cells, grid host, EPG content host, focus reconciliation, Home layoutmetrics, and Home parental-lock policy are now feature-owned, with the optionsoverlay and EPG-match dialog also feature-owned+and the EPG guide-channel lock policy now feature-ownedwhile the Home and EPGscreen/dialog composition remains in `:app` for the remaining app-specificdialogs.@@ -154,7 +155,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, Home layout metrics, Home parental-lock policy, options overlay,-and EPG-match dialog are independent of app code;+reconciliation, Home layout metrics, Home parental-lock policy, EPG guide-channel+lock policy, 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 75fcdf33..b7fb1a14 100644--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md@@ -31,6 +31,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, gridrows/cells, grid host, EPG content host, focus reconciliation, Home layoutmetrics, and Home parental-lock policy are now feature-owned, with the optionsoverlay and EPG-match dialog also feature-owned+and the EPG guide-channel lock policy now feature-ownedand their feature checks are green. Home screen/dialog composition, theremaining live cards/rows, complete locale resource migration, and acceptancegates remain open.@@ -730,7 +731,10 @@ Home layout metrics now preserve the existing device/mode breakpoints behind afeature-owned pure contract while `HomeScreen` supplies the configuration anddevice inputs. Home parental-lock policy likewise preserves normalized unlockIDs and selected/source-category protection behind feature-owned pure-predicates while the app supplies current state.+predicates while the app supplies current state. EPG guide-channel lock policy+now preserves the existing parental-control level, channel protection, and+source-category protection behind a feature-owned pure predicate; `EpgScreen`+keeps its compatibility wrapper while supplying current state.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/epg/LiveGuideLockPolicy.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.ktnew file mode 100644index 00000000..c83c73fa--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.kt@@ -0,0 +1,19 @@+package com.streamvault.feature.live.presentation.epg++import com.streamvault.domain.model.Category+import com.streamvault.domain.model.Channel++fun isLiveGuideChannelLocked(+ channel: Channel,+ categoriesById: Map<Long, Category>,+ parentalControlLevel: Int+): Boolean {+ if (parentalControlLevel !in 1..2) {+ return false+ }+ val categoryLocked = channel.categoryId+ ?.let(categoriesById::get)+ ?.let { category -> category.isAdult || category.isUserProtected }+ ?: false+ return channel.isAdult || channel.isUserProtected || categoryLocked+}diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.ktnew file mode 100644index 00000000..3445fe3f--- /dev/null+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicyTest.kt@@ -0,0 +1,48 @@+package com.streamvault.feature.live.presentation.epg++import com.google.common.truth.Truth.assertThat+import com.streamvault.domain.model.Category+import com.streamvault.domain.model.Channel+import org.junit.Test++class LiveGuideLockPolicyTest {+ @Test+ fun `guide channel is locked by its own protection or source category`() {+ val protectedCategory = Category(id = 4L, name = "Protected", isAdult = true)+ val channel = Channel(id = 9L, name = "Channel", categoryId = 4L)++ assertThat(+ isLiveGuideChannelLocked(+ channel = channel,+ categoriesById = mapOf(protectedCategory.id to protectedCategory),+ parentalControlLevel = 1+ )+ ).isTrue()+ }++ @Test+ fun `guide channel is unlocked when parental controls are inactive`() {+ val protectedChannel = Channel(id = 9L, name = "Channel", isUserProtected = true)++ assertThat(+ isLiveGuideChannelLocked(+ channel = protectedChannel,+ categoriesById = emptyMap(),+ parentalControlLevel = 0+ )+ ).isFalse()+ }++ @Test+ fun `guide channel is unlocked when it has no protection`() {+ val channel = Channel(id = 9L, name = "Channel")++ assertThat(+ isLiveGuideChannelLocked(+ channel = channel,+ categoriesById = emptyMap(),+ parentalControlLevel = 2+ )+ ).isFalse()+ }+}