android-plan.md
155 lines · 7427 bytes
1# Android / Termux Support for Curd
2
3## Summary
4Add 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.
5
6Target outcome:
7- Android users run `curd` inside Termux with a mobile-tuned TUI.
8- Playback opens in a user-selected Android mpv app or mpv fork package.
9- Full watch-flow features are supported only when that player path exposes MPV-compatible IPC/control.
10- Desktop config stays clean; Android gets its own config file and only Android-relevant options.
11
12## Implementation Changes
13- Add platform detection in startup:
14 - Detect Termux/Android from `runtime.GOOS == "android"` or Termux env markers.
15 - Default config path on Android to `~/.config/curd/android.conf`.
16 - Keep desktop default as `~/.config/curd/curd.conf`.
17 - Add `--config` so either platform can override explicitly.
18
19- Split config into shared core plus Android-only schema:
20 - Keep shared fields such as `SubOrDub`, `SubsLanguage`, `PercentageToMarkComplete`, `NextEpisodePrompt`, `SkipOp`, `SkipEd`, `SkipFiller`, `SkipRecap`, `ScoreOnCompletion`, `SaveMpvSpeed`, `AnimeNameLanguage`, `MenuOrder`.
21 - Remove desktop-only Android noise from desktop config and vice versa by generating different defaults per platform.
22 - Android config should add:
23 - `AndroidPlayerPackage`
24 - `AndroidPlayerActivity`
25 - `AndroidPlayerMode` with `ipc` or `intent`
26 - `AndroidPlayerIntentAction`
27 - `AndroidUseTermuxAPI`
28 - `AndroidOpenLinksWith`
29 - `AndroidNotifications`
30 - `AndroidWakeLock`
31 - `AndroidExtraIntentArgs`
32 - Android defaults:
33 - `RofiSelection=false`
34 - `ImagePreview=false`
35 - `DiscordPresence=false`
36 - `AlternateScreen=false`
37
38- Introduce a playback backend abstraction:
39 - Replace direct desktop assumptions in `internal/player.go` with a `PlayerBackend` interface.
40 - Desktop backend keeps current MPV IPC behavior.
41 - Android backend supports two modes:
42 - `ipc`: required for full Android feature parity; launches the selected mpv/mpv fork with a known socket path or equivalent control bridge.
43 - `intent`: basic fallback; launches player by Android intent only, with no reliable progress/control.
44 - Do not promise full features in `intent` mode.
45
46- Android player launch design:
47 - Launch via `am start` using user-configured package/activity, not hardcoded `is.xyz.mpv/.MPVActivity`.
48 - Support official mpv-android and mpvEx by config, not by special-casing brand names.
49 - Add a player capability check during `curd --android-setup`:
50 - Validate package/activity exists.
51 - Validate whether IPC/control is available.
52 - Write detected capability into Android config.
53
54- Preserve core watch-flow features in Android `ipc` mode:
55 - Resume from saved position.
56 - Track playback time and duration.
57 - Auto update AniList progress.
58 - Auto continue to next episode on completion.
59 - Skip OP/ED through AniSkip.
60 - Skip filler and recap episodes.
61 - Save playback speed.
62 - Prompt for rating on completion.
63 - Sequel prompt / list updates.
64 - Continue last episode.
65 - Local history.
66
67- Android UI changes:
68 - Keep Bubble Tea terminal UI, but add an Android/mobile presentation mode:
69 - larger list rows
70 - explicit footer shortcuts
71 - back behavior mapped cleanly
72 - no alternate-screen dependency
73 - search-first flow with visible quick actions
74 - Do not use rofi or image preview on Android.
75 - Use Termux API optionally for:
76 - `termux-open-url` for AniList auth and sequel pages
77 - `termux-notification` / `termux-toast` for prompts and status
78 - `termux-wake-lock` during active playback sessions if enabled
79
80- Android auth and update flow:
81 - On Android, prefer `termux-open-url` or Android intent for AniList OAuth instead of generic browser open.
82 - Keep localhost callback flow if reachable; retain manual token fallback.
83 - Extend `-u` / updater logic in `internal/curd.go` to support an Android release artifact plus a Termux install/update wrapper.
84 - First release should support both:
85 - direct GitHub Android binary
86 - Termux bootstrap/update script that downloads the correct Android asset
87
88## Feature Reality
89Features we can support well on Android in `ipc` mode: 12+
90- streaming playback
91- mobile-tuned TUI selection/search
92- continue last
93- local resume/history
94- AniList tracking/progress updates
95- next episode on completion
96- skip OP
97- skip ED
98- skip filler
99- skip recap
100- save speed
101- score-on-completion and sequel prompts
102- configurable player package and Android-specific settings
103- self-update/install flow
104
105Features that are possible but conditional:
106- opening in mpvEx or another fork only if the selected package/activity can be launched reliably and exposes MPV-compatible control
107- notifications and wake-locks only when `termux-api` is installed
108- seamless same-session player reuse only if Android player integration supports IPC commands like `loadfile`
109
110Features that should be treated as unsupported on Android:
111- Discord Rich Presence
112- rofi UI
113- rofi image preview / ueberzug flow
114- full playback control against arbitrary external players that only accept a `VIEW` intent
115- guaranteed progress/completion detection if the user picks a player with no IPC/control channel
116- desktop-style “one live mpv window” semantics if the Android player does not support file replacement over IPC
117
118## Public Interfaces / CLI Changes
119- Add `--config <path>`.
120- Add `--android-setup` to:
121 - detect Termux API tools
122 - probe configured player package/activity
123 - verify IPC capability
124 - create `android.conf`
125- Keep existing flags, but on Android ignore or hide desktop-only ones in generated config and help text.
126- Update config loader in `internal/config.go` to generate platform-specific defaults and missing keys from the active schema, not one global desktop schema.
127
128## Test Plan
129- Config tests:
130 - Android auto-selects `android.conf`.
131 - Desktop still uses `curd.conf`.
132 - Android config generation excludes desktop-only options.
133 - Desktop config generation excludes Android-only options.
134
135- Backend tests:
136 - desktop backend still resolves and controls mpv
137 - Android intent backend builds correct `am start` command from config
138 - Android IPC backend reports unsupported when capability probe fails
139
140- Watch-flow tests:
141 - completed episode advances progress and local history in Android IPC mode
142 - next episode starts automatically after threshold
143 - skip OP/ED seeks are issued through Android IPC backend
144 - fallback intent mode disables completion-dependent automation cleanly instead of silently failing
145
146- UX tests:
147 - Termux TUI works without alternate screen
148 - back/quit/search flows are usable on narrow terminal widths
149 - `--android-setup` produces actionable errors when `termux-api` or player integration is missing
150
151## Assumptions
152- Android target is Termux on ARM64.
153- “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.
154- mpvEx support should be implemented as configurable package/activity targeting, not as a hardcoded special case.
155- If no reliable IPC/control path exists for a chosen player, `curd` must downgrade explicitly to basic launch mode and tell the user which features are unavailable.