Add PiP for native (ExoPlayer) video on Android. Video renders into a SurfaceView behind the WebView, so PiP is driven by the Activity shrinking into a floating window rather than the HTML5 PiP API (which WebKitGTK does not implement, hence Android-only). - PictureInPictureManager.kt: enter PiP with the video's aspect ratio (clamped to the 1:2.39-2.39:1 range Android accepts, outside which it throws), plus a play/pause RemoteAction. Hides the WebView while in PiP - it is opaque and sits above the surface, so it would otherwise occlude the video entirely - and re-fits the surface on exit. - MainActivity.kt: onUserLeaveHint auto-PiP, onPictureInPictureModeChanged, and an AndroidPictureInPicture JS interface following the existing AndroidAudioFocus pattern. - pictureInPicture.ts + VideoPlayer.svelte: PiP button, rendered only when the native bridge reports support. - proguard: keep rules for @JavascriptInterface methods, which are only referenced from JS and would be stripped in minified release builds. Casting needs no special handling: canEnterPip() checks natively that a local video surface is attached and playing, which a remote session lacks. While wiring the manifest, found that three tracked files under src-tauri/android/ were never reaching any build. Gradle reads only gen/android/app/src/main/, and sync-android-sources.sh did not copy them: - src/main/AndroidManifest.xml was a partial <application> fragment written as if Tauri merged it. It does not - there is no manifest-merger hook here, so its hardwareAccelerated flag never reached an APK. Promoted to the complete authoritative manifest (folding in that flag) and synced. - src/main/res/values/themes.xml (transparent status bar, fitsSystemWindows) was never copied; the sync only globbed mipmap-*. Now synced. - build.gradle.kts was a leftover com.android.library module config with stale media3 1.5.1 deps. The live deps are in app/build.gradle.kts at 1.5.0. Deleted. Verified: merged manifest now carries hardwareAccelerated, supportsPictureInPicture, resizeableActivity and the density configChange; themes.xml compiles into merged resources; Kotlin builds warning-free; svelte-check clean; 537 frontend tests pass. Not verified: PiP behaviour on a device, and the release keep rules against a minified build. assembleUniversalDebug cannot complete in this environment - the Rust step wants a dev-server addr file that only exists under `tauri android dev`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
112 lines
4.9 KiB
Bash
Executable File
112 lines
4.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sync Android source files from src-tauri/android to src-tauri/gen/android
|
|
# This ensures the generated build directory has the latest source files
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
SOURCE_DIR="$PROJECT_ROOT/src-tauri/android/src/main/java/com/dtourolle/jellytau"
|
|
TARGET_DIR="$PROJECT_ROOT/src-tauri/gen/android/app/src/main/java/com/dtourolle/jellytau"
|
|
|
|
echo "Syncing Android sources..."
|
|
echo " From: $SOURCE_DIR"
|
|
echo " To: $TARGET_DIR"
|
|
|
|
# Create target directory if it doesn't exist
|
|
mkdir -p "$TARGET_DIR"
|
|
|
|
# Remove old copies of player and security directories
|
|
rm -rf "$TARGET_DIR/player" "$TARGET_DIR/security"
|
|
|
|
# Copy the directories
|
|
cp -r "$SOURCE_DIR/player" "$TARGET_DIR/"
|
|
cp -r "$SOURCE_DIR/security" "$TARGET_DIR/"
|
|
|
|
# Copy individual Kotlin files (like VideoOverlayManager.kt)
|
|
for kt_file in "$SOURCE_DIR"/*.kt; do
|
|
if [ -f "$kt_file" ]; then
|
|
cp "$kt_file" "$TARGET_DIR/"
|
|
echo " Copied: $(basename "$kt_file")"
|
|
fi
|
|
done
|
|
|
|
# Restore the app module build.gradle.kts (media3 deps + release signing config).
|
|
# gen/android is regenerated by `tauri android init`, so this tracked template is
|
|
# the source of truth and must be copied back after any (re)generation.
|
|
APP_GRADLE_SRC="$PROJECT_ROOT/src-tauri/android/app/build.gradle.kts"
|
|
APP_GRADLE_DST="$PROJECT_ROOT/src-tauri/gen/android/app/build.gradle.kts"
|
|
if [ -f "$APP_GRADLE_SRC" ]; then
|
|
cp "$APP_GRADLE_SRC" "$APP_GRADLE_DST"
|
|
echo " Copied: app/build.gradle.kts"
|
|
fi
|
|
|
|
# AndroidManifest.xml. `tauri android init` regenerates gen/android from
|
|
# tauri.conf.json and would drop our hand-maintained entries (media playback
|
|
# service + permissions, hardware acceleration, picture-in-picture attributes
|
|
# on MainActivity), so this tracked copy is the source of truth and must be
|
|
# restored after a regen. Gradle reads ONLY the gen/ copy - there is no
|
|
# manifest-merger hook here, so this must be the complete manifest.
|
|
MANIFEST_SRC="$PROJECT_ROOT/src-tauri/android/src/main/AndroidManifest.xml"
|
|
MANIFEST_DST="$PROJECT_ROOT/src-tauri/gen/android/app/src/main/AndroidManifest.xml"
|
|
if [ -f "$MANIFEST_SRC" ]; then
|
|
cp "$MANIFEST_SRC" "$MANIFEST_DST"
|
|
echo " Copied: app/src/main/AndroidManifest.xml"
|
|
fi
|
|
|
|
# Custom ProGuard/R8 keep rules. Required for minified release builds:
|
|
# the player/ and security/ Kotlin classes are loaded by name via JNI from
|
|
# Rust, so R8 can't see the references and would strip them without this.
|
|
# build.gradle.kts globs **/*.pro, so dropping it in app/ is enough.
|
|
PROGUARD_SRC="$PROJECT_ROOT/src-tauri/android/app/proguard-jellytau.pro"
|
|
PROGUARD_DST="$PROJECT_ROOT/src-tauri/gen/android/app/proguard-jellytau.pro"
|
|
if [ -f "$PROGUARD_SRC" ]; then
|
|
cp "$PROGUARD_SRC" "$PROGUARD_DST"
|
|
echo " Copied: app/proguard-jellytau.pro"
|
|
fi
|
|
|
|
# Launcher icons / adaptive-icon mipmaps. `tauri android init` generates
|
|
# low-quality launcher icons from tauri.conf.json (which has no high-res
|
|
# Android source), so overwrite them with the real committed mipmaps.
|
|
RES_SRC="$PROJECT_ROOT/src-tauri/android/src/main/res"
|
|
RES_DST="$PROJECT_ROOT/src-tauri/gen/android/app/src/main/res"
|
|
if [ -d "$RES_SRC" ]; then
|
|
for dir in "$RES_SRC"/mipmap-*; do
|
|
[ -d "$dir" ] || continue
|
|
name="$(basename "$dir")"
|
|
mkdir -p "$RES_DST/$name"
|
|
cp "$dir"/* "$RES_DST/$name/"
|
|
echo " Copied res: $name"
|
|
done
|
|
|
|
# values/ (themes.xml): status-bar styling that `tauri android init` does
|
|
# not generate. Previously this directory was tracked but never copied, so
|
|
# the theme customizations below never reached a build.
|
|
if [ -d "$RES_SRC/values" ]; then
|
|
mkdir -p "$RES_DST/values"
|
|
cp "$RES_SRC"/values/*.xml "$RES_DST/values/"
|
|
echo " Copied res: values"
|
|
fi
|
|
# We ship only the color adaptive icon (background + foreground). Drop any
|
|
# monochrome layer Tauri may generate: the themed-icon monochrome doesn't
|
|
# render well, and our adaptive-icon xml no longer references it, so a stray
|
|
# ic_launcher_monochrome.png would just be dead weight.
|
|
rm -f "$RES_DST"/mipmap-*/ic_launcher_monochrome.png
|
|
|
|
# `tauri android init` also emits the Android Studio DEFAULT adaptive icon
|
|
# as API-qualified VECTOR drawables:
|
|
# drawable/ic_launcher_background.xml (solid #3DDC84 green)
|
|
# drawable-v24/ic_launcher_foreground.xml (the Android robot)
|
|
# Because drawable-v24 is a more specific match than our unqualified
|
|
# mipmap-*/ic_launcher_*.png, on API 24+ the vector WINS and the app ships
|
|
# the green square robot instead of our jellyfish. Remove them so the
|
|
# adaptive-icon xml resolves @mipmap/ic_launcher_{background,foreground}
|
|
# to the real committed PNGs.
|
|
rm -f "$RES_DST"/drawable/ic_launcher_background.xml \
|
|
"$RES_DST"/drawable-v24/ic_launcher_foreground.xml \
|
|
"$RES_DST"/drawable*/ic_launcher_foreground.xml \
|
|
"$RES_DST"/drawable*/ic_launcher_background.xml
|
|
fi
|
|
|
|
echo "✓ Android sources synced successfully"
|