From 57708b37b83a88513eec7530961fec70820cd104 Mon Sep 17 00:00:00 2001 From: Pasta Date: Thu, 3 Sep 2026 17:44:12 +0300 Subject: [PATCH 01/54] fix(tv): restore imports, UI mode selection, and channel navigation --- .../ui/screens/settings/ImportViewModel.kt | 27 +++ .../io/github/aedev/flow/ui/tv/FlowTvApp.kt | 35 +++- .../aedev/flow/ui/tv/navigation/TvNavHost.kt | 5 + .../aedev/flow/ui/tv/navigation/TvRoutes.kt | 1 + .../flow/ui/tv/player/TvPlayerOverlay.kt | 32 ++- .../flow/ui/tv/screens/TvImportDataScreen.kt | 190 ++++++++++++++++++ .../flow/ui/tv/screens/TvSettingsScreen.kt | 6 +- .../screens/settings/TvSettingsCategories.kt | 2 + .../screens/settings/TvSystemSettingsPanes.kt | 10 +- 9 files changed, 283 insertions(+), 25 deletions(-) create mode 100644 app/src/main/java/io/github/aedev/flow/ui/tv/screens/TvImportDataScreen.kt diff --git a/app/src/main/java/io/github/aedev/flow/ui/screens/settings/ImportViewModel.kt b/app/src/main/java/io/github/aedev/flow/ui/screens/settings/ImportViewModel.kt index c9392c108..9abffe429 100644 --- a/app/src/main/java/io/github/aedev/flow/ui/screens/settings/ImportViewModel.kt +++ b/app/src/main/java/io/github/aedev/flow/ui/screens/settings/ImportViewModel.kt @@ -77,6 +77,33 @@ class ImportViewModel // ── Public import launchers ─────────────────────────────────────────────── + fun importFlowBackup(uri: Uri) { + if (isRunning) return + val label = context.getString(R.string.import_flow_backup_item_title) + val successMessage = context.getString(R.string.import_flow_backup_success) + viewModelScope.launch { + startProgress(label, 0, 0) + try { + val result = backupRepo.importData(uri) + if (result.isSuccess) { + _state.value = State.Success(label, message = successMessage) + if (NotificationHelper.hasNotificationPermission(context)) { + NotificationHelper.showImportComplete(context, label, 0, successMessage) + } + } else { + val msg = result.exceptionOrNull()?.message ?: context.getString(R.string.unknown_error) + _state.value = State.Error(label, msg) + } + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + _state.value = State.Error(label, e.message ?: context.getString(R.string.unknown_error)) + } finally { + NotificationHelper.cancelImportNotification(context) + } + } + } + fun importNewPipe(uri: Uri) { if (isRunning) return val label = context.getString(R.string.import_label_newpipe_subscriptions) diff --git a/app/src/main/java/io/github/aedev/flow/ui/tv/FlowTvApp.kt b/app/src/main/java/io/github/aedev/flow/ui/tv/FlowTvApp.kt index bddee2c51..143377156 100644 --- a/app/src/main/java/io/github/aedev/flow/ui/tv/FlowTvApp.kt +++ b/app/src/main/java/io/github/aedev/flow/ui/tv/FlowTvApp.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -26,6 +27,9 @@ import io.github.aedev.flow.ui.screens.player.VideoPlayerViewModel import io.github.aedev.flow.ui.screens.search.SearchViewModel import io.github.aedev.flow.ui.screens.subscriptions.SubscriptionsViewModel import io.github.aedev.flow.ui.tv.music.TvMusicNowPlayingScreen +import io.github.aedev.flow.ui.tv.navigation.TvRoutes +import io.github.aedev.flow.ui.tv.player.LocalTvPlayerChannelAction +import io.github.aedev.flow.ui.tv.player.TvPlayerChannelAction import io.github.aedev.flow.ui.tv.screens.TvPlayerScreen import io.github.aedev.flow.ui.tv.theme.TvTheme @@ -63,6 +67,17 @@ fun FlowTvApp( playerViewModel.playVideo(video) } + fun closeVideo() { + playerViewModel.clearVideo() + GlobalPlayerState.setCurrentVideo(null) + } + + fun openVideoChannel(channelRef: String) { + if (channelRef.isBlank()) return + closeVideo() + navController.navigate(TvRoutes.channel(channelRef)) + } + fun playPlaylist( videos: List