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): own browse remote dispatch

David Nashashe2422a6b4db8
diff --git a/app/src/main/java/com/streamvault/app/ui/remote/RemoteShortcutDispatch.kt b/app/src/main/java/com/streamvault/app/ui/remote/RemoteShortcutDispatch.kt
index d5abbffc..3980d708 100644
--- a/app/src/main/java/com/streamvault/app/ui/remote/RemoteShortcutDispatch.kt
+++ b/app/src/main/java/com/streamvault/app/ui/remote/RemoteShortcutDispatch.kt
@@ -1,7 +1,5 @@
package com.streamvault.app.ui.remote
-import android.view.KeyEvent
-import com.streamvault.domain.model.RemoteColorButton
import com.streamvault.domain.model.RemoteShortcutAction
data class PlayerRemoteShortcutHandler(
@@ -18,32 +16,6 @@ data class PlayerRemoteShortcutHandler(
val onAddToSplitScreen: () -> Unit
)
-sealed interface LiveBrowseRemoteShortcutHandler {
- val onOpenGuide: (() -> Unit)?
-
- data class Channel(
- val onToggleFavorite: () -> Unit,
- val onPlayChannel: () -> Unit,
- val onAddToSplitScreen: () -> Unit,
- override val onOpenGuide: (() -> Unit)? = null
- ) : LiveBrowseRemoteShortcutHandler
-
- data class Category(
- val onPinCategory: () -> Unit,
- val onToggleCategoryLock: () -> Unit,
- val onHideCategory: () -> Unit,
- override val onOpenGuide: (() -> Unit)? = null
- ) : LiveBrowseRemoteShortcutHandler
-}
-
-fun remoteColorButtonForKeyCode(keyCode: Int): RemoteColorButton? = when (keyCode) {
- KeyEvent.KEYCODE_PROG_RED -> RemoteColorButton.RED
- KeyEvent.KEYCODE_PROG_GREEN -> RemoteColorButton.GREEN
- KeyEvent.KEYCODE_PROG_YELLOW -> RemoteColorButton.YELLOW
- KeyEvent.KEYCODE_PROG_BLUE -> RemoteColorButton.BLUE
- else -> null
-}
-
fun dispatchPlayerRemoteShortcut(
action: RemoteShortcutAction,
handler: PlayerRemoteShortcutHandler
@@ -65,32 +37,6 @@ fun dispatchPlayerRemoteShortcut(
return true
}
-fun dispatchLiveBrowseRemoteShortcut(
- action: RemoteShortcutAction,
- handler: LiveBrowseRemoteShortcutHandler
-): Boolean {
- if (!action.isSupportedInBrowse(handler)) return false
- when (handler) {
- is LiveBrowseRemoteShortcutHandler.Channel -> when (action) {
- RemoteShortcutAction.NONE -> return true
- RemoteShortcutAction.OPEN_GUIDE -> handler.onOpenGuide?.invoke() ?: return false
- RemoteShortcutAction.TOGGLE_FAVORITE -> handler.onToggleFavorite()
- RemoteShortcutAction.PLAY_CHANNEL -> handler.onPlayChannel()
- RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> handler.onAddToSplitScreen()
- else -> return false
- }
- is LiveBrowseRemoteShortcutHandler.Category -> when (action) {
- RemoteShortcutAction.NONE -> return true
- RemoteShortcutAction.OPEN_GUIDE -> handler.onOpenGuide?.invoke() ?: return false
- RemoteShortcutAction.PIN_CATEGORY -> handler.onPinCategory()
- RemoteShortcutAction.TOGGLE_CATEGORY_LOCK -> handler.onToggleCategoryLock()
- RemoteShortcutAction.HIDE_CATEGORY -> handler.onHideCategory()
- else -> return false
- }
- }
- return true
-}
-
fun RemoteShortcutAction.isSupportedInPlayback(
isLiveContent: Boolean,
isCatchUpPlayback: Boolean
@@ -107,22 +53,3 @@ fun RemoteShortcutAction.isSupportedInPlayback(
RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> isLiveContent && !isCatchUpPlayback
else -> false
}
-
-fun RemoteShortcutAction.isSupportedInBrowse(handler: LiveBrowseRemoteShortcutHandler): Boolean = when (handler) {
- is LiveBrowseRemoteShortcutHandler.Channel -> when (this) {
- RemoteShortcutAction.NONE,
- RemoteShortcutAction.OPEN_GUIDE,
- RemoteShortcutAction.TOGGLE_FAVORITE,
- RemoteShortcutAction.PLAY_CHANNEL,
- RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> true
- else -> false
- }
- is LiveBrowseRemoteShortcutHandler.Category -> when (this) {
- RemoteShortcutAction.NONE,
- RemoteShortcutAction.OPEN_GUIDE,
- RemoteShortcutAction.PIN_CATEGORY,
- RemoteShortcutAction.TOGGLE_CATEGORY_LOCK,
- RemoteShortcutAction.HIDE_CATEGORY -> true
- else -> false
- }
-}
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.kt
index ae5db4da..d21c5174 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
@@ -78,10 +78,10 @@ import com.streamvault.app.navigation.Routes
import com.streamvault.domain.model.VirtualCategoryIds
import com.streamvault.domain.playback.archivePlaybackCapability
import com.streamvault.domain.repository.ChannelRepository
-import com.streamvault.app.ui.remote.LiveBrowseRemoteShortcutHandler
-import com.streamvault.app.ui.remote.dispatchLiveBrowseRemoteShortcut
-import com.streamvault.app.ui.remote.remoteColorButtonForKeyCode
import com.streamvault.domain.model.RemoteShortcutProfile
+import com.streamvault.feature.live.presentation.remote.LiveBrowseRemoteShortcutHandler
+import com.streamvault.feature.live.presentation.remote.dispatchLiveBrowseRemoteShortcut
+import com.streamvault.feature.live.presentation.remote.remoteColorButtonForKeyCode
private enum class FocusRestoreTarget {
CATEGORY,
diff --git a/app/src/test/java/com/streamvault/app/ui/remote/RemoteShortcutDispatchTest.kt b/app/src/test/java/com/streamvault/app/ui/remote/RemoteShortcutDispatchTest.kt
index d11e03f4..eb6fc83a 100644
--- a/app/src/test/java/com/streamvault/app/ui/remote/RemoteShortcutDispatchTest.kt
+++ b/app/src/test/java/com/streamvault/app/ui/remote/RemoteShortcutDispatchTest.kt
@@ -2,6 +2,8 @@ package com.streamvault.app.ui.remote
import com.google.common.truth.Truth.assertThat
import com.streamvault.domain.model.RemoteShortcutAction
+import com.streamvault.feature.live.presentation.remote.LiveBrowseRemoteShortcutHandler
+import com.streamvault.feature.live.presentation.remote.dispatchLiveBrowseRemoteShortcut
import org.junit.Test
class RemoteShortcutDispatchTest {
diff --git a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
index a3e7ef89..fcc53928 100644
--- a/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
+++ b/docs/COMPOSE_REDUCTION_PHASE5_TRANSITIONAL_DEPENDENCIES.md
@@ -146,6 +146,13 @@ policy, and schedule metrics now feature-owned
while the Home and EPG
screen/dialog composition remains in `:app` for the remaining app-specific
dialogs.
+
+The Live-browse remote shortcut dispatcher is no longer app-owned: its handler
+types, Android colour-key mapping, and action dispatch live in
+`feature/live/.../presentation/remote/LiveRemoteShortcutDispatch.kt`. The app
+retains only player-wide shortcut dispatch and adapts Home callbacks to the
+feature handler API. This is a presentation move, not a new transitional
+implementation dependency.
The source switcher receives localized labels from the app at the current
composition boundary. Live-owned
presentation primitives, `HomeUiState`, `HomePreviewUiState`, Guide
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 e6999e08..23ae4877 100644
--- a/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
+++ b/docs/superpowers/plans/2026-08-28-live-feature-extraction.md
@@ -37,6 +37,11 @@ and their feature checks are green. Home screen/dialog composition, the
remaining live cards/rows, complete locale resource migration, and acceptance
gates remain open.
+The Live-browse portion of remote shortcut dispatch is now feature-owned in
+`presentation/remote/LiveRemoteShortcutDispatch.kt`; the app retains only
+player-wide shortcut dispatch and imports the Live handler API at the Home
+composition boundary. Focused feature and app dispatch tests are green.
+
Route patterns were subsequently moved behind `LiveRoutePatterns`; the app
codec still owns encode/decode compatibility and no route behavior changed.
The feature-owned `registerLiveGraph` now owns Live destination argument
@@ -539,6 +544,13 @@ Expected: FAIL because live-owned implementations do not exist.
Move `GuideLookupKey.kt` and the Live browse portion of `RemoteShortcutDispatch.kt` mechanically into the feature packages. Leave non-live remote helpers in `:app`. Preserve every key code and action result.
+The Live browse handler types, colour-key mapping, and dispatch function now
+live in `feature/live/.../presentation/remote/LiveRemoteShortcutDispatch.kt`.
+The app dispatcher retains player-only behavior and its existing tests import
+the feature API. `LiveRemoteShortcutDispatchTest` covers key mapping, channel
+dispatch, and category action rejection; both that suite and the existing app
+remote suite pass.
+
- [ ] **Step 3: Add failing connected/golden coverage for shared visuals**
Render representative selected/unselected selection chips, locked/unlocked category rows, channel card progress, source switcher, reorder bar, and category dialog. Use the repository golden helper that fails when the checked-in baseline is absent.
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatch.kt b/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatch.kt
new file mode 100644
index 00000000..346f31c9
--- /dev/null
+++ b/feature/live/src/main/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatch.kt
@@ -0,0 +1,83 @@
+package com.streamvault.feature.live.presentation.remote
+
+import android.view.KeyEvent
+import com.streamvault.domain.model.RemoteColorButton
+import com.streamvault.domain.model.RemoteShortcutAction
+
+/** Callbacks exposed by the focused Live browse item to the feature-owned dispatcher. */
+sealed interface LiveBrowseRemoteShortcutHandler {
+ val onOpenGuide: (() -> Unit)?
+
+ data class Channel(
+ val onToggleFavorite: () -> Unit,
+ val onPlayChannel: () -> Unit,
+ val onAddToSplitScreen: () -> Unit,
+ override val onOpenGuide: (() -> Unit)? = null,
+ ) : LiveBrowseRemoteShortcutHandler
+
+ data class Category(
+ val onPinCategory: () -> Unit,
+ val onToggleCategoryLock: () -> Unit,
+ val onHideCategory: () -> Unit,
+ override val onOpenGuide: (() -> Unit)? = null,
+ ) : LiveBrowseRemoteShortcutHandler
+}
+
+/** Maps Android TV colour-program keys to the domain-level Live shortcut buttons. */
+fun remoteColorButtonForKeyCode(keyCode: Int): RemoteColorButton? = when (keyCode) {
+ KeyEvent.KEYCODE_PROG_RED -> RemoteColorButton.RED
+ KeyEvent.KEYCODE_PROG_GREEN -> RemoteColorButton.GREEN
+ KeyEvent.KEYCODE_PROG_YELLOW -> RemoteColorButton.YELLOW
+ KeyEvent.KEYCODE_PROG_BLUE -> RemoteColorButton.BLUE
+ else -> null
+}
+
+/** Dispatches a configured action to the currently focused Live browse item. */
+fun dispatchLiveBrowseRemoteShortcut(
+ action: RemoteShortcutAction,
+ handler: LiveBrowseRemoteShortcutHandler,
+): Boolean {
+ if (!action.isSupportedInBrowse(handler)) return false
+ when (handler) {
+ is LiveBrowseRemoteShortcutHandler.Channel -> when (action) {
+ RemoteShortcutAction.NONE -> return true
+ RemoteShortcutAction.OPEN_GUIDE -> handler.onOpenGuide?.invoke() ?: return false
+ RemoteShortcutAction.TOGGLE_FAVORITE -> handler.onToggleFavorite()
+ RemoteShortcutAction.PLAY_CHANNEL -> handler.onPlayChannel()
+ RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> handler.onAddToSplitScreen()
+ else -> return false
+ }
+
+ is LiveBrowseRemoteShortcutHandler.Category -> when (action) {
+ RemoteShortcutAction.NONE -> return true
+ RemoteShortcutAction.OPEN_GUIDE -> handler.onOpenGuide?.invoke() ?: return false
+ RemoteShortcutAction.PIN_CATEGORY -> handler.onPinCategory()
+ RemoteShortcutAction.TOGGLE_CATEGORY_LOCK -> handler.onToggleCategoryLock()
+ RemoteShortcutAction.HIDE_CATEGORY -> handler.onHideCategory()
+ else -> return false
+ }
+ }
+ return true
+}
+
+private fun RemoteShortcutAction.isSupportedInBrowse(
+ handler: LiveBrowseRemoteShortcutHandler,
+): Boolean = when (handler) {
+ is LiveBrowseRemoteShortcutHandler.Channel -> when (this) {
+ RemoteShortcutAction.NONE,
+ RemoteShortcutAction.OPEN_GUIDE,
+ RemoteShortcutAction.TOGGLE_FAVORITE,
+ RemoteShortcutAction.PLAY_CHANNEL,
+ RemoteShortcutAction.ADD_TO_SPLIT_SCREEN -> true
+ else -> false
+ }
+
+ is LiveBrowseRemoteShortcutHandler.Category -> when (this) {
+ RemoteShortcutAction.NONE,
+ RemoteShortcutAction.OPEN_GUIDE,
+ RemoteShortcutAction.PIN_CATEGORY,
+ RemoteShortcutAction.TOGGLE_CATEGORY_LOCK,
+ RemoteShortcutAction.HIDE_CATEGORY -> true
+ else -> false
+ }
+}
diff --git a/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatchTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatchTest.kt
new file mode 100644
index 00000000..e202754d
--- /dev/null
+++ b/feature/live/src/test/java/com/streamvault/feature/live/presentation/remote/LiveRemoteShortcutDispatchTest.kt
@@ -0,0 +1,57 @@
+package com.streamvault.feature.live.presentation.remote
+
+import android.view.KeyEvent
+import com.google.common.truth.Truth.assertThat
+import com.streamvault.domain.model.RemoteColorButton
+import com.streamvault.domain.model.RemoteShortcutAction
+import org.junit.Test
+
+class LiveRemoteShortcutDispatchTest {
+
+ @Test
+ fun colorKeyMappingUsesLiveRemoteButtons() {
+ assertThat(remoteColorButtonForKeyCode(KeyEvent.KEYCODE_PROG_RED))
+ .isEqualTo(RemoteColorButton.RED)
+ assertThat(remoteColorButtonForKeyCode(KeyEvent.KEYCODE_PROG_GREEN))
+ .isEqualTo(RemoteColorButton.GREEN)
+ assertThat(remoteColorButtonForKeyCode(KeyEvent.KEYCODE_PROG_YELLOW))
+ .isEqualTo(RemoteColorButton.YELLOW)
+ assertThat(remoteColorButtonForKeyCode(KeyEvent.KEYCODE_PROG_BLUE))
+ .isEqualTo(RemoteColorButton.BLUE)
+ assertThat(remoteColorButtonForKeyCode(KeyEvent.KEYCODE_ENTER)).isNull()
+ }
+
+ @Test
+ fun browseChannelDispatchRunsExpectedHandler() {
+ var favoriteToggled = false
+
+ val handled = dispatchLiveBrowseRemoteShortcut(
+ action = RemoteShortcutAction.TOGGLE_FAVORITE,
+ handler = LiveBrowseRemoteShortcutHandler.Channel(
+ onToggleFavorite = { favoriteToggled = true },
+ onPlayChannel = {},
+ onAddToSplitScreen = {},
+ ),
+ )
+
+ assertThat(handled).isTrue()
+ assertThat(favoriteToggled).isTrue()
+ }
+
+ @Test
+ fun browseCategoryDispatchRejectsChannelOnlyAction() {
+ var hidden = false
+
+ val handled = dispatchLiveBrowseRemoteShortcut(
+ action = RemoteShortcutAction.ADD_TO_SPLIT_SCREEN,
+ handler = LiveBrowseRemoteShortcutHandler.Category(
+ onPinCategory = {},
+ onToggleCategoryLock = {},
+ onHideCategory = { hidden = true },
+ ),
+ )
+
+ assertThat(handled).isFalse()
+ assertThat(hidden).isFalse()
+ }
+}