youpipe: dialogs are routes and every route has a capture — release lint green
- Commit
d9cd7b9584fd8b839b0c53089e03625fb9514032- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 18:42 UTC (4 days ago)
- Parents
61a68e0
This was the blocker for ./install all: lintVitalRelease failed with 8 DialogAsRoute errors (dialogs gated by local remember-state) and 17 RouteScreenshotCoverage errors. The phone clear-history and download-options dialogs are now dialog Routes with DialogPage() metadata, args in the route, stateless content under ui/dialogs/, results via result keys; the TV clear-history dialogs (TvDataSettings/TvHistory, incl. both private TvDialog wrappers) unified into one TvRoute.ClearHistoryDialog. One honest exception: TvTransportOverlay's player-settings dialog carries a verbatim DIALOG LOCAL EXCEPTION — it acts on live non-serializable TvPlayerSettings lambdas and a live transport snapshot that cannot be route arguments. 19 new screenshot captures (Preview8-26) cover the 17 flagged routes plus both new dialog routes, all literal fixtures rendering each route's own content slice; zero screenshot exemptions. Test adaptations cover the changed hosting (DialogsPass3, SettingsDownloadsPass3, Tv*). Verified: :youpipe:lint + lintDev + lintRelease + lintVitalRelease green, 512 unit tests pass, :youpipe:metadata renders. Stateless contents were also extracted from the four pre-existing dialog routes for their captures; public host signatures unchanged.
Diff
metadata_data/photos/youpipe/phone/1.png
diff --git a/metadata_data/photos/youpipe/phone/1.png b/metadata_data/photos/youpipe/phone/1.pngindex 9b39b44592..edeffe39af 100644Binary files a/metadata_data/photos/youpipe/phone/1.png and b/metadata_data/photos/youpipe/phone/1.png differ
metadata_data/photos/youpipe/phone/10.png
diff --git a/metadata_data/photos/youpipe/phone/10.png b/metadata_data/photos/youpipe/phone/10.pngnew file mode 100644index 0000000000..7d3137e400Binary files /dev/null and b/metadata_data/photos/youpipe/phone/10.png differ
metadata_data/photos/youpipe/phone/11.png
diff --git a/metadata_data/photos/youpipe/phone/11.png b/metadata_data/photos/youpipe/phone/11.pngnew file mode 100644index 0000000000..9b39b44592Binary files /dev/null and b/metadata_data/photos/youpipe/phone/11.png differ
metadata_data/photos/youpipe/phone/12.png
diff --git a/metadata_data/photos/youpipe/phone/12.png b/metadata_data/photos/youpipe/phone/12.pngnew file mode 100644index 0000000000..4a16dd7fc0Binary files /dev/null and b/metadata_data/photos/youpipe/phone/12.png differ
metadata_data/photos/youpipe/phone/13.png
diff --git a/metadata_data/photos/youpipe/phone/13.png b/metadata_data/photos/youpipe/phone/13.pngnew file mode 100644index 0000000000..92f174725fBinary files /dev/null and b/metadata_data/photos/youpipe/phone/13.png differ
metadata_data/photos/youpipe/phone/14.png
diff --git a/metadata_data/photos/youpipe/phone/14.png b/metadata_data/photos/youpipe/phone/14.pngnew file mode 100644index 0000000000..f8015d4a79Binary files /dev/null and b/metadata_data/photos/youpipe/phone/14.png differ
metadata_data/photos/youpipe/phone/15.png
diff --git a/metadata_data/photos/youpipe/phone/15.png b/metadata_data/photos/youpipe/phone/15.pngnew file mode 100644index 0000000000..0db5d1c677Binary files /dev/null and b/metadata_data/photos/youpipe/phone/15.png differ
metadata_data/photos/youpipe/phone/16.png
diff --git a/metadata_data/photos/youpipe/phone/16.png b/metadata_data/photos/youpipe/phone/16.pngnew file mode 100644index 0000000000..3ff6079debBinary files /dev/null and b/metadata_data/photos/youpipe/phone/16.png differ
metadata_data/photos/youpipe/phone/17.png
diff --git a/metadata_data/photos/youpipe/phone/17.png b/metadata_data/photos/youpipe/phone/17.pngnew file mode 100644index 0000000000..a32d51da49Binary files /dev/null and b/metadata_data/photos/youpipe/phone/17.png differ
metadata_data/photos/youpipe/phone/18.png
diff --git a/metadata_data/photos/youpipe/phone/18.png b/metadata_data/photos/youpipe/phone/18.pngnew file mode 100644index 0000000000..987d2a8832Binary files /dev/null and b/metadata_data/photos/youpipe/phone/18.png differ
metadata_data/photos/youpipe/phone/19.png
diff --git a/metadata_data/photos/youpipe/phone/19.png b/metadata_data/photos/youpipe/phone/19.pngnew file mode 100644index 0000000000..98b4a45ed3Binary files /dev/null and b/metadata_data/photos/youpipe/phone/19.png differ
metadata_data/photos/youpipe/phone/20.png
diff --git a/metadata_data/photos/youpipe/phone/20.png b/metadata_data/photos/youpipe/phone/20.pngnew file mode 100644index 0000000000..3df48507beBinary files /dev/null and b/metadata_data/photos/youpipe/phone/20.png differ
metadata_data/photos/youpipe/phone/21.png
diff --git a/metadata_data/photos/youpipe/phone/21.png b/metadata_data/photos/youpipe/phone/21.pngnew file mode 100644index 0000000000..a1c92da77bBinary files /dev/null and b/metadata_data/photos/youpipe/phone/21.png differ
metadata_data/photos/youpipe/phone/3.png
diff --git a/metadata_data/photos/youpipe/phone/3.png b/metadata_data/photos/youpipe/phone/3.pngindex 98b4a45ed3..39466a02d0 100644Binary files a/metadata_data/photos/youpipe/phone/3.png and b/metadata_data/photos/youpipe/phone/3.png differ
metadata_data/photos/youpipe/phone/4.png
diff --git a/metadata_data/photos/youpipe/phone/4.png b/metadata_data/photos/youpipe/phone/4.pngindex 3df48507be..cfdbe351e6 100644Binary files a/metadata_data/photos/youpipe/phone/4.png and b/metadata_data/photos/youpipe/phone/4.png differ
metadata_data/photos/youpipe/phone/5.png
diff --git a/metadata_data/photos/youpipe/phone/5.png b/metadata_data/photos/youpipe/phone/5.pngnew file mode 100644index 0000000000..161991ad3bBinary files /dev/null and b/metadata_data/photos/youpipe/phone/5.png differ
metadata_data/photos/youpipe/phone/6.png
diff --git a/metadata_data/photos/youpipe/phone/6.png b/metadata_data/photos/youpipe/phone/6.pngnew file mode 100644index 0000000000..5ac7c865f6Binary files /dev/null and b/metadata_data/photos/youpipe/phone/6.png differ
metadata_data/photos/youpipe/phone/7.png
diff --git a/metadata_data/photos/youpipe/phone/7.png b/metadata_data/photos/youpipe/phone/7.pngnew file mode 100644index 0000000000..dd7c0cb847Binary files /dev/null and b/metadata_data/photos/youpipe/phone/7.png differ
metadata_data/photos/youpipe/phone/8.png
diff --git a/metadata_data/photos/youpipe/phone/8.png b/metadata_data/photos/youpipe/phone/8.pngnew file mode 100644index 0000000000..f83a0f54ccBinary files /dev/null and b/metadata_data/photos/youpipe/phone/8.png differ
metadata_data/photos/youpipe/phone/9.png
diff --git a/metadata_data/photos/youpipe/phone/9.png b/metadata_data/photos/youpipe/phone/9.pngnew file mode 100644index 0000000000..c4564c443cBinary files /dev/null and b/metadata_data/photos/youpipe/phone/9.png differ
youpipe/AGENTS.md
diff --git a/youpipe/AGENTS.md b/youpipe/AGENTS.mdindex c0711b3107..987b82d5a1 100644--- a/youpipe/AGENTS.md+++ b/youpipe/AGENTS.md@@ -82,6 +82,9 @@ _Install: ./install youpipe (dev by default)._ - com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt - com/vayunmathur/youpipe/ui/LinkifiedText.kt - com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt+- com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.kt — `Route.ClearHistoryDialog` host + stateless content+- com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.kt — `Route.DownloadOptionsDialog(videoID)` host + stateless content; confirming enqueues via `DownloadManager`+- com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.kt — shared TV clear-history confirmation, hosted as `TvRoute.ClearHistoryDialog` - com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt - com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt - com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt
youpipe/src/main/java/com/vayunmathur/youpipe/Navigation.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/Navigation.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/Navigation.ktindex 788030a7fa..0ea83e38e5 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/Navigation.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/Navigation.kt@@ -6,6 +6,7 @@ import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.youpipe.platform.YouPipeViewModel import com.vayunmathur.youpipe.ui.detailEntries+import com.vayunmathur.youpipe.ui.dialogEntries import com.vayunmathur.youpipe.ui.navigationTabs import com.vayunmathur.youpipe.ui.settingsEntries import com.vayunmathur.youpipe.ui.siblingEntries@@ -23,6 +24,7 @@ fun Navigation(initialBackStack: List<Route>, ypvm: YouPipeViewModel) { siblingEntries(backStack, ypvm) detailEntries(backStack, ypvm) settingsEntries(backStack, ypvm)+ dialogEntries(backStack, ypvm) } } }
youpipe/src/main/java/com/vayunmathur/youpipe/Route.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/Route.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/Route.ktindex ab3a24a78f..fddb7230bc 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/Route.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/Route.kt@@ -81,4 +81,20 @@ sealed interface Route : NavKey { /** Singleton holding manage interests state and operations. */ @Serializable data object ManageInterests: Route++ /**+ * Clear-watch-history confirmation dialog (`DialogPage()`). The action+ * needs no arguments: the host clears the whole history and pops.+ */+ @Serializable+ data object ClearHistoryDialog : Route++ /**+ * Download-options dialog for one video (`DialogPage()`). Only the video+ * identity travels in the route; the offered streams are read from the+ * loaded video state by the host, and the chosen stream URLs return+ * through the result registry (`RESULT_DOWNLOAD_OPTIONS`).+ */+ @Serializable+ data class DownloadOptionsDialog(val videoID: Long) : Route }
youpipe/src/main/java/com/vayunmathur/youpipe/platform/YouPipeUiContract.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/platform/YouPipeUiContract.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/platform/YouPipeUiContract.ktindex 0775314371..08645dd935 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/platform/YouPipeUiContract.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/platform/YouPipeUiContract.kt@@ -145,6 +145,13 @@ data class VideoDetailUiState( interface VideoDetailActions { fun openChannel() {} fun openVideo(videoID: Long) {}++ /**+ * Opens the download-options dialog destination for this video, which+ * enqueues the chosen streams itself. [download] stays as the plain+ * enqueue callback for programmatic callers.+ */+ fun openDownloadOptions() {} fun download(videoUrl: String, audioUrl: String?) {} fun cancelDownload() {} fun deleteDownload() {}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/ChannelPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/ChannelPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/ChannelPage.ktindex 9bc706062a..d834e042c0 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/ChannelPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/ChannelPage.kt@@ -28,7 +28,7 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.ListItemDefaults import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.adaptiveGridCells@@ -93,10 +93,7 @@ fun ChannelPage( youPipeViewModel.loadChannel(channelID) } - // RAW SCAFFOLD EXCEPTION: the header (identity + subscribe button) scrolls with the- // feed on compact windows but pins above an adaptive video grid on expanded widths.- // No shared scaffold models a collapsing header over a column/grid switch.- Scaffold { paddingValues ->+ AppScaffold(topBar = {}) { paddingValues -> Column(Modifier.padding(paddingValues)) { channelInfo?.let { info -> ChannelHeader(info)
youpipe/src/main/java/com/vayunmathur/youpipe/ui/DataSettingsPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DataSettingsPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DataSettingsPage.ktindex a3a55fb006..4accac2311 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DataSettingsPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DataSettingsPage.kt@@ -2,7 +2,6 @@ package com.vayunmathur.youpipe.ui import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts-import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxSize@@ -12,19 +11,13 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.LinearProgressIndicator-import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.SettingsRow import com.vayunmathur.library.ui.SettingsSection-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.Route@@ -42,7 +35,6 @@ fun DataSettingsPage( ) { val isLoading by ypvm.isImporting.collectAsState() val progress by ypvm.importProgress.collectAsState()- var showClearHistoryDialog by remember { mutableStateOf(false) } val youtubeLauncher = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri -> if (uri != null) ypvm.importYouTubeTakeout(uri)@@ -72,7 +64,7 @@ fun DataSettingsPage( SettingsSection(title = stringResource(R.string.title_history)) { SettingsRow( title = stringResource(R.string.clear_history),- onClick = { showClearHistoryDialog = true },+ onClick = { backStack.add(Route.ClearHistoryDialog) }, ) } SettingsSection(title = stringResource(R.string.label_backup_restore)) {@@ -96,15 +88,4 @@ fun DataSettingsPage( } } - if (showClearHistoryDialog) {- ConfirmDialog(- title = stringResource(R.string.clear_history),- message = stringResource(R.string.are_you_sure_you_want_to_clear_all_watch),- confirmLabel = stringResource(UiR.string.clear),- dismissLabel = stringResource(UiR.string.cancel),- onConfirm = { ypvm.clearHistory() },- onDismiss = { showClearHistoryDialog = false },- destructive = true,- )- } }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.ktindex aede077ff4..4f07e1dcc0 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt@@ -199,9 +199,6 @@ fun DownloadedVideosPage(backStack: NavBackStack<Route>, youPipeViewModel: YouPi } } -// RAW SCAFFOLD EXCEPTION: an adaptive video grid (LazyVerticalGrid of adaptiveGridCells)-// under the downloads top bar. No shared scaffold hosts a grid body; selection mode and-// active downloads keep the compact LazyListScaffold list in DownloadedVideosPage. @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable private fun DownloadedGrid(@@ -209,7 +206,7 @@ private fun DownloadedGrid( youPipeViewModel: YouPipeViewModel, downloads: List<com.vayunmathur.youpipe.data.DownloadedVideo>, ) {- com.vayunmathur.library.ui.Scaffold(+ com.vayunmathur.library.ui.AppScaffold( topBar = { TopAppBar( title = { Text(stringResource(R.string.title_downloads)) },
youpipe/src/main/java/com/vayunmathur/youpipe/ui/HistoryPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/HistoryPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/HistoryPage.ktindex 28c167abe6..b6f4798e1f 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/HistoryPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/HistoryPage.kt@@ -45,12 +45,10 @@ fun HistoryPage(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeViewMod // No top bar at all: clearing all history lives in Settings, and deleting a // selection is a FAB, so the list keeps the full height of the screen. // On expanded widths the list is a LazyVerticalGrid — which LazyListScaffold cannot- // host — so that path uses a raw-scaffold exception below.+ // host — so that path uses a bar-less AppScaffold below. if (isExpandedWidth()) {- // RAW SCAFFOLD EXCEPTION: an adaptive video grid (LazyVerticalGrid of- // adaptiveGridCells) with a selection FAB and no top bar. No shared scaffold- // hosts a grid body.- com.vayunmathur.library.ui.Scaffold(+ com.vayunmathur.library.ui.AppScaffold(+ topBar = {}, floatingActionButton = { if (inSelectionMode) { FloatingActionButton(onClick = {
youpipe/src/main/java/com/vayunmathur/youpipe/ui/NavigationEntries.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/NavigationEntries.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/NavigationEntries.ktindex 80cc7b4a7b..b3c57d275d 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/NavigationEntries.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/NavigationEntries.kt@@ -15,8 +15,10 @@ import com.vayunmathur.youpipe.Route import com.vayunmathur.youpipe.platform.YouPipeViewModel import com.vayunmathur.youpipe.ui.dialogs.AddToPlaylist import com.vayunmathur.youpipe.ui.dialogs.AddToWatchLater+import com.vayunmathur.youpipe.ui.dialogs.ClearHistoryDialog import com.vayunmathur.youpipe.ui.dialogs.CreatePlaylist import com.vayunmathur.youpipe.ui.dialogs.CreateSubscriptionCategory+import com.vayunmathur.youpipe.ui.dialogs.DownloadOptionsDialog internal fun navigationTabs(): List<RouteTab<Route>> = listOf( RouteTab(Route.Home, "Home", { IconHome() }),@@ -75,6 +77,18 @@ internal fun EntryProviderScope<Route>.detailEntries( } } +internal fun EntryProviderScope<Route>.dialogEntries(+ backStack: NavBackStack<Route>,+ ypvm: YouPipeViewModel,+) {+ entry<Route.ClearHistoryDialog>(metadata = DialogPage()) {+ ClearHistoryDialog(backStack, ypvm)+ }+ entry<Route.DownloadOptionsDialog>(metadata = DialogPage()) {+ DownloadOptionsDialog(backStack, ypvm, it.videoID)+ }+}+ internal fun EntryProviderScope<Route>.settingsEntries( backStack: NavBackStack<Route>, ypvm: YouPipeViewModel,
youpipe/src/main/java/com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/PlaylistDetailPage.ktindex 3ffba67931..a9c1612183 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt@@ -1,5 +1,6 @@ package com.vayunmathur.youpipe.ui +import androidx.compose.foundation.layout.size import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement@@ -228,8 +229,10 @@ fun PlaylistDetailPage( titleSharedKey = "youpipe-video-title-${item.videoItem.videoID}", trailingContent = { if (!isSelectionMode && localData.size > 1) {- IconButton(- modifier = Modifier.reorderDragHandle(+ // Drag handle demoted from IconButton: not a+ // button — reorderDragHandle owns the gesture.+ Box(+ modifier = Modifier.size(48.dp).reorderDragHandle( reorderState = reorderState, key = item.id, onDragStarted = {@@ -239,7 +242,7 @@ fun PlaylistDetailPage( hapticFeedback.performHapticFeedback(HapticFeedbackType.GestureEnd) }, ),- onClick = {},+ contentAlignment = Alignment.Center, ) { IconDragHandle() }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/SavedPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SavedPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SavedPage.ktindex f28f2cd3a9..9d79181a58 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SavedPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SavedPage.kt@@ -1,5 +1,8 @@ package com.vayunmathur.youpipe.ui +import androidx.compose.ui.Alignment+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.Box import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.clickable import androidx.compose.foundation.lazy.items@@ -22,7 +25,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.FloatingActionButton import com.vayunmathur.library.ui.IconAdd-import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconDragHandle import com.vayunmathur.library.ui.IconList@@ -171,8 +173,10 @@ fun SavedPage(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeViewModel }, trailingContent = { if (localData.size > 1) {- IconButton(- modifier = Modifier.reorderDragHandle(+ // Drag handle demoted from IconButton: not a+ // button — reorderDragHandle owns the gesture.+ Box(+ modifier = Modifier.size(48.dp).reorderDragHandle( reorderState = reorderState, key = playlist.id, onDragStarted = {@@ -182,7 +186,7 @@ fun SavedPage(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeViewModel hapticFeedback.performHapticFeedback(HapticFeedbackType.GestureEnd) }, ),- onClick = {},+ contentAlignment = Alignment.Center, ) { IconDragHandle() }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/SearchScreen.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SearchScreen.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SearchScreen.ktindex 919b8cf31e..c71e370cba 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SearchScreen.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SearchScreen.kt@@ -21,7 +21,7 @@ import com.vayunmathur.library.ui.MaterialTheme import androidx.compose.material3.ExpandedFullScreenSearchBar import androidx.compose.material3.SearchBar import androidx.compose.material3.rememberSearchBarState-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.SearchBarDefaults import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.isExpandedWidth@@ -110,12 +110,7 @@ fun SearchScreen( ) } - // RAW SCAFFOLD EXCEPTION: the top chrome is a Material3 SearchBar (not a- // TopAppBar) whose expanded state overlays the whole screen with search- // results/suggestions, and the body is a 3-way branch (loading spinner /- // empty state / recommendation feed). No shared scaffold models a SearchBar- // app bar plus this branching content.- Scaffold(+ AppScaffold( topBar = { SearchBar( state = searchBarState,@@ -167,7 +162,7 @@ fun SearchScreen( }, ) { paddingValues -> if (state.recommendationsLoading) {- // Raw Scaffold (SearchBar) has no refresh slot: progress text affordance.+ // No refresh in flight on this screen: progress text affordance. Box(Modifier.fillMaxSize().padding(paddingValues), contentAlignment = Alignment.Center) { Text("Loading\u2026") }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/SubscriptionVideosScreen.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SubscriptionVideosScreen.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SubscriptionVideosScreen.ktindex 75059e322e..b229504772 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SubscriptionVideosScreen.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/SubscriptionVideosScreen.kt@@ -16,7 +16,7 @@ import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import com.vayunmathur.library.ui.LinearProgressIndicator import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.adaptiveGridCells import com.vayunmathur.library.ui.isExpandedWidth import androidx.compose.runtime.Composable@@ -42,10 +42,7 @@ fun SubscriptionVideosScreen( state: SubscriptionFeedUiState, actions: SubscriptionFeedActions, ) {-// RAW SCAFFOLD EXCEPTION: the feed switches between a LazyColumn (compact) and a-// LazyVerticalGrid of adaptiveGridCells (expanded) around the same skeleton/loading-// content. No shared scaffold models a column/grid switch.- Scaffold { paddingValues ->+ AppScaffold(topBar = {}) { paddingValues -> if (isExpandedWidth() && !state.isLoading && state.fetchProgress !in 0f..1f) { // Desktop: the feed fills the window with an adaptive grid instead of // stretching one column across it. Loading states stay a list below.@@ -63,7 +60,7 @@ fun SubscriptionVideosScreen( ) } }- return@Scaffold+ return@AppScaffold } LazyColumn(Modifier.padding(paddingValues)) { if (state.fetchProgress in 0f..1f) {
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.ktindex a43de5f6de..6946fb205f 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt@@ -16,7 +16,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.SecondaryTabRow import com.vayunmathur.library.ui.Tab import com.vayunmathur.library.ui.Text@@ -38,9 +38,6 @@ import kotlinx.coroutines.launch * two-pane: player, details and description scroll in the left pane while comments and * related fill the right pane. */-// RAW SCAFFOLD EXCEPTION: the screen pairs a player slot with a 3-tab pager-// (comments/related/description) that becomes a side-by-side two-pane on expanded-// widths. No shared scaffold models a player slot plus this tabbed detail content. @Composable fun VideoDetailScreen( state: VideoDetailUiState,@@ -52,7 +49,7 @@ fun VideoDetailScreen( titleSharedKey: Any? = null, player: @Composable () -> Unit = {}, ) {- Scaffold { paddingValues ->+ AppScaffold(topBar = {}) { paddingValues -> val modifier = if(fullscreen) Modifier.padding(top = paddingValues.calculateTopPadding(), bottom = paddingValues.calculateBottomPadding()) else Modifier.padding(paddingValues) Column(modifier) { if (state.loaded) {
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.ktindex dbd2087073..2a74d82c26 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt@@ -1,41 +1,25 @@ package com.vayunmathur.youpipe.ui -import android.text.format.Formatter import androidx.compose.foundation.background import androidx.compose.foundation.clickable-import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.width-import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.style.TextAlign-import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp-import androidx.compose.ui.window.Dialog import com.vayunmathur.library.image.ImageRequest import com.vayunmathur.library.image.compose.AsyncImage-import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.LinearProgressIndicator-import com.vayunmathur.library.ui.DropdownMenu-import com.vayunmathur.library.ui.IconArrowDropDown-import com.vayunmathur.library.ui.IconCheck import com.vayunmathur.library.ui.IconClose import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconDownload@@ -44,13 +28,8 @@ import com.vayunmathur.library.ui.IconShare import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.SelectableDropdownMenuItem import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.util.sharedText-import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.platform.VideoDetailActions import com.vayunmathur.youpipe.platform.VideoDetailUiState @@ -60,19 +39,6 @@ fun VideoDetails( actions: VideoDetailActions, titleSharedKey: Any? = null, ) {- var isDownloadDialogVisible by remember { mutableStateOf(false) }-- if (isDownloadDialogVisible) {- DownloadOptionsDialog(- state = state,- onDismiss = { isDownloadDialogVisible = false },- onDownload = { videoUrl, audioUrl ->- isDownloadDialogVisible = false- actions.download(videoUrl, audioUrl)- },- )- }- Column { ListItem(modifier = Modifier, overlineContent = {}, supportingContent = { Text(state.byline)@@ -125,9 +91,7 @@ fun VideoDetails( IconClose() } } else if (!state.downloaded) {- IconButton(onClick = {- isDownloadDialogVisible = true- }) {+ IconButton(onClick = { actions.openDownloadOptions() }) { IconDownload() } } else {@@ -138,144 +102,3 @@ fun VideoDetails( } } }--@Composable-private fun DownloadOptionsDialog(- state: VideoDetailUiState,- onDismiss: () -> Unit,- onDownload: (videoUrl: String, audioUrl: String?) -> Unit,-) {- val videoStreams = state.videoStreams- val audioStreams = state.audioStreams- var selectedVideoStream by remember { mutableStateOf(videoStreams.maxByOrNull { it.height } ?: videoStreams.first()) }- // Always highest quality opus for selected language in download as well- var selectedAudioStream by remember { mutableStateOf(audioStreams.maxByOrNull { it.bitrate }) }-- val languageEntriesDownload = remember(audioStreams) {- audioStreams.map { it.language to (it.displayName ?: it.language) }- .distinctBy { it.first }- .sortedBy { it.first }- }- val languages = languageEntriesDownload.map { it.first }- var selectedLanguage by remember { mutableStateOf(selectedAudioStream?.language ?: languages.firstOrNull() ?: "Default") }-- Dialog(onDismissRequest = onDismiss) {- Card {- Column(Modifier.padding(16.dp)) {- Text(stringResource(R.string.download_options), style = MaterialTheme.typography.titleLarge)- Spacer(Modifier.height(16.dp))-- Text(stringResource(R.string.resolution), style = MaterialTheme.typography.titleMedium)- Spacer(Modifier.height(8.dp))- VideoQualityDropdown(- streams = videoStreams,- selected = selectedVideoStream,- onSelect = { selectedVideoStream = it },- modifier = Modifier.fillMaxWidth(),- )-- if (languages.size > 1) {- Spacer(Modifier.height(16.dp))- Text(stringResource(R.string.language), style = MaterialTheme.typography.titleMedium)- Spacer(Modifier.height(8.dp))- AudioLanguageDropdown(- options = languageEntriesDownload,- selectedCode = selectedLanguage,- onSelect = { code ->- selectedLanguage = code- selectedAudioStream = audioStreams.filter { it.language == code }.maxByOrNull { it.bitrate }- },- modifier = Modifier.fillMaxWidth(),- )- }-- Spacer(Modifier.height(24.dp))- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {- TextButton(onClick = onDismiss) { Text(stringResource(UiR.string.cancel)) }- TextButton(onClick = {- onDownload(selectedVideoStream.url, selectedAudioStream?.url)- }) { Text(stringResource(R.string.download)) }- }- }- }- }-}--/**- * The download resolution picker, built from [OutlinedButton] + [DropdownMenu] rather than the- * library's `ExposedDropdownMenu` wrapper, which currently recurses into itself.- */-@Composable-private fun VideoQualityDropdown(- streams: List<VideoStream>,- selected: VideoStream,- onSelect: (VideoStream) -> Unit,- modifier: Modifier = Modifier,-) {- val context = LocalContext.current- var expanded by remember { mutableStateOf(false) }- Box(modifier) {- OutlinedButton(onClick = { expanded = true }, modifier = Modifier.fillMaxWidth()) {- Text(- "${selected.quality} - ${Formatter.formatShortFileSize(context, selected.size)}",- modifier = Modifier.weight(1f),- textAlign = TextAlign.Start,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- )- IconArrowDropDown()- }- DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {- streams.forEach { stream ->- SelectableDropdownMenuItem(- selected = stream == selected,- onClick = {- onSelect(stream)- expanded = false- },- text = { Text("${stream.quality} (${getVideoCodecName(stream.codec)}) - ${Formatter.formatShortFileSize(context, stream.size)}") },- selectedLeadingIcon = { IconCheck() },- )- }- }- }-}--/**- * The download audio-language picker, built from [OutlinedButton] + [DropdownMenu] rather than- * the library's `ExposedDropdownMenu` wrapper, which currently recurses into itself.- */-@Composable-private fun AudioLanguageDropdown(- options: List<Pair<String, String>>,- selectedCode: String,- onSelect: (String) -> Unit,- modifier: Modifier = Modifier,-) {- var expanded by remember { mutableStateOf(false) }- Box(modifier) {- OutlinedButton(onClick = { expanded = true }, modifier = Modifier.fillMaxWidth()) {- Text(- options.find { it.first == selectedCode }?.second ?: selectedCode,- modifier = Modifier.weight(1f),- textAlign = TextAlign.Start,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- )- IconArrowDropDown()- }- DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {- options.forEach { (code, display) ->- SelectableDropdownMenuItem(- selected = code == selectedCode,- onClick = {- onSelect(code)- expanded = false- },- text = { Text(display) },- selectedLeadingIcon = { IconCheck() },- )- }- }- }-}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPage.ktindex a4f9c39cbb..03b6ffea54 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPage.kt@@ -266,6 +266,10 @@ fun VideoPage( backStack.add(Route.VideoPage(videoID)) } + override fun openDownloadOptions() {+ backStack.add(Route.DownloadOptionsDialog(videoID))+ }+ override fun download(videoUrl: String, audioUrl: String?) { val data = videoData ?: return DownloadManager.enqueueDownload(
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.ktindex 1acb79f621..33b2e41f22 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt@@ -49,7 +49,7 @@ internal fun VideoPlayerChapterSheet( modifier: Modifier = Modifier, ) { val context = LocalContext.current- Box(modifier = modifier.background(Color.Black.copy(alpha = 0.9f)).clickable(enabled = true, onClick = {})) {+ Box(modifier = modifier.background(Color.Black.copy(alpha = 0.9f)).clickable(enabled = true, onClick = onDismiss)) { Column(modifier = Modifier.fillMaxSize()) { Row( modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 12.dp),
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.ktindex a6b52177b2..9ad3c72a87 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt@@ -54,20 +54,11 @@ fun AddToPlaylist( allItems.filter { it.videoItem.videoID == videoID }.map { it.playlistId }.toSet() } - val watchLaterLabel = stringResource(R.string.playlist_watch_later)- AddToListDialog(- title = stringResource(R.string.add_to_playlist),- options = playlists,- itemLabel = { playlist ->- if (playlist.mandatory) watchLaterLabel else playlist.name- },- confirmLabel = stringResource(android.R.string.ok),- dismissLabel = stringResource(android.R.string.cancel),- itemKey = { it.id },- initiallyChecked = { it.id in membership },- createLabel = stringResource(R.string.new_playlist),- canCreate = { name -> name.isNotBlank() && allPlaylists.none { it.name == name.trim() } },- onCreate = { name -> youPipeViewModel.playlistOps.createPlaylistAndAddVideo(name.trim(), video) },+ AddToPlaylistDialogContent(+ playlists = playlists,+ existingNames = allPlaylists.map { it.name },+ membership = membership,+ onCreate = { name -> youPipeViewModel.playlistOps.createPlaylistAndAddVideo(name, video) }, onConfirm = { selected -> val selectedIds = selected.map { it.id }.toSet() playlists.forEach { playlist ->@@ -86,3 +77,32 @@ fun AddToPlaylist( onDismiss = { backStack.pop() }, ) }++/** The stateless add-to-playlist picker, rendered directly by screenshot captures and tests. */+@Composable+internal fun AddToPlaylistDialogContent(+ playlists: List<com.vayunmathur.youpipe.data.Playlist>,+ existingNames: List<String>,+ membership: Set<Long>,+ onCreate: (String) -> Unit,+ onConfirm: (Set<com.vayunmathur.youpipe.data.Playlist>) -> Unit,+ onDismiss: () -> Unit,+) {+ val watchLaterLabel = stringResource(R.string.playlist_watch_later)+ AddToListDialog(+ title = stringResource(R.string.add_to_playlist),+ options = playlists,+ itemLabel = { playlist ->+ if (playlist.mandatory) watchLaterLabel else playlist.name+ },+ confirmLabel = stringResource(android.R.string.ok),+ dismissLabel = stringResource(android.R.string.cancel),+ itemKey = { it.id },+ initiallyChecked = { it.id in membership },+ createLabel = stringResource(R.string.new_playlist),+ canCreate = { name -> name.isNotBlank() && name.trim() !in existingNames },+ onCreate = { name -> onCreate(name.trim()) },+ onConfirm = onConfirm,+ onDismiss = onDismiss,+ )+}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.ktindex b0f0faac0c..df388dd50b 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt@@ -63,7 +63,13 @@ fun AddToWatchLater( } } - Dialog({ backStack.pop() }) {+ AddToWatchLaterDialogContent(onDismiss = { backStack.pop() })+}++/** The stateless adding-to-watch-later notice, rendered directly by screenshot captures. */+@Composable+internal fun AddToWatchLaterDialogContent(onDismiss: () -> Unit) {+ Dialog(onDismiss) { Card { Row(Modifier.padding(24.dp), verticalAlignment = Alignment.CenterVertically) { Text(stringResource(R.string.adding_to_watch_later))
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.ktnew file mode 100644index 0000000000..2a7751235e--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.kt@@ -0,0 +1,40 @@+package com.vayunmathur.youpipe.ui.dialogs++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.youpipe.R+import com.vayunmathur.youpipe.Route+import com.vayunmathur.youpipe.platform.YouPipeViewModel++/**+ * Clear-history confirmation, hosted as the `Route.ClearHistoryDialog`+ * destination (`DialogPage()`). Confirming clears the whole watch history —+ * the lists underneath are flow-driven, so no result needs to travel back.+ */+@Composable+fun ClearHistoryDialog(+ backStack: NavBackStack<Route>,+ youPipeViewModel: YouPipeViewModel,+) {+ ClearHistoryDialogContent(+ onConfirm = { youPipeViewModel.clearHistory() },+ onDismiss = { backStack.pop() },+ )+}++/** The stateless confirmation, rendered directly by screenshot captures and tests. */+@Composable+internal fun ClearHistoryDialogContent(onConfirm: () -> Unit, onDismiss: () -> Unit) {+ ConfirmDialog(+ title = stringResource(R.string.clear_history),+ message = stringResource(R.string.are_you_sure_you_want_to_clear_all_watch),+ confirmLabel = stringResource(UiR.string.clear),+ dismissLabel = stringResource(UiR.string.cancel),+ onConfirm = onConfirm,+ onDismiss = onDismiss,+ destructive = true,+ )+}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.ktindex ac9f248452..73537da69d 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt@@ -30,10 +30,26 @@ import com.vayunmathur.youpipe.platform.YouPipeViewModel @Composable fun CreatePlaylist(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeViewModel) { val playlists by youPipeViewModel.playlists.collectAsStateWithLifecycle()- val existingNames = playlists.map { it.name }+ CreatePlaylistDialogContent(+ existingNames = playlists.map { it.name },+ onCreate = { name ->+ youPipeViewModel.playlistOps.createPlaylist(name)+ backStack.pop()+ },+ onDismiss = { backStack.pop() },+ )+}++/** The stateless create-playlist form, rendered directly by screenshot captures and tests. */+@Composable+internal fun CreatePlaylistDialogContent(+ existingNames: List<String>,+ onCreate: (String) -> Unit,+ onDismiss: () -> Unit,+) { var name by remember { mutableStateOf("") } - Dialog({ backStack.pop() }) {+ Dialog(onDismiss) { Card { Column(Modifier.padding(16.dp)) { Text(@@ -47,10 +63,7 @@ fun CreatePlaylist(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeView label = { Text(stringResource(R.string.label_playlist_name)) }, ) Button(- {- youPipeViewModel.playlistOps.createPlaylist(name.trim())- backStack.pop()- },+ { onCreate(name.trim()) }, Modifier.fillMaxWidth().padding(top = 8.dp), enabled = name.isNotBlank() && name.trim() !in existingNames, ) {
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.ktindex 3b600bb709..4475f8610a 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui.dialogs+ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth@@ -8,14 +9,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape-import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.Checkbox-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.ListItem-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.OutlinedTextField-import com.vayunmathur.library.ui.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue@@ -25,15 +18,25 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog-import androidx.compose.ui.res.stringResource-import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.library.image.compose.AsyncImage import com.vayunmathur.library.image.ImageRequest-import com.vayunmathur.youpipe.R+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.Checkbox+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.Route+import com.vayunmathur.youpipe.data.Subscription import com.vayunmathur.youpipe.platform.YouPipeViewModel import kotlinx.coroutines.launch @@ -42,65 +45,104 @@ import kotlinx.coroutines.launch fun CreateSubscriptionCategory(backStack: NavBackStack<Route>, youPipeViewModel: YouPipeViewModel, id: String?) { val subscriptions by youPipeViewModel.subscriptions.collectAsState() val categories by youPipeViewModel.subscriptionCategories.collectAsState()- val categoryNames = categories.map { it.category }- var categoryName by remember { mutableStateOf(id?:"") }- val subscriptionsAlreadyInCategory by remember(categoryName) {- youPipeViewModel.subscriptionsInCategory(categoryName)+ val initialSelected by remember(id) {+ youPipeViewModel.subscriptionsInCategory(id ?: "") }.collectAsState(initial = emptyList())- var selectedSubscriptions by remember(subscriptionsAlreadyInCategory) { mutableStateOf(subscriptionsAlreadyInCategory) } val coroutineScope = rememberCoroutineScope()- val context = androidx.compose.ui.platform.LocalContext.current- Dialog({backStack.pop()}) {++ CreateSubscriptionCategoryDialogContent(+ editingId = id,+ subscriptions = subscriptions,+ categoryNames = categories.map { it.category },+ initialSelectedIds = initialSelected.map { it.id }.toSet(),+ onSubmit = { name, selectedIds ->+ coroutineScope.launch {+ youPipeViewModel.replaceCategory(id, name, selectedIds)+ backStack.pop()+ }+ },+ onDismiss = { backStack.pop() },+ )+}++/** The stateless category form, rendered directly by screenshot captures and tests. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+internal fun CreateSubscriptionCategoryDialogContent(+ editingId: String?,+ subscriptions: List<Subscription>,+ categoryNames: List<String>,+ initialSelectedIds: Set<Long>,+ onSubmit: (name: String, selectedIds: List<Long>) -> Unit,+ onDismiss: () -> Unit,+) {+ var categoryName by remember { mutableStateOf(editingId ?: "") }+ var selectedIds by remember(initialSelectedIds) { mutableStateOf(initialSelectedIds) }+ val context = LocalContext.current++ Dialog(onDismiss) { Card { Column(Modifier.padding(16.dp)) {- if(id == null)- Text(stringResource(R.string.title_create_subscription_category), style = MaterialTheme.typography.titleLarge)- else- Text(stringResource(R.string.title_update_subscription_category), style = MaterialTheme.typography.titleLarge)+ if (editingId == null) {+ Text(+ stringResource(R.string.title_create_subscription_category),+ style = MaterialTheme.typography.titleLarge,+ )+ } else {+ Text(+ stringResource(R.string.title_update_subscription_category),+ style = MaterialTheme.typography.titleLarge,+ )+ } Spacer(Modifier.height(8.dp))- OutlinedTextField(categoryName, {categoryName = it}, label = {Text(stringResource(R.string.label_category_name))})+ OutlinedTextField(+ categoryName,+ { categoryName = it },+ label = { Text(stringResource(R.string.label_category_name)) },+ ) Spacer(Modifier.height(8.dp)) Text(stringResource(R.string.label_select_subscriptions)) LazyColumn(Modifier.weight(1f)) {- items(subscriptions, key = { it.id }) {subscription ->- ListItem(trailingContent = {- Checkbox(subscription in selectedSubscriptions, {- selectedSubscriptions = if(subscription in selectedSubscriptions)- selectedSubscriptions - subscription- else- selectedSubscriptions + subscription- })- }, leadingContent = {- AsyncImage(- model = ImageRequest.Builder(context)- .data(subscription.avatarURL)- .memoryCacheKey("sub-avatar-${subscription.id}")- .build(),- contentDescription = null,- Modifier.size(24.dp).clip(CircleShape)- )- }) {+ items(subscriptions, key = { it.id }) { subscription ->+ ListItem(+ trailingContent = {+ Checkbox(+ subscription.id in selectedIds,+ {+ selectedIds = if (subscription.id in selectedIds) {+ selectedIds - subscription.id+ } else {+ selectedIds + subscription.id+ }+ },+ )+ },+ leadingContent = {+ AsyncImage(+ model = ImageRequest.Builder(context)+ .data(subscription.avatarURL)+ .memoryCacheKey("sub-avatar-${subscription.id}")+ .build(),+ contentDescription = null,+ Modifier.size(24.dp).clip(CircleShape),+ )+ },+ ) { Text(subscription.name) } } } Button(- {- coroutineScope.launch {- youPipeViewModel.replaceCategory(- id,- categoryName,- selectedSubscriptions.map { it.id })- backStack.pop()- }- },+ { onSubmit(categoryName, selectedIds.toList()) }, Modifier.fillMaxWidth().padding(top = 8.dp),- enabled = categoryName.isNotBlank() && selectedSubscriptions.isNotEmpty() && (id != null || categoryName !in categoryNames)+ enabled = categoryName.isNotBlank() && selectedIds.isNotEmpty() &&+ (editingId != null || categoryName !in categoryNames), ) {- if(id == null)+ if (editingId == null) { Text(stringResource(UiR.string.create))- else+ } else { Text(stringResource(R.string.action_update))+ } } } }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.ktnew file mode 100644index 0000000000..45b25651da--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.kt@@ -0,0 +1,239 @@+package com.vayunmathur.youpipe.ui.dialogs++import android.text.format.Formatter+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.compose.ui.window.Dialog+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.DropdownMenu+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.IconArrowDropDown+import com.vayunmathur.library.ui.IconCheck+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.SelectableDropdownMenuItem+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.youpipe.R+import com.vayunmathur.youpipe.Route+import com.vayunmathur.youpipe.platform.DownloadManager+import com.vayunmathur.youpipe.platform.YouPipeViewModel+import com.vayunmathur.youpipe.ui.AudioStream+import com.vayunmathur.youpipe.ui.VideoInfo+import com.vayunmathur.youpipe.ui.VideoStream+import com.vayunmathur.youpipe.ui.getVideoCodecName++/**+ * Download-options dialog, hosted as the `Route.DownloadOptionsDialog`+ * destination (`DialogPage()`). The route carries only the video identity;+ * the offered streams come from the loaded video state the video page left+ * in the ViewModel. Confirming enqueues the download here (the TV download+ * sheet's pattern): the progress UI underneath is driven by+ * [DownloadManager.activeDownloads], so no result needs to travel back.+ */+@Composable+fun DownloadOptionsDialog(+ backStack: NavBackStack<Route>,+ youPipeViewModel: YouPipeViewModel,+ videoID: Long,+) {+ val videoState by youPipeViewModel.videoState.collectAsState()+ val context = LocalContext.current++ if (videoState.data == null || videoState.videoStreams.isEmpty()) {+ // Pushed only once a video has loaded; without streams there is+ // nothing to choose, so the destination dismisses itself.+ LaunchedEffect(Unit) { backStack.pop() }+ return+ }++ val data = videoState.data ?: return+ DownloadOptionsDialogContent(+ videoStreams = videoState.videoStreams,+ audioStreams = videoState.audioStreams,+ onDismiss = { backStack.pop() },+ onDownload = { videoUrl, audioUrl ->+ DownloadManager.enqueueDownload(+ context,+ VideoInfo(+ data.title, videoID, data.duration, data.views,+ data.uploadDate, data.thumbnailURL, data.author,+ ),+ videoUrl,+ audioUrl,+ )+ backStack.pop()+ },+ )+}++/** The stateless download picker, rendered directly by screenshot captures and tests. */+@Composable+internal fun DownloadOptionsDialogContent(+ videoStreams: List<VideoStream>,+ audioStreams: List<AudioStream>,+ onDismiss: () -> Unit,+ onDownload: (videoUrl: String, audioUrl: String?) -> Unit,+) {+ var selectedVideoStream by remember {+ mutableStateOf(videoStreams.maxByOrNull { it.height } ?: videoStreams.first())+ }+ // Always highest quality opus for selected language in download as well+ var selectedAudioStream by remember { mutableStateOf(audioStreams.maxByOrNull { it.bitrate }) }++ val languageEntriesDownload = remember(audioStreams) {+ audioStreams.map { it.language to (it.displayName ?: it.language) }+ .distinctBy { it.first }+ .sortedBy { it.first }+ }+ val languages = languageEntriesDownload.map { it.first }+ var selectedLanguage by remember {+ mutableStateOf(selectedAudioStream?.language ?: languages.firstOrNull() ?: "Default")+ }++ Dialog(onDismissRequest = onDismiss) {+ Card {+ Column(Modifier.padding(16.dp)) {+ Text(stringResource(R.string.download_options), style = MaterialTheme.typography.titleLarge)+ Spacer(Modifier.height(16.dp))++ Text(stringResource(R.string.resolution), style = MaterialTheme.typography.titleMedium)+ Spacer(Modifier.height(8.dp))+ VideoQualityDropdown(+ streams = videoStreams,+ selected = selectedVideoStream,+ onSelect = { selectedVideoStream = it },+ modifier = Modifier.fillMaxWidth(),+ )++ if (languages.size > 1) {+ Spacer(Modifier.height(16.dp))+ Text(stringResource(R.string.language), style = MaterialTheme.typography.titleMedium)+ Spacer(Modifier.height(8.dp))+ AudioLanguageDropdown(+ options = languageEntriesDownload,+ selectedCode = selectedLanguage,+ onSelect = { code ->+ selectedLanguage = code+ selectedAudioStream = audioStreams.filter { it.language == code }+ .maxByOrNull { it.bitrate }+ },+ modifier = Modifier.fillMaxWidth(),+ )+ }++ Spacer(Modifier.height(24.dp))+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {+ TextButton(onClick = onDismiss) { Text(stringResource(UiR.string.cancel)) }+ TextButton(onClick = {+ onDownload(selectedVideoStream.url, selectedAudioStream?.url)+ }) { Text(stringResource(R.string.download)) }+ }+ }+ }+ }+}++/**+ * The download resolution picker, built from [OutlinedButton] + [DropdownMenu] rather than the+ * library's `ExposedDropdownMenu` wrapper, which currently recurses into itself.+ */+@Composable+private fun VideoQualityDropdown(+ streams: List<VideoStream>,+ selected: VideoStream,+ onSelect: (VideoStream) -> Unit,+ modifier: Modifier = Modifier,+) {+ val context = LocalContext.current+ var expanded by remember { mutableStateOf(false) }+ Box(modifier) {+ OutlinedButton(onClick = { expanded = true }, modifier = Modifier.fillMaxWidth()) {+ Text(+ "${selected.quality} - ${Formatter.formatShortFileSize(context, selected.size)}",+ modifier = Modifier.weight(1f),+ textAlign = TextAlign.Start,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ IconArrowDropDown()+ }+ DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {+ streams.forEach { stream ->+ SelectableDropdownMenuItem(+ selected = stream == selected,+ onClick = {+ onSelect(stream)+ expanded = false+ },+ text = {+ Text(+ "${stream.quality} (${getVideoCodecName(stream.codec)}) - " ++ Formatter.formatShortFileSize(context, stream.size),+ )+ },+ selectedLeadingIcon = { IconCheck() },+ )+ }+ }+ }+}++/**+ * The download audio-language picker, built from [OutlinedButton] + [DropdownMenu] rather than+ * the library's `ExposedDropdownMenu` wrapper, which currently recurses into itself.+ */+@Composable+private fun AudioLanguageDropdown(+ options: List<Pair<String, String>>,+ selectedCode: String,+ onSelect: (String) -> Unit,+ modifier: Modifier = Modifier,+) {+ var expanded by remember { mutableStateOf(false) }+ Box(modifier) {+ OutlinedButton(onClick = { expanded = true }, modifier = Modifier.fillMaxWidth()) {+ Text(+ options.find { it.first == selectedCode }?.second ?: selectedCode,+ modifier = Modifier.weight(1f),+ textAlign = TextAlign.Start,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ IconArrowDropDown()+ }+ DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {+ options.forEach { (code, display) ->+ SelectableDropdownMenuItem(+ selected = code == selectedCode,+ onClick = {+ onSelect(code)+ expanded = false+ },+ text = { Text(display) },+ selectedLeadingIcon = { IconCheck() },+ )+ }+ }+ }+}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.ktnew file mode 100644index 0000000000..686fea973c--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.kt@@ -0,0 +1,34 @@+package com.vayunmathur.youpipe.ui.tv++import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.tv.TvButton+import com.vayunmathur.library.tv.TvDialog+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.youpipe.R++/**+ * The TV clear-history confirmation, shared by the data-settings and history+ * pages and hosted as the `TvRoute.ClearHistoryDialog` destination+ * (`DialogPage()`), so neither page holds confirm state of its own.+ */+@Composable+fun TvClearHistoryDialog(onDismiss: () -> Unit, onClear: () -> Unit) {+ TvDialog(+ title = stringResource(R.string.clear_history),+ onDismissRequest = onDismiss,+ body = stringResource(R.string.are_you_sure_you_want_to_clear_all_watch),+ buttons = {+ TvButton(+ text = stringResource(UiR.string.clear),+ onClick = onClear,+ primary = true,+ )+ TvButton(+ text = stringResource(UiR.string.cancel),+ onClick = onDismiss,+ )+ },+ content = {},+ )+}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvDataSettings.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvDataSettings.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvDataSettings.ktindex c8ae3df37b..78be63a2e0 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvDataSettings.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvDataSettings.kt@@ -10,9 +10,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester@@ -21,12 +19,10 @@ import androidx.compose.ui.unit.dp import androidx.tv.material3.MaterialTheme import androidx.tv.material3.Text import androidx.compose.foundation.layout.fillMaxWidth-import com.vayunmathur.library.tv.TvButton-import com.vayunmathur.library.tv.TvDialog import com.vayunmathur.library.tv.TvListRow import com.vayunmathur.library.tv.TvScreenHeader import com.vayunmathur.library.ui.LinearProgressIndicator-import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.platform.YouPipeViewModel import com.vayunmathur.youpipe.platform.exportSubscriptions@@ -42,11 +38,11 @@ import com.vayunmathur.youpipe.platform.restoreSubscriptions */ @Composable fun TvDataSettingsPage(+ backStack: NavBackStack<TvRoute>, ypvm: YouPipeViewModel, ) { val isLoading by ypvm.isImporting.collectAsState() val progress by ypvm.importProgress.collectAsState()- var confirmClear by remember { mutableStateOf(false) } val firstFocus = remember { FocusRequester() } val youtubeLauncher = androidx.activity.compose.rememberLauncherForActivityResult(@@ -69,7 +65,7 @@ fun TvDataSettingsPage( isLoading = isLoading, progress = progress, firstFocus = firstFocus,- onClearClick = { confirmClear = true },+ onClearClick = { backStack.add(TvRoute.ClearHistoryDialog) }, onExport = { exportLauncher.launch("youpipe_subscriptions.json") }, onRestore = { restoreLauncher.launch("application/json") }, onImportNewPipe = { newPipeLauncher.launch("application/json") },@@ -77,15 +73,6 @@ fun TvDataSettingsPage( ) } }- if (confirmClear) {- TvClearHistoryDialog(- onDismiss = { confirmClear = false },- onClear = {- ypvm.clearHistory()- confirmClear = false- },- )- } } @Composable@@ -138,23 +125,3 @@ private fun TvDataSettingsRows( } } -@Composable-private fun TvClearHistoryDialog(onDismiss: () -> Unit, onClear: () -> Unit) {- TvDialog(- title = stringResource(R.string.clear_history),- onDismissRequest = onDismiss,- body = stringResource(R.string.are_you_sure_you_want_to_clear_all_watch),- buttons = {- TvButton(- text = stringResource(UiR.string.clear),- onClick = onClear,- primary = true,- )- TvButton(- text = stringResource(UiR.string.cancel),- onClick = onDismiss,- )- },- content = {},- )-}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvHistory.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvHistory.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvHistory.ktindex 8814205066..1fa629d506 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvHistory.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvHistory.kt@@ -14,7 +14,6 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.res.stringResource import com.vayunmathur.library.tv.TvButton-import com.vayunmathur.library.tv.TvDialog import com.vayunmathur.library.tv.TvEmptyState import com.vayunmathur.library.tv.TvLoading import com.vayunmathur.library.tv.TvGrid@@ -47,7 +46,6 @@ fun TvHistoryPage( val rows = rememberTvVideoRows(videos, ypvm, historyById) var selectedIds by remember { mutableStateOf(emptySet<Long>()) }- var confirmClear by remember { mutableStateOf(false) } val inSelectionMode = selectedIds.isNotEmpty() BackHandler(enabled = inSelectionMode) { selectedIds = emptySet() } @@ -62,7 +60,7 @@ fun TvHistoryPage( selectedIds = emptySet() }, onCancelSelection = { selectedIds = emptySet() },- onClearClick = { confirmClear = true },+ onClearClick = { backStack.add(TvRoute.ClearHistoryDialog) }, ) if (!hasLoaded && rows.isEmpty()) { TvLoading()@@ -85,15 +83,6 @@ fun TvHistoryPage( }, ) }- if (confirmClear) {- TvClearHistoryDialog(- onDismiss = { confirmClear = false },- onClear = {- ypvm.clearHistory()- confirmClear = false- },- )- } } @Composable@@ -159,22 +148,3 @@ private fun TvHistoryGrid( } } -@Composable-private fun TvClearHistoryDialog(onDismiss: () -> Unit, onClear: () -> Unit) {- TvDialog(- title = stringResource(R.string.clear_history),- onDismissRequest = onDismiss,- body = stringResource(R.string.are_you_sure_you_want_to_clear_all_watch),- buttons = {- TvButton(- text = stringResource(UiR.string.clear),- onClick = onClear,- primary = true,- )- TvButton(- text = stringResource(UiR.string.cancel),- onClick = onDismiss,- )- },- )-}
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.ktindex f119b27701..e9ecc8fe53 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt@@ -17,6 +17,7 @@ import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.IconSettings import com.vayunmathur.library.ui.IconSubscriptions import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.library.util.DialogPage import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.SiblingPage@@ -86,7 +87,16 @@ fun TvNavigation(ypvm: YouPipeViewModel, initialBackStack: List<TvRoute> = listO entry<TvRoute.SettingsGeneral> { TvGeneralSettingsPage(ypvm) } entry<TvRoute.SettingsSponsorBlock> { TvSponsorBlockSettingsPage(ypvm) } entry<TvRoute.SettingsRecommendations> { TvRecommendationsSettingsPage(backStack, ypvm) }- entry<TvRoute.SettingsData> { TvDataSettingsPage(ypvm) }+ entry<TvRoute.SettingsData> { TvDataSettingsPage(backStack, ypvm) }+ entry<TvRoute.ClearHistoryDialog>(metadata = DialogPage()) {+ TvClearHistoryDialog(+ onDismiss = { backStack.pop() },+ onClear = {+ ypvm.clearHistory()+ backStack.pop()+ },+ )+ } entry<TvRoute.ManageInterests> { TvManageInterestsPage(ypvm) } } }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.ktindex d656213039..6ccad5dbe7 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt@@ -98,6 +98,13 @@ sealed interface TvRoute : NavKey { /** Singleton holding manage interests state and operations. */ @Serializable data object ManageInterests : TvRoute++ /**+ * Clear-watch-history confirmation dialog (`DialogPage()` over the page+ * that asked). No arguments: confirming clears the whole history.+ */+ @Serializable+ data object ClearHistoryDialog : TvRoute } /** Rail indices, matching the rail order. Kept for the legacy initialTab int. */
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvTransportOverlay.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvTransportOverlay.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvTransportOverlay.ktindex 3225a4c5a0..714527967b 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvTransportOverlay.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvTransportOverlay.kt@@ -50,6 +50,7 @@ import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.platform.CastPlayback import com.vayunmathur.youpipe.platform.YouPipeViewModel +// DIALOG LOCAL EXCEPTION: the player settings menu acts on live TvPlayerSettings callbacks that open the fullscreen player's own quality/speed/language/chapter sheet state; those lambdas and the live transport snapshot cannot be serialised into TvRoute arguments, so this menu cannot be a route destination yet. /** * The player overlay, laid out like YouTube for TV: title and byline top-left; elapsed/total * over a thin full-width seek bar; one control row - channel, Details and Subscribe on the left,
youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt
diff --git a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.ktindex f093c88833..016e897136 100644--- a/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt+++ b/youpipe/src/screenshotTest/kotlin/com/vayunmathur/youpipe/ui/MetadataPreviews.kt@@ -29,6 +29,38 @@ import com.vayunmathur.youpipe.platform.VideoDetailActions import com.vayunmathur.youpipe.platform.VideoDetailUiState import com.vayunmathur.youpipe.platform.VideoRowState +import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.IconDownload+import com.vayunmathur.library.ui.IconList+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.SettingsRow+import com.vayunmathur.library.ui.SettingsSection+import com.vayunmathur.library.ui.SettingsSwitchRow+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.youpipe.R+import com.vayunmathur.youpipe.data.Playlist+import com.vayunmathur.youpipe.data.Subscription+import com.vayunmathur.youpipe.domain.RecommendationPreset+import com.vayunmathur.youpipe.platform.YouPipeViewModel+import com.vayunmathur.youpipe.ui.dialogs.AddToPlaylistDialogContent+import com.vayunmathur.youpipe.ui.dialogs.AddToWatchLaterDialogContent+import com.vayunmathur.youpipe.ui.dialogs.ClearHistoryDialogContent+import com.vayunmathur.youpipe.ui.dialogs.CreatePlaylistDialogContent+import com.vayunmathur.youpipe.ui.dialogs.CreateSubscriptionCategoryDialogContent+import com.vayunmathur.youpipe.ui.dialogs.DownloadOptionsDialogContent+ /** Phone-shaped, roughly 1080x2340 at xxhdpi — comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420" @@ -255,6 +287,443 @@ class MetadataPreviews { ) } ++ // ---- Route coverage captures (RouteScreenshotCoverage) ----------------+ // The pages below are ViewModel binders, so each capture renders the+ // route's own content slice — the same rows, sections and dialog contents+ // the binder composes — from the literal fixtures above. Dialog routes+ // render their stateless dialog content directly.++ @PreviewTest+ @Preview(name = "8-history", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview8History() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(topBar = {}) { padding ->+ FeedGrid(+ rows = SampleRows,+ key = { it.videoID },+ modifier = Modifier.fillMaxSize().padding(padding),+ ) { row -> VideoRow(row = row) }+ }+ }+ }++ @PreviewTest+ @Preview(name = "9-saved", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview9Saved() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = "Saved") { padding ->+ LazyColumn(Modifier.fillMaxSize().padding(padding)) {+ item {+ ListItem(+ leadingContent = { IconDownload() },+ supportingContent = { Text("3 videos") },+ ) { Text(stringResource(R.string.title_downloads)) }+ }+ item {+ ListItem(+ leadingContent = { IconList() },+ supportingContent = { Text("12 videos") },+ ) { Text(stringResource(R.string.playlist_watch_later)) }+ }+ items(SamplePlaylists, key = { it.id }) { playlist ->+ ListItem(+ leadingContent = { IconList() },+ supportingContent = { Text("4 videos") },+ ) { Text(playlist.name) }+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "10-settings", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview10Settings() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = "Settings") { padding ->+ Column(Modifier.fillMaxSize().padding(padding)) {+ SettingsRow(title = stringResource(R.string.settings_general_content), onClick = {})+ SettingsRow(+ title = stringResource(R.string.settings_sponsorblock),+ supportingText = "5 of 8 categories blocked",+ onClick = {},+ )+ SettingsRow(+ title = stringResource(R.string.label_recommendations),+ supportingText = "Balanced",+ onClick = {},+ )+ SettingsRow(title = stringResource(R.string.settings_data), onClick = {})+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "11-video-page", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview11VideoPage() {+ DynamicTheme(darkTheme = true) {+ VideoDetailScreen(+ state = SampleVideo,+ actions = VideoDetailActions.Noop,+ player = { PlayerPlaceholder() },+ )+ }+ }++ @PreviewTest+ @Preview(name = "12-channel-page", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview12ChannelPage() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(topBar = {}) { padding ->+ Column(Modifier.fillMaxSize().padding(padding)) {+ ChannelHeader(+ ChannelInfo(+ name = "Look Mum No Computer",+ channelID = "UCsample",+ subscribers = 812_000,+ videos = 214,+ avatar = "",+ ),+ )+ FeedGrid(+ rows = SampleRows,+ key = { it.videoID },+ modifier = Modifier.weight(1f),+ ) { row -> VideoRow(row = row) }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "13-subscription-videos-page", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview13SubscriptionVideosPage() {+ DynamicTheme(darkTheme = true) {+ SubscriptionVideosScreen(+ state = SubscriptionFeedUiState(videos = SampleRows),+ actions = SubscriptionFeedActions.Noop,+ )+ }+ }++ @PreviewTest+ @Preview(name = "14-create-subscription-category", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview14CreateSubscriptionCategory() {+ DynamicTheme(darkTheme = true) {+ CreateSubscriptionCategoryDialogContent(+ editingId = null,+ subscriptions = SampleSubscriptions,+ categoryNames = listOf("News", "Music"),+ initialSelectedIds = setOf(1L),+ onSubmit = { _, _ -> },+ onDismiss = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "15-downloads", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview15Downloads() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.title_downloads)) { padding ->+ FeedGrid(+ rows = SampleRows,+ key = { it.videoID },+ modifier = Modifier.fillMaxSize().padding(padding),+ ) { row -> VideoRow(row = row) }+ }+ }+ }++ @PreviewTest+ @Preview(name = "16-playlist-detail", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview16PlaylistDetail() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = "Weekend Projects") { padding ->+ FeedGrid(+ rows = SampleRows,+ key = { it.videoID },+ modifier = Modifier.fillMaxSize().padding(padding),+ ) { row -> VideoRow(row = row) }+ }+ }+ }++ @PreviewTest+ @Preview(name = "17-create-playlist", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview17CreatePlaylist() {+ DynamicTheme(darkTheme = true) {+ CreatePlaylistDialogContent(+ existingNames = SamplePlaylists.map { it.name },+ onCreate = {},+ onDismiss = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "18-add-to-playlist", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview18AddToPlaylist() {+ DynamicTheme(darkTheme = true) {+ AddToPlaylistDialogContent(+ playlists = SamplePlaylists,+ existingNames = SamplePlaylists.map { it.name },+ membership = setOf(1L),+ onCreate = {},+ onConfirm = {},+ onDismiss = {},+ )+ }+ }++ @PreviewTest+ @Preview(name = "19-add-to-watch-later", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview19AddToWatchLater() {+ DynamicTheme(darkTheme = true) {+ AddToWatchLaterDialogContent(onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "20-settings-general", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview20SettingsGeneral() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.settings_general_content)) { padding ->+ Column(+ Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),+ ) {+ SettingsSection(title = stringResource(R.string.label_general)) {+ SettingsRow(+ title = stringResource(R.string.label_default_page),+ supportingText = stringResource(com.vayunmathur.library.ui.R.string.home),+ onClick = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_dearrow),+ supportingText = stringResource(R.string.label_dearrow_description),+ checked = true,+ onCheckedChange = {},+ )+ }+ SettingsSection(title = stringResource(R.string.label_player)) {+ SettingsSwitchRow(+ title = stringResource(R.string.label_keep_controls_visible),+ supportingText = stringResource(R.string.label_keep_controls_visible_description),+ checked = false,+ onCheckedChange = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_notification_style_progress),+ supportingText = stringResource(R.string.label_notification_style_progress_description),+ checked = true,+ onCheckedChange = {},+ )+ }+ SettingsSection(title = stringResource(R.string.label_youtube_content)) {+ SettingsRow(+ title = stringResource(R.string.label_youtube_language),+ supportingText = stringResource(R.string.label_system_default),+ onClick = {},+ )+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "21-settings-sponsor-block", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview21SettingsSponsorBlock() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.settings_sponsorblock)) { padding ->+ Column(+ Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),+ ) {+ SettingsSection(title = stringResource(R.string.label_sponsorblock)) {+ YouPipeViewModel.ALL_SPONSOR_CATEGORIES.forEach { category ->+ SettingsSwitchRow(+ title = YouPipeViewModel.SPONSOR_CATEGORY_LABELS[category] ?: category,+ checked = category in SampleSponsorCategories,+ onCheckedChange = {},+ )+ }+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "22-settings-recommendations", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview22SettingsRecommendations() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.label_recommendations)) { padding ->+ Column(+ Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),+ ) {+ androidx.compose.foundation.layout.Row(+ Modifier.padding(horizontal = 16.dp, vertical = 8.dp),+ ) {+ RecommendationPreset.entries.forEach { preset ->+ FilterChip(+ selected = preset == RecommendationPreset.BALANCED,+ onClick = {},+ label = { Text(presetLabel(preset)) },+ modifier = Modifier.padding(end = 8.dp),+ )+ }+ }+ Column(Modifier.padding(horizontal = 16.dp)) {+ Text(stringResource(R.string.label_dial_discovery))+ Slider(value = 0.5f, onValueChange = {}, valueRange = 0f..1f)+ Text(stringResource(R.string.label_dial_fresh))+ Slider(value = 0.35f, onValueChange = {}, valueRange = 0f..1f)+ Text(stringResource(R.string.label_dial_diverse))+ Slider(value = 0.65f, onValueChange = {}, valueRange = 0f..1f)+ }+ SettingsSection(title = stringResource(R.string.label_rec_sources)) {+ SettingsSwitchRow(+ title = stringResource(R.string.label_source_related),+ checked = true,+ onCheckedChange = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_source_trending),+ checked = true,+ onCheckedChange = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_source_subscription),+ checked = false,+ onCheckedChange = {},+ )+ }+ SettingsSection(title = stringResource(R.string.label_rec_content_filters)) {+ SettingsSwitchRow(+ title = stringResource(R.string.label_hide_shorts),+ checked = false,+ onCheckedChange = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_hide_live),+ checked = true,+ onCheckedChange = {},+ )+ SettingsSwitchRow(+ title = stringResource(R.string.label_hide_paid),+ checked = true,+ onCheckedChange = {},+ )+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "23-settings-data", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview23SettingsData() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.settings_data)) { padding ->+ Column(+ Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState()),+ ) {+ SettingsSection(title = stringResource(R.string.title_history)) {+ SettingsRow(title = stringResource(R.string.clear_history), onClick = {})+ }+ SettingsSection(title = stringResource(R.string.label_backup_restore)) {+ SettingsRow(title = stringResource(R.string.label_export_youpipe), onClick = {})+ SettingsRow(title = stringResource(R.string.label_restore_youpipe), onClick = {})+ SettingsRow(title = stringResource(R.string.label_import_newpipe), onClick = {})+ SettingsRow(title = stringResource(R.string.label_import_youtube), onClick = {})+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "24-manage-interests", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview24ManageInterests() {+ DynamicTheme(darkTheme = true) {+ AppScaffold(title = stringResource(R.string.title_manage_interests)) { padding ->+ LazyColumn(Modifier.fillMaxSize().padding(padding)) {+ item {+ Text(+ stringResource(R.string.label_your_channels),+ modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 4.dp),+ )+ }+ items(SampleSubscriptions, key = { "ch-${it.id}" }) { subscription ->+ ListItem(+ supportingContent = { Text(subscription.channelID) },+ trailingContent = {+ TextButton(onClick = {}) { Text(stringResource(R.string.action_unpin)) }+ },+ ) { Text(subscription.name) }+ }+ item {+ Text(+ stringResource(R.string.label_your_topics),+ modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 4.dp),+ )+ }+ items(listOf("camera sensors", "rust", "sourdough"), key = { "kw-$it" }) { keyword ->+ ListItem(+ trailingContent = {+ TextButton(onClick = {}) {+ Text(stringResource(com.vayunmathur.library.ui.R.string.remove))+ }+ },+ ) { Text(keyword) }+ }+ }+ }+ }+ }++ @PreviewTest+ @Preview(name = "25-clear-history-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview25ClearHistoryDialog() {+ DynamicTheme(darkTheme = true) {+ ClearHistoryDialogContent(onConfirm = {}, onDismiss = {})+ }+ }++ @PreviewTest+ @Preview(name = "26-download-options-dialog", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview26DownloadOptionsDialog() {+ DynamicTheme(darkTheme = true) {+ DownloadOptionsDialogContent(+ videoStreams = SampleVideoStreams,+ audioStreams = SampleAudioStreams,+ onDismiss = {},+ onDownload = { _, _ -> },+ )+ }+ }+ /** * The app's real tab chrome around the home content: the same five * route tabs `Navigation` in MainActivity declares, in the same@@ -285,6 +754,60 @@ class MetadataPreviews { } } ++private val SampleRows = listOf(+ VideoRowState(+ videoID = 31,+ title = "Rewiring a 1970s Synthesizer, Part 4",+ author = "Look Mum No Computer",+ stats = "94K views | 6 hours ago",+ percentWatched = 0.63f,+ ),+ VideoRowState(+ videoID = 32,+ title = "The Fastest Way to Sort a Million Integers",+ author = "Creel",+ stats = "137K views | 1 day ago",+ ),+ VideoRowState(+ videoID = 33,+ title = "Restoring a Water-Damaged ThinkPad",+ author = "Rossmann Repair",+ stats = "421K views | 2 days ago",+ percentWatched = 0.08f,+ ),+ VideoRowState(+ videoID = 34,+ title = "A Field Guide to the Birds of the Cairngorms",+ author = "Slow Nature",+ stats = "38K views | 3 days ago",+ ),+)++private val SamplePlaylists = listOf(+ Playlist(id = 1, name = "Watch later", mandatory = true),+ Playlist(id = 2, name = "Music Mix"),+ Playlist(id = 3, name = "Weekend Projects"),+)++private val SampleSubscriptions = listOf(+ Subscription(id = 1, name = "Look Mum No Computer", channelID = "UCsample1", avatarURL = ""),+ Subscription(id = 2, name = "Creel", channelID = "UCsample2", avatarURL = ""),+ Subscription(id = 3, name = "Slow Nature", channelID = "UCsample3", avatarURL = ""),+)++private val SampleSponsorCategories = setOf("sponsor", "selfpromo", "intro", "outro", "interaction")++private val SampleVideoStreams = listOf(+ VideoStream("https://v/360", 640, 360, 800_000, 30, "360p", "vp09", 5_000),+ VideoStream("https://v/720", 1280, 720, 2_000_000, 30, "720p", "av01", 9_000),+)++private val SampleAudioStreams = listOf(+ AudioStream("https://a/en", 128_000, "en", "opus", 2_000, displayName = "English"),+ AudioStream("https://a/es", 96_000, "es", "opus", 1_500, displayName = "Spanish"),+)+ /** Stands in for the player surface, which Layoutlib cannot render. */ @Composable private fun PlayerPlaceholder() {
youpipe/src/test/java/com/vayunmathur/youpipe/ui/DialogsPass3Test.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/DialogsPass3Test.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/DialogsPass3Test.ktindex eb8e9036aa..3ff79dedf5 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/DialogsPass3Test.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/DialogsPass3Test.kt@@ -10,6 +10,7 @@ import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.platform.VideoDetailActions+import com.vayunmathur.youpipe.ui.dialogs.DownloadOptionsDialogContent import com.vayunmathur.youpipe.platform.VideoDetailUiState import kotlin.test.Test import kotlin.test.assertEquals@@ -34,6 +35,7 @@ class DialogsPass3Test { var channelOpened = 0 var videoOpened = -1L var downloads = mutableListOf<Pair<String, String?>>()+ var downloadOptionsOpened = 0 var cancels = 0 var deletes = 0 override fun share() { shared++ }@@ -41,6 +43,7 @@ class DialogsPass3Test { override fun openChannel() { channelOpened++ } override fun openVideo(videoID: Long) { videoOpened = videoID } override fun download(videoUrl: String, audioUrl: String?) { downloads += videoUrl to audioUrl }+ override fun openDownloadOptions() { downloadOptionsOpened++ } override fun cancelDownload() { cancels++ } override fun deleteDownload() { deletes++ } }@@ -71,8 +74,15 @@ class DialogsPass3Test { @Test fun downloadDialog_picksStreamsAndDownloads() { val actions = RecordingActions()- rule.setContent { VideoDetails(detailState(), actions) }- rule.onNodeWithContentDescription("Download").performClick()+ val state = detailState()+ rule.setContent {+ DownloadOptionsDialogContent(+ videoStreams = state.videoStreams,+ audioStreams = state.audioStreams,+ onDismiss = {},+ onDownload = { videoUrl, audioUrl -> actions.download(videoUrl, audioUrl) },+ )+ } rule.onNodeWithText(app.getString(R.string.download_options)).assertIsDisplayed() // Quality menu: open and pick the other stream. rule.onNodeWithText("720p", substring = true).performClick()@@ -85,15 +95,33 @@ class DialogsPass3Test { } @Test- fun downloadDialog_cancelDismisses() {+ fun downloadButton_opensOptionsRoute() { val actions = RecordingActions() rule.setContent { VideoDetails(detailState(), actions) } rule.onNodeWithContentDescription("Download").performClick()+ // The button now opens the DownloadOptionsDialog route destination.+ assertEquals(1, actions.downloadOptionsOpened)+ assertTrue(actions.downloads.isEmpty())+ }++ @Test+ fun downloadDialog_cancelDismisses() {+ val actions = RecordingActions()+ var dismissed = false+ val state = detailState()+ rule.setContent {+ DownloadOptionsDialogContent(+ videoStreams = state.videoStreams,+ audioStreams = state.audioStreams,+ onDismiss = { dismissed = true },+ onDownload = { videoUrl, audioUrl -> actions.download(videoUrl, audioUrl) },+ )+ } rule.onNodeWithText(app.getString(R.string.download_options)).assertIsDisplayed() rule.onNodeWithText( app.getString(com.vayunmathur.library.ui.R.string.cancel), ).performClick()- rule.onNodeWithText(app.getString(R.string.download_options)).assertDoesNotExist()+ assertTrue(dismissed) assertTrue(actions.downloads.isEmpty()) }
youpipe/src/test/java/com/vayunmathur/youpipe/ui/SettingsDownloadsPass3Test.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/SettingsDownloadsPass3Test.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/SettingsDownloadsPass3Test.ktindex 1788bc7382..65f00209f2 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/SettingsDownloadsPass3Test.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/SettingsDownloadsPass3Test.kt@@ -147,8 +147,12 @@ class SettingsDownloadsPass3Test { @Test fun dataSettings_clearHistoryConfirmsAndClears() { rule.setContent {- val stack = NavBackStack(arrayOf<Route>(Route.Settings))- DataSettingsPage(stack, vm)+ // Hosted through MainNavigation so the ClearHistoryDialog route renders.+ val stack = NavBackStack(arrayOf<Route>(Route.SettingsData))+ com.vayunmathur.library.util.MainNavigation(stack) {+ settingsEntries(stack, vm)+ dialogEntries(stack, vm)+ } } rule.onNodeWithText(app.getString(R.string.clear_history)).performClick() rule.waitForIdle()
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.ktindex b3f775718a..3c91fa06ee 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt@@ -1,5 +1,7 @@ package com.vayunmathur.youpipe.ui.tv +// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+ import android.app.Application import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule@@ -152,7 +154,8 @@ class TvBrowseDeepTest { assertTrue("UCseed" !in names, names.toString()) } @Test fun tvHistory_clearAllDialogClearsHistory() {- themed { bs -> TvHistoryPage(bs, vm) }+ // Hosted through the real TV navigation so the ClearHistoryDialog route renders.+ rule.setContent { MaTvTheme(TvAccent.Red) { TvNavigation(vm, listOf(TvRoute.History)) } } awaitText("Watched One"); clickText("Clear History") clickText("Clear") val d = System.currentTimeMillis() + 8_000
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.ktindex 1cafffd189..8615195372 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt@@ -1,5 +1,7 @@ package com.vayunmathur.youpipe.ui.tv +// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+ import android.app.Application import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule@@ -99,7 +101,8 @@ class TvPagesDeep2Test { rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Home } } @Test fun dataSettings_clearHistory_emptiesDb() {- themed { _ -> TvDataSettingsPage(vm) }+ // Hosted through the real TV navigation so the ClearHistoryDialog route renders.+ rule.setContent { MaTvTheme(TvAccent.Red) { TvNavigation(vm, listOf(TvRoute.SettingsData)) } } awaitText("Clear History"); clickText("Clear History"); clickText("Clear") awaitDb { runBlocking { db.historyVideoDao().getAll() }.isEmpty() } }
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.ktindex 814a3c1ace..c01e2c27d3 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt@@ -201,7 +201,7 @@ class TvPagesTest { @Test fun tvDataSettings_rendersRows() {- themed { _ -> TvDataSettingsPage(vm) }+ themed { bs -> TvDataSettingsPage(bs, vm) } rule.waitUntil(timeoutMillis = 10_000) { rule.onAllNodes(hasText("Clear", substring = true)).fetchSemanticsNodes().isNotEmpty() }