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 category lock policy

David Nashash62124ade0a92
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 12cecdfc..737c94a7 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
@@ -6,6 +6,7 @@ import com.streamvault.domain.playback.archivePlaybackCapability
import com.streamvault.domain.playback.isArchivePlayable
import com.streamvault.feature.live.presentation.epg.resolveLiveGuideFocus
import com.streamvault.feature.live.presentation.epg.isLiveGuideChannelLocked
+import com.streamvault.feature.live.presentation.epg.isLiveGuideCategoryLocked
import com.streamvault.feature.live.presentation.epg.LiveGuideNowProvider
import com.streamvault.feature.live.presentation.epg.currentLiveGuideNow
import com.streamvault.feature.live.presentation.epg.LiveGuideSearchOverlay
@@ -976,7 +977,7 @@ private fun GuideProviderTroubleshootingCard(
}
internal fun isGuideCategoryLocked(category: Category, parentalControlLevel: Int): Boolean =
- parentalControlLevel in 1..2 && (category.isAdult || category.isUserProtected)
+ isLiveGuideCategoryLocked(category, parentalControlLevel)
private fun isGuideChannelLocked(
channel: Channel,
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index 3b0802cd..6af80bbb 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -141,7 +141,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, grid
rows/cells, grid host, EPG content host, focus reconciliation, Home layout
metrics, and Home parental-lock policy are now feature-owned, with the options
overlay and EPG-match dialog also feature-owned
-and the EPG guide-channel lock policy now feature-owned
+and the EPG guide category/channel lock policies now feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
@@ -155,7 +155,8 @@ 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, grid host, EPG content host, focus
-reconciliation, Home layout metrics, Home parental-lock policy, EPG guide-channel
-lock policy, options overlay, and EPG-match dialog are independent of app code;
+reconciliation, Home layout metrics, Home parental-lock policy, EPG guide
+category/channel lock policies, 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 b7fb1a14..1dd6ddee 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -31,7 +31,7 @@ pane, guide toolbar, guide message state, hero badge, timeline header, grid
rows/cells, grid host, EPG content host, focus reconciliation, Home layout
metrics, and Home parental-lock policy are now feature-owned, with the options
overlay and EPG-match dialog also feature-owned
-and the EPG guide-channel lock policy now feature-owned
+and the EPG guide category/channel lock policies 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.
@@ -733,8 +733,8 @@ device inputs. Home parental-lock policy likewise preserves normalized unlock
IDs and selected/source-category protection behind feature-owned pure
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.
+source-category protection behind feature-owned pure predicates; `EpgScreen`
+keeps its compatibility wrappers while supplying current state.
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/LiveGuideLockPolicy.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideLockPolicy.kt
index c83c73fa..edbc8d53 100644
--- 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.kt
@@ -3,6 +3,9 @@ package com.streamvault.feature.live.presentation.epg
import com.streamvault.domain.model.Category
import com.streamvault.domain.model.Channel
+fun isLiveGuideCategoryLocked(category: Category, parentalControlLevel: Int): Boolean =
+ parentalControlLevel in 1..2 && (category.isAdult || category.isUserProtected)
+
fun isLiveGuideChannelLocked(
channel: Channel,
categoriesById: Map<Long, Category>,
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.kt
index 3445fe3f..9918d3df 100644
--- 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.kt
@@ -6,6 +6,14 @@ import com.streamvault.domain.model.Channel
import org.junit.Test
class LiveGuideLockPolicyTest {
+ @Test
+ fun `guide category is locked only when parental controls are active`() {
+ val protectedCategory = Category(id = 4L, name = "Protected", isAdult = true)
+
+ assertThat(isLiveGuideCategoryLocked(protectedCategory, parentalControlLevel = 1)).isTrue()
+ assertThat(isLiveGuideCategoryLocked(protectedCategory, parentalControlLevel = 0)).isFalse()
+ }
+
@Test
fun `guide channel is locked by its own protection or source category`() {
val protectedCategory = Category(id = 4L, name = "Protected", isAdult = true)