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 search policy
David Nashashccf062581a56
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.ktindex d26c2eef..ef4807e1 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/epg/EpgViewModel.kt@@ -78,6 +78,7 @@ import com.streamvault.feature.live.presentation.epg.GuideChannelModeimport com.streamvault.feature.live.presentation.epg.GuideDensityimport com.streamvault.feature.live.presentation.epg.programReminderDeliveryIssueMessageimport com.streamvault.feature.live.presentation.epg.isLiveGuideCategoryAccessible+import com.streamvault.feature.live.presentation.epg.matchesLiveGuideMetadataSearchimport javax.inject.Provider as InjectProviderdata class RecordingConflictInfo(@@ -2010,8 +2011,7 @@ class EpgViewModel @Inject constructor(}private fun Channel.matchesGuideMetadataSearch(searchQuery: String): Boolean {- return name.contains(searchQuery, ignoreCase = true) ||- categoryName?.contains(searchQuery, ignoreCase = true) == true+ return matchesLiveGuideMetadataSearch(this, searchQuery)}private fun resolveGuideCategorySelection(diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicy.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicy.ktnew file mode 100644index 00000000..7ea3c979--- /dev/null+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicy.kt@@ -0,0 +1,7 @@+package com.streamvault.feature.live.presentation.epg++import com.streamvault.domain.model.Channel++fun matchesLiveGuideMetadataSearch(channel: Channel, searchQuery: String): Boolean =+ channel.name.contains(searchQuery, ignoreCase = true) ||+ channel.categoryName?.contains(searchQuery, ignoreCase = true) == truediff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicyTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicyTest.ktnew file mode 100644index 00000000..5a54514c--- /dev/null+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/epg/LiveGuideSearchPolicyTest.kt@@ -0,0 +1,23 @@+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 LiveGuideSearchPolicyTest {+ @Test+ fun `guide metadata search matches channel name or category case insensitively`() {+ val channel = Channel(id = 9L, name = "News One", categoryName = "World")++ assertThat(matchesLiveGuideMetadataSearch(channel, "news")).isTrue()+ assertThat(matchesLiveGuideMetadataSearch(channel, "WORLD")).isTrue()+ assertThat(matchesLiveGuideMetadataSearch(channel, "sports")).isFalse()+ }++ @Test+ fun `blank guide metadata search matches every channel`() {+ val channel = Channel(id = 9L, name = "News One")++ assertThat(matchesLiveGuideMetadataSearch(channel, "")).isTrue()+ }+}