refactor(player): move back key handling to BackHandler in TvPlayerScreen

Consolidate Back and Escape key handling in the existing BackHandler
composable and remove the redundant branch from
handleTvPlayerRootKeyEvent. The BackHandler already implements the same
panel/playlist/controls dismissal chain and adds the missing onBack()
fallback for system navigation. Drop the now-unused parameters
(isPlaylistExpanded, trackPanelType, onCloseTrackPanel,
onCollapsePlaylist, onHideControls) from both the function and its
call site.
This commit is contained in:
2026-06-30 20:15:26 +00:00
parent cd3fa8ace1
commit 7f68b9d32b

View File

@@ -254,11 +254,6 @@ fun TvPlayerScreen(
controlsVisible = controlsVisible,
popupVisible = showSkipIntroButton || showNextEpisodeOverlay,
onShowControls = ::showControls,
isPlaylistExpanded = isPlaylistExpanded,
trackPanelType = trackPanelType,
onCloseTrackPanel = closeTrackPanel,
onCollapsePlaylist = {},
onHideControls = ::hideControls,
onTogglePlayback = {
// This is a hack to trigger the ValueChangeTimedVisibility to show the hidden resume/stop feedback.
resumeStopFeedbackCounter++
@@ -504,38 +499,12 @@ internal fun handleTvPlayerRootKeyEvent(
event: KeyEvent,
controlsVisible: Boolean,
popupVisible: Boolean,
isPlaylistExpanded: Boolean,
trackPanelType: TvTrackPanelType?,
onCloseTrackPanel: () -> Unit,
onCollapsePlaylist: () -> Unit,
onHideControls: () -> Unit,
onTogglePlayback: () -> Unit,
onSeekRelative: (Long) -> Unit,
onShowControls: () -> Unit,
): Boolean {
if (event.type != KeyEventType.KeyDown) return false
if (event.key == Key.Back || event.key == Key.Escape) {
return when {
trackPanelType != null -> {
onCloseTrackPanel()
true
}
isPlaylistExpanded -> {
onCollapsePlaylist()
true
}
controlsVisible -> {
onHideControls()
true
}
else -> false
}
}
if (!controlsVisible) {
return when (event.key) {
Key.DirectionLeft -> {