feat(android): Compose app with bundled yt-dlp, theme pack, nav & progress

Turn android/ into a real Gradle app (Kotlin + Jetpack Compose + Material3)
that bundles an on-device yt-dlp engine and reuses the Phase-4 Rust JNI core.

- Bundled engine: youtubedl-android (Python + yt-dlp + ffmpeg + aria2c) via
  Engine.kt; initialises off the main thread on first launch. Requires legacy
  jniLib packaging so the bundled .zip.so payloads extract to disk.
- Intuitive navigation: bottom NavigationBar — Download / Files / Settings.
- Settings section: dedicated screen with a live theme picker, default-quality
  chips, engine info, and a Rust-core demo.
- All 19 desktop themes ported from src/theme.rs into Theme.kt as Material3
  colour schemes, shown as tappable swatches; selection persisted (Prefs.kt).
- Download screen: live platform detection through the Rust core as you type,
  plus an improved animated determinate progress indicator (%/ETA/status/
  success-error) and a scrollable log.

Toolchain pinned for reproducibility: Gradle 8.9 wrapper, AGP 8.5.2, Kotlin
1.9.24, Compose BOM 2024.06.00, compileSdk 34, minSdk 24, ABIs arm64-v8a +
x86_64. build-apk.sh runs Gradle on a JDK <= 21 (system JDK may break R8) and
builds the Rust libs first.

Verified on an Android 14 x86_64 emulator: installs, launches, engine reports
"yt-dlp ready", Rust .so loads, theme switching re-themes live and persists
across restart, all screens render. (A real YouTube download still depends on
the anti-bot/POT question — Phases 2-3, device-only.)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Luna 2026-07-03 17:03:26 -07:00
parent 1790fd1a22
commit 3a55ff5b8a
22 changed files with 1607 additions and 83 deletions

59
android/build-apk.sh Executable file
View file

@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Build the Catacomb Android app (Compose + bundled yt-dlp + Rust JNI core).
#
# Runs Gradle on a JDK it tolerates (<= 21; the system JDK may be newer and
# breaks R8/d8) and ensures the Rust native libs exist first. Produces a
# debug-signed, installable APK.
#
# Usage: ./build-apk.sh
# Output: app/build/outputs/apk/debug/app-debug.apk
set -euo pipefail
cd "$(dirname "$0")"
# ── JDK for Gradle/AGP (<= 21) ────────────────────────────────────────────
find_jdk() {
if [[ -n "${TOOL_JAVA_HOME:-}" && -x "$TOOL_JAVA_HOME/bin/java" ]]; then
echo "$TOOL_JAVA_HOME"; return
fi
local c
for c in java-17-openjdk java-21-openjdk; do
[[ -x "/usr/lib/jvm/$c/bin/java" ]] && { echo "/usr/lib/jvm/$c"; return; }
done
echo "${JAVA_HOME:-}"
}
export JAVA_HOME="$(find_jdk)"
[[ -x "$JAVA_HOME/bin/java" ]] || { echo "ERROR: need a JDK <= 21 (set TOOL_JAVA_HOME)."; exit 1; }
echo "Using JDK: $JAVA_HOME"
# ── Android SDK location for Gradle ───────────────────────────────────────
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}}"
[[ -d "$SDK" ]] || { echo "ERROR: Android SDK not found (set ANDROID_HOME)."; exit 1; }
if [[ ! -f local.properties ]]; then
echo "sdk.dir=$SDK" > local.properties
fi
# ── Native libs (Rust core) ───────────────────────────────────────────────
if ! ls app/src/main/jniLibs/*/libcatacomb_core.so >/dev/null 2>&1; then
echo "Building Rust core native libs…"
( cd rust/catacomb_core && ./build.sh )
fi
# ── Debug keystore (stable, reproducible signing) ─────────────────────────
if [[ ! -f debug.keystore ]]; then
"$JAVA_HOME/bin/keytool" -genkeypair -keystore debug.keystore \
-alias androiddebugkey -storepass android -keypass android \
-keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=Android Debug,O=Android,C=US" >/dev/null 2>&1
fi
echo "── gradlew assembleDebug ─────────────────────────────────────"
./gradlew --no-daemon assembleDebug "$@"
APK="app/build/outputs/apk/debug/app-debug.apk"
if [[ -f "$APK" ]]; then
echo ""
echo "✓ APK: $(pwd)/$APK ($(du -h "$APK" | cut -f1))"
echo " Install: adb install -r $APK"
else
echo "✗ build finished but $APK not found" >&2; exit 1
fi