App/ytdlp Updates and Sponsor Support
Overview
This area covers the app's automatic/manual update surfaces, yt-dlp binary refresh, and the about-page sponsor and credits support UI.
app/…/UpdateUtil.kt is the shared update backend. For app releases it queries GitHub releases for JunkFood02/Seal, parses release names with String?.toVersion(), filters to stable releases when UPDATE_CHANNEL is STABLE, and compares the selected release with the installed package version from PackageManager. downloadApk() chooses the release asset whose name contains the device's first Build.SUPPORTED_ABIS entry, writes it to context.getExternalFilesDir("apk")/latest.apk, emits DownloadStatus.Progress values while streaming, deletes partial files on failure, and returns DownloadStatus.Finished when the APK is ready. installLatestApk() exposes that APK through the app FileProvider and starts an ACTION_VIEW package-archive intent. deleteOutdatedApk() removes a cached latest.apk whose archive version is not newer than the installed app.
app/…/AppUpdater.kt is the startup/background app-update checker. On first composition it exits unless downloads are allowed by network policy and PreferenceUtil.isAutoUpdateEnabled() is true. If UpdateUtil.checkForUpdate() returns a newer Release, it opens UpdateDialogImpl. Confirming the dialog launches UpdateUtil.downloadApk() on Dispatchers.IO, updates the dialog button with progress, then requests Manifest.permission.REQUEST_INSTALL_PACKAGES. If the runtime permission is denied on Android O+, it sends the user to Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES and retries installLatestApk() when the settings activity returns.
app/…/UpdatePage.kt is the manual update/settings route exposed from About. It owns the AUTO_UPDATE toggle, UPDATE_CHANNEL stable/prerelease selection, and a "check for updates" button. The button calls UpdateUtil.checkForUpdate() directly, shows UpdateDialog when a release is available, and shows a toast when the app is current or update checking fails. F-Droid builds start this page with AutoUpdateUnavailableDialog from AboutPage.kt, then navigate back after dismissal.
app/…/UpdateDialog.kt contains two app-update dialog entry points. UpdateDialogImpl is the pure UI used by both automatic and manual update flows: it displays release notes, prevents duplicate confirm actions while DownloadStatus.Progress is active, and renders the confirm button as either update or a percent. UpdateDialog wraps it for the manual page and downloads/installs with UpdateUtil.downloadApk() and UpdateUtil.installLatestApk(); unlike AppUpdater.kt, it does not include the unknown-sources permission/settings launcher.
app/…/YtdlpUpdater.kt is the automatic yt-dlp updater. It runs only while Downloader.downloaderState is idle, skips when auto-update is disabled and a yt-dlp version is already recorded, respects PreferenceUtil.isNetworkAvailableForDownload(), and throttles by YT_DLP_UPDATE_TIME + YT_DLP_UPDATE_INTERVAL. When eligible it sets Downloader.State.Updating, calls UpdateUtil.updateYtDlp(), then returns the downloader to idle. UpdateUtil.updateYtDlp() maps YT_DLP_UPDATE_CHANNEL to YoutubeDL.UpdateChannel.STABLE or NIGHTLY, calls YoutubeDL.getInstance().updateYoutubeDL(), stores the new YT_DLP_VERSION when the library reports DONE, and always records the latest attempt time in YT_DLP_UPDATE_TIME.
app/…/AboutPage.kt is the path-routing hub for this feature group. It links out to the repository and releases URL, routes Sponsor to onNavigateToDonatePage(), Credits to onNavigateToCreditsPage(), and Auto Update to onNavigateToUpdatePage() while also letting the switch mutate AUTO_UPDATE inline. It copies App.getVersionReport() and the package name to the clipboard from the version/package rows. Keep navigation changes in the host router aligned with these callback names: the about screen itself does not know concrete route strings.
Sponsor data is defined in app/…/SponsorData.kt to match the GitHub GraphQL response shape: SponsorData.data.viewer.sponsorshipsAsMaintainer.nodes contains SponsorShip entries with a SponsorEntity, optional Tier, and optional social links. app/…/SponsorUtil.kt builds a GitHub GraphQL request for the viewer's first 100 maintainer sponsorships, authorizes with a base64-assembled token string, decodes with Json { ignoreUnknownKeys = true }, logs the raw body, and caches the decoded SponsorData in memory for later calls.
app/…/SponsorPage.kt renders the sponsor route. On first composition it resets SHOW_SPONSOR_MSG, loads sponsors on Dispatchers.IO, then splits them by tier.monthlyPriceInDollars: 5-9 as "Sponsors", 10-24 as "Backers", and 25+ as "Supporters". Each group is shown in a 12-column LazyVerticalGrid with different spans, using app/…/SponsorItem.kt for avatar/name/login cards. Clicking a card opens SponsorDialog, which shows the GitHub avatar, tier label, website fallback to the GitHub profile, and social links; link clicks try LocalUriHandler.openUri() and copy the URL to the clipboard with a toast if opening fails. The page also contains the developer message and a direct https://github.com/sponsors/JunkFood02 button.
app/…/CreditsPage.kt is a static about subpage listing upstream projects and licenses, including yt-dlp and youtubedl-android. It only routes out through LocalUriHandler and does not share state with the update or sponsor flows.
Coupling
- If app release asset names change, update
UpdateUtil.downloadApk()in app/…/UpdateUtil.kt: it selects an APK solely by checking whetherAssetsItem.namecontainsBuild.SUPPORTED_ABIS.first(), so release packaging and ABI names must stay aligned. - If version tag formats change, update
UpdateUtil.toVersion()and both release channels in app/…/UpdateUtil.kt: app update eligibility, stable/prerelease filtering, cached APK reuse, anddeleteOutdatedApk()all rely on the samev?major.minor.patch[-alpha|beta|rc.N]parser. - If install-permission behavior changes, check both app/…/AppUpdater.kt and app/…/UpdateDialog.kt: the automatic flow includes the permission/settings launcher, while the manual
UpdateDialogwrapper callsinstallLatestApk()after download without that fallback. - If about-page route names or destinations change, update the host navigation to keep AboutPage.kt callbacks mapped correctly: sponsor, credits, and update are exposed as
onNavigateToDonatePage,onNavigateToCreditsPage, andonNavigateToUpdatePage, not as route constants inside the about module. - If the GitHub Sponsors GraphQL query changes in app/…/SponsorUtil.kt, update the serializable response model in app/…/SponsorData.kt and the consumers in SponsorPage.kt; the page directly traverses
data.viewer.sponsorshipsAsMaintainer.nodesand expectstier.monthlyPriceInDollars,sponsorEntity.login, optionalwebsiteUrl, and optional social-account URLs. - If sponsor tier thresholds or labels change in app/…/SponsorPage.kt, change both the list partitioning and
SponsorDialoglabel mapping together; otherwise a card can appear under one section but show a different tier label in the bottom sheet.
Risks
- app/…/SponsorUtil.kt embeds an authorization token assembled from base64 constants and logs the raw GraphQL response. If the token is revoked, rate-limited, or abused,
SponsorsPagesilently renders only the developer message; if the response includes unexpected private data, the raw body is written to logcat. - app/…/YtdlpUpdater.kt updates
Downloader.StatearoundUpdateUtil.updateYtDlp()from a composable side effect. If another download state transition occurs while the update is running, the unconditional finalDownloader.updateState(Idle)can mask that newer state. - app/…/SponsorPage.kt maps social URLs with
it.url.toString(). If GitHub returns a social account node with a null URL, the dialog displays and attempts to open the literal string"null".