From 3faa595b76d019ff0cc73ea777b9ce144c22d0c0 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 21 Jun 2026 21:55:30 +0200 Subject: [PATCH] fix(android): track VideoOverlayManager.kt in canonical source tree JellyTauPlayer.kt references com.dtourolle.jellytau.VideoOverlayManager, but the file existed only in the gitignored gen/android dir, so it survived locally but vanished in CI (which regenerates gen/android via 'tauri android init'). sync-android-sources.sh copies top-level *.kt from src-tauri/android, so adding it there gets it synced into the build. Fixes: 'Unresolved reference: VideoOverlayManager' in :app:compileUniversalReleaseKotlin. Co-Authored-By: Claude Opus 4.8 --- .../dtourolle/jellytau/VideoOverlayManager.kt | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src-tauri/android/src/main/java/com/dtourolle/jellytau/VideoOverlayManager.kt diff --git a/src-tauri/android/src/main/java/com/dtourolle/jellytau/VideoOverlayManager.kt b/src-tauri/android/src/main/java/com/dtourolle/jellytau/VideoOverlayManager.kt new file mode 100644 index 0000000..d8e9cb3 --- /dev/null +++ b/src-tauri/android/src/main/java/com/dtourolle/jellytau/VideoOverlayManager.kt @@ -0,0 +1,86 @@ +package com.dtourolle.jellytau + +import android.app.Activity +import android.view.SurfaceView +import android.view.ViewGroup +import android.widget.FrameLayout +import com.dtourolle.jellytau.player.JellyTauPlayer + +/** + * Manages the video SurfaceView overlay in the Activity's view hierarchy. + * + * This class handles attaching and detaching the native ExoPlayer SurfaceView + * so that it renders video content behind the WebView. + */ +object VideoOverlayManager { + + private var attachedSurfaceView: SurfaceView? = null + + /** + * Attach the video SurfaceView to the Activity's content view. + * + * The SurfaceView is added at index 0 (bottom of z-order) so it renders + * behind the Tauri WebView, allowing Svelte controls to overlay on top. + * + * @param activity The Activity to attach the surface to + */ + fun attachVideoSurface(activity: Activity) { + try { + // Get the SurfaceView from JellyTauPlayer + val player = JellyTauPlayer.getInstance() + val surfaceView = player.getSurfaceView() + + if (surfaceView == null) { + android.util.Log.w("VideoOverlayManager", "No SurfaceView available to attach") + return + } + + // Get the root content view + val contentView = activity.window.decorView.findViewById(android.R.id.content) + + // Remove from parent if already attached elsewhere + (surfaceView.parent as? ViewGroup)?.removeView(surfaceView) + + // Configure layout params to fill the screen + val layoutParams = FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT + ) + + // Add to content view at index 0 (behind WebView) + contentView.addView(surfaceView, 0, layoutParams) + attachedSurfaceView = surfaceView + + android.util.Log.d("VideoOverlayManager", "Video surface attached to view hierarchy") + } catch (e: Exception) { + android.util.Log.e("VideoOverlayManager", "Failed to attach video surface", e) + } + } + + /** + * Detach the video SurfaceView from the Activity's view hierarchy. + * + * @param activity The Activity to detach the surface from + */ + fun detachVideoSurface(activity: Activity) { + try { + attachedSurfaceView?.let { surfaceView -> + val contentView = activity.window.decorView.findViewById(android.R.id.content) + contentView.removeView(surfaceView) + attachedSurfaceView = null + android.util.Log.d("VideoOverlayManager", "Video surface detached from view hierarchy") + } + } catch (e: Exception) { + android.util.Log.e("VideoOverlayManager", "Failed to detach video surface", e) + } + } + + /** + * Check if a video surface is currently attached. + * + * @return true if a surface is attached, false otherwise + */ + fun isVideoSurfaceAttached(): Boolean { + return attachedSurfaceView != null + } +}