android-plan.md
155 lines · 7427 bytes
Android / Termux Support for Curd
Summary
Add a dedicated Android-on-Termux mode that keeps curd terminal-first, uses a separate Android config schema, and introduces an Android playback backend instead of assuming desktop mpv process control.
Target outcome:
- Android users run
curdinside Termux with a mobile-tuned TUI. - Playback opens in a user-selected Android mpv app or mpv fork package.
- Full watch-flow features are supported only when that player path exposes MPV-compatible IPC/control.
- Desktop config stays clean; Android gets its own config file and only Android-relevant options.
Implementation Changes
-
Add platform detection in startup:
- Detect Termux/Android from
runtime.GOOS == "android"or Termux env markers. - Default config path on Android to
~/.config/curd/android.conf. - Keep desktop default as
~/.config/curd/curd.conf. - Add
--configso either platform can override explicitly.
- Detect Termux/Android from
-
Split config into shared core plus Android-only schema:
- Keep shared fields such as
SubOrDub,SubsLanguage,PercentageToMarkComplete,NextEpisodePrompt,SkipOp,SkipEd,SkipFiller,SkipRecap,ScoreOnCompletion,SaveMpvSpeed,AnimeNameLanguage,MenuOrder. - Remove desktop-only Android noise from desktop config and vice versa by generating different defaults per platform.
- Android config should add:
AndroidPlayerPackageAndroidPlayerActivityAndroidPlayerModewithipcorintentAndroidPlayerIntentActionAndroidUseTermuxAPIAndroidOpenLinksWithAndroidNotificationsAndroidWakeLockAndroidExtraIntentArgs
- Android defaults:
RofiSelection=falseImagePreview=falseDiscordPresence=falseAlternateScreen=false
- Keep shared fields such as
-
Introduce a playback backend abstraction:
- Replace direct desktop assumptions in
internal/player.gowith aPlayerBackendinterface. - Desktop backend keeps current MPV IPC behavior.
- Android backend supports two modes:
ipc: required for full Android feature parity; launches the selected mpv/mpv fork with a known socket path or equivalent control bridge.intent: basic fallback; launches player by Android intent only, with no reliable progress/control.
- Do not promise full features in
intentmode.
- Replace direct desktop assumptions in
-
Android player launch design:
- Launch via
am startusing user-configured package/activity, not hardcodedis.xyz.mpv/.MPVActivity. - Support official mpv-android and mpvEx by config, not by special-casing brand names.
- Add a player capability check during
curd --android-setup:- Validate package/activity exists.
- Validate whether IPC/control is available.
- Write detected capability into Android config.
- Launch via
-
Preserve core watch-flow features in Android
ipcmode:- Resume from saved position.
- Track playback time and duration.
- Auto update AniList progress.
- Auto continue to next episode on completion.
- Skip OP/ED through AniSkip.
- Skip filler and recap episodes.
- Save playback speed.
- Prompt for rating on completion.
- Sequel prompt / list updates.
- Continue last episode.
- Local history.
-
Android UI changes:
- Keep Bubble Tea terminal UI, but add an Android/mobile presentation mode:
- larger list rows
- explicit footer shortcuts
- back behavior mapped cleanly
- no alternate-screen dependency
- search-first flow with visible quick actions
- Do not use rofi or image preview on Android.
- Use Termux API optionally for:
termux-open-urlfor AniList auth and sequel pagestermux-notification/termux-toastfor prompts and statustermux-wake-lockduring active playback sessions if enabled
- Keep Bubble Tea terminal UI, but add an Android/mobile presentation mode:
-
Android auth and update flow:
- On Android, prefer
termux-open-urlor Android intent for AniList OAuth instead of generic browser open. - Keep localhost callback flow if reachable; retain manual token fallback.
- Extend
-u/ updater logic ininternal/curd.goto support an Android release artifact plus a Termux install/update wrapper. - First release should support both:
- direct GitHub Android binary
- Termux bootstrap/update script that downloads the correct Android asset
- On Android, prefer
Feature Reality
Features we can support well on Android in ipc mode: 12+
- streaming playback
- mobile-tuned TUI selection/search
- continue last
- local resume/history
- AniList tracking/progress updates
- next episode on completion
- skip OP
- skip ED
- skip filler
- skip recap
- save speed
- score-on-completion and sequel prompts
- configurable player package and Android-specific settings
- self-update/install flow
Features that are possible but conditional:
- opening in mpvEx or another fork only if the selected package/activity can be launched reliably and exposes MPV-compatible control
- notifications and wake-locks only when
termux-apiis installed - seamless same-session player reuse only if Android player integration supports IPC commands like
loadfile
Features that should be treated as unsupported on Android:
- Discord Rich Presence
- rofi UI
- rofi image preview / ueberzug flow
- full playback control against arbitrary external players that only accept a
VIEWintent - guaranteed progress/completion detection if the user picks a player with no IPC/control channel
- desktop-style “one live mpv window” semantics if the Android player does not support file replacement over IPC
Public Interfaces / CLI Changes
- Add
--config <path>. - Add
--android-setupto:- detect Termux API tools
- probe configured player package/activity
- verify IPC capability
- create
android.conf
- Keep existing flags, but on Android ignore or hide desktop-only ones in generated config and help text.
- Update config loader in
internal/config.goto generate platform-specific defaults and missing keys from the active schema, not one global desktop schema.
Test Plan
-
Config tests:
- Android auto-selects
android.conf. - Desktop still uses
curd.conf. - Android config generation excludes desktop-only options.
- Desktop config generation excludes Android-only options.
- Android auto-selects
-
Backend tests:
- desktop backend still resolves and controls mpv
- Android intent backend builds correct
am startcommand from config - Android IPC backend reports unsupported when capability probe fails
-
Watch-flow tests:
- completed episode advances progress and local history in Android IPC mode
- next episode starts automatically after threshold
- skip OP/ED seeks are issued through Android IPC backend
- fallback intent mode disables completion-dependent automation cleanly instead of silently failing
-
UX tests:
- Termux TUI works without alternate screen
- back/quit/search flows are usable on narrow terminal widths
--android-setupproduces actionable errors whentermux-apior player integration is missing
Assumptions
- Android target is Termux on ARM64.
- “All desktop features on Android” is only a valid goal when the chosen Android mpv path exposes MPV-compatible IPC or an equivalent control bridge.
- mpvEx support should be implemented as configurable package/activity targeting, not as a hardcoded special case.
- If no reliable IPC/control path exists for a chosen player,
curdmust downgrade explicitly to basic launch mode and tell the user which features are unavailable.