Introducing a new way to review your PRs.

Read the announcement

junkfood02 / seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

View on GitHub

13 documents · Updated Nov 16, 2026

docs / legacy-download-ui-flow

Legacy download UI flow

Overview

The legacy/original download page is rooted at app/…/DownloadPage.kt. DownloadPage composes the home screen, collects state from the shared singleton downloader (Downloader.downloaderState, Downloader.taskState, Downloader.errorState, Downloader.processCount, and Downloader.playlistResult), and collects local page state from HomePageViewModel.viewStateFlow and HomePageViewModel.videoInfoFlow. The visible page is rendered by DownloadPageImpl: a top app bar routes to settings, downloads history, and running tasks; the main body shows the app title, current download/playlist progress, the URL field, optional VideoCard progress, terminal output when debug output is enabled, and an expandable/copyable error report.

URL input state lives in HomePageViewModel.ViewState.url (HomePageViewModel.kt). The paste FAB in DownloadPage.kt reads the clipboard, passes it through matchUrlFromClipboard, and writes the result with HomePageViewModel.updateUrl. The URL text field writes every edit back through the same method. Shared intents are represented by ViewState.isUrlSharingTriggered; when DownloadPage sees it, it calls HomePageViewModel.onShareIntentConsumed() and then runs the legacy download callback.

There are two download-start paths in DownloadPage.kt:

  • Normal page interaction (DownloadPageImpl.downloadCallback) posts DownloadDialogViewModel.Action.ShowSheet() to the newer downloadv2.configure.DownloadDialog flow. The bottom sheet is shown from dialogViewModel.sheetValueFlow; its preferences are initialized from DownloadUtil.DownloadPreferences.createFromPreferences(), and format-selection state may show downloadv2.configure.FormatPage.
  • The legacy callback, still used for shared URLs, first handles notification permission prompts, then either opens DownloadSettingDialog when CONFIGURE is enabled or proceeds through storage/network checks before calling HomePageViewModel.startDownloadVideo().

HomePageViewModel.startDownloadVideo() (HomePageViewModel.kt) is the legacy orchestrator for actual work. It clears downloader errors, optionally executes a custom command with DownloadUtil.executeCommandInBackground, checks downloader availability, validates that the URL is not blank, and then branches by preferences: PLAYLIST fetches playlist/video metadata via DownloadUtil.getPlaylistOrVideoInfo, FORMAT_SELECTION fetches video metadata via DownloadUtil.fetchVideoInfoFromUrl, and the default path calls Downloader.getInfoAndDownload(url). Playlist metadata is written to the shared downloader via Downloader.updatePlaylistResult; format metadata is written to videoInfoFlow.

Routing out of this package is controlled by callbacks supplied to DownloadPage. navigateToSettings, navigateToDownloads, and onNavigateToTaskList are top-bar actions. navigateToPlaylistPage is triggered by a DisposableEffect when ViewState.showPlaylistSelectionDialog is true and Downloader.playlistResult.entries is non-empty; disposal calls HomePageViewModel.hidePlaylistDialog(). navigateToFormatPage is triggered similarly when ViewState.showFormatSelectionPage is true and videoInfoFlow.formats is non-empty; disposal calls hideFormatPage(). onNavigateToCookieGeneratorPage is passed into DownloadSettingDialog and is invoked when a cookie profile is selected from its cookies quick settings.

Dialogs in this package are mostly small state gates around preferences and permissions:

  • DownloadSettingsDialog.kt exposes DownloadSettingDialog, the legacy “settings before download” surface. It chooses an AlertDialog on wider windows (useDialog) or a modal bottom sheet on compact screens, falling back to the Material 2 sheet on Android versions below 30. It mutates shared preferences such as EXTRACT_AUDIO, CUSTOM_COMMAND, PLAYLIST, FORMAT_SELECTION, VIDEO_FORMAT, VIDEO_QUALITY, COOKIES, SUBTITLE, THUMBNAIL, FORMAT_SORTING, and command template IDs, then calls onDownloadConfirm to resume permission/network checks. It also opens nested settings dialogs for video format, quality, cookies, audio conversion, format sorting, and command templates.
  • NotificationPermissionDialog.kt is shown on Android 13+ when notifications are enabled in preferences but POST_NOTIFICATIONS is not granted. Dismissing it disables the NOTIFICATION preference; confirming launches the permission request.
  • MeteredNetworkDialog.kt is shown when PreferenceUtil.isNetworkAvailableForDownload() rejects the current network. “Allow once” calls HomePageViewModel.startDownloadVideo(). “Allow always” also sets CELLULAR_DOWNLOAD true.
  • PlaylistSelectionDialog.kt is a legacy range picker for a PlaylistResult. It validates numeric from/to inputs against the playlist entry count and returns an IntRange on confirm. The current DownloadPage.kt routes playlist selection to navigateToPlaylistPage instead of rendering this dialog directly.
  • VideoSectionSlider.kt contains the video clip selection UI: VideoSelectionSlider wraps a Material RangeSliderState, displays the selected start/end as duration text, and offers discard/edit actions; VideoClipDialog edits the same range with minute/second fields and validates that start < end within the supplied duration range.

Coupling

  • If HomePageViewModel.ViewState flags change in app/…/HomePageViewModel.kt, update the DisposableEffect routing in app/…/DownloadPage.kt. The page relies on showPlaylistSelectionDialog and showFormatSelectionPage being one-shot navigation signals that are cleared on disposal.
  • If playlist or format routing changes, verify both the shared downloader state and page-local state: DownloadPage.kt reads playlist entries from Downloader.playlistResult, while format routing reads HomePageViewModel.videoInfoFlow.formats.
  • If download preference keys or meanings change, update both HomePageViewModel.kt and DownloadSettingsDialog.kt. The dialog mutates preferences such as PLAYLIST, CUSTOM_COMMAND, and FORMAT_SELECTION, while the view model branches on those same preferences to choose the downloader path.
  • If notification, storage, or metered-network behavior changes in DownloadPage.kt, verify the legacy shared-intent path as well as the normal DownloadDialogViewModel.Action.ShowSheet() path. They do not currently enter the same start-download code.
  • If video clipping range semantics change, update both VideoSelectionSlider and VideoClipDialog in app/…/VideoSectionSlider.kt; one uses RangeSliderState floats and the other converts minute/second text to integer seconds.

Risks

  • app/…/DownloadPage.kt has parallel start flows: normal FAB/keyboard interaction opens the newer download dialog, while shared intents use the legacy permission/configuration callback. If a permission, cellular, or configuration fix is applied to only one path, shared URLs and manually entered URLs can behave differently.
  • app/…/DownloadSettingsDialog.kt writes global preferences immediately when chips are tapped, before the user presses “start download.” If the user cancels, changed preferences remain and can affect the next download.