From e4b99354f6dedd895b1b9a71218c3ebe324aa319 Mon Sep 17 00:00:00 2001 From: Barnabas Balogh Date: Fri, 27 Feb 2026 17:42:05 +0100 Subject: [PATCH] feat: Back gesture should hide controls in tv module --- .../java/hu/bbara/purefin/tv/player/TvPlayerScreen.kt | 11 ++++++++--- .../purefin/core/player/viewmodel/PlayerViewModel.kt | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app-tv/src/main/java/hu/bbara/purefin/tv/player/TvPlayerScreen.kt b/app-tv/src/main/java/hu/bbara/purefin/tv/player/TvPlayerScreen.kt index ef9d615..5e4a6e5 100644 --- a/app-tv/src/main/java/hu/bbara/purefin/tv/player/TvPlayerScreen.kt +++ b/app-tv/src/main/java/hu/bbara/purefin/tv/player/TvPlayerScreen.kt @@ -2,14 +2,16 @@ package hu.bbara.purefin.tv.player import android.app.Activity import android.view.WindowManager +import androidx.activity.compose.BackHandler import androidx.annotation.OptIn import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideOutHorizontally -import androidx.compose.animation.animateColorAsState -import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable @@ -29,7 +31,6 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.Canvas import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll @@ -119,6 +120,10 @@ fun TvPlayerScreen( } } + BackHandler(enabled = controlsVisible) { + viewModel.hideControls() + } + LaunchedEffect(uiState.isPlaying) { if (uiState.isPlaying) showQueuePanel = false } diff --git a/core/player/src/main/java/hu/bbara/purefin/core/player/viewmodel/PlayerViewModel.kt b/core/player/src/main/java/hu/bbara/purefin/core/player/viewmodel/PlayerViewModel.kt index 4e3cf25..742cb60 100644 --- a/core/player/src/main/java/hu/bbara/purefin/core/player/viewmodel/PlayerViewModel.kt +++ b/core/player/src/main/java/hu/bbara/purefin/core/player/viewmodel/PlayerViewModel.kt @@ -203,6 +203,11 @@ class PlayerViewModel @Inject constructor( if (_controlsVisible.value) scheduleAutoHide() } + fun hideControls() { + _controlsVisible.value = false + autoHideJob?.cancel() + } + private fun scheduleAutoHide() { autoHideJob?.cancel() if (!player.isPlaying) return