From 44e0d8d6b392c4c9e4b809e14c89eca7a18404ad Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 20 Dec 2024 15:45:52 +0000 Subject: [PATCH] patch bluesky-video to handle insets --- patches/@haileyok+bluesky-video+0.2.4.patch | 113 ++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 patches/@haileyok+bluesky-video+0.2.4.patch diff --git a/patches/@haileyok+bluesky-video+0.2.4.patch b/patches/@haileyok+bluesky-video+0.2.4.patch new file mode 100644 index 0000000000..a8dc6a181a --- /dev/null +++ b/patches/@haileyok+bluesky-video+0.2.4.patch @@ -0,0 +1,113 @@ +diff --git a/node_modules/@haileyok/bluesky-video/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt b/node_modules/@haileyok/bluesky-video/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt +index d4f83cc..a7b1d16 100644 +--- a/node_modules/@haileyok/bluesky-video/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt ++++ b/node_modules/@haileyok/bluesky-video/android/src/main/java/expo/modules/blueskyvideo/FullscreenActivity.kt +@@ -1,8 +1,12 @@ + package expo.modules.blueskyvideo + + import android.graphics.Color ++import android.os.Build + import android.os.Bundle ++import android.view.View + import android.view.ViewGroup ++import android.view.WindowInsets ++import android.view.WindowInsetsController + import android.view.WindowManager + import androidx.appcompat.app.AppCompatActivity + import androidx.media3.common.util.UnstableApi +@@ -25,37 +29,54 @@ class FullscreenActivity : AppCompatActivity() { + return + } + +- this.window.setFlags( +- WindowManager.LayoutParams.FLAG_FULLSCREEN, +- WindowManager.LayoutParams.FLAG_FULLSCREEN, +- ) +- +- val keepDisplayOn = this.getIntent().getBooleanExtra("keepDisplayOn", false) ++ // Enable full-screen mode for older Android versions while avoiding double insets ++ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { ++ @Suppress("DEPRECATION") ++ window.decorView.systemUiVisibility = ( ++ View.SYSTEM_UI_FLAG_LAYOUT_STABLE ++ or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION ++ or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN ++ ) ++ } else { ++ window.setDecorFitsSystemWindows(false) ++ } + ++ // Keep screen on if requested ++ val keepDisplayOn = this.intent.getBooleanExtra("keepDisplayOn", false) + if (keepDisplayOn) { +- this.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) ++ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } + +- // Update the player viewz +- val playerView = +- PlayerView(this).apply { +- setBackgroundColor(Color.BLACK) +- setShowSubtitleButton(true) +- setShowNextButton(false) +- setShowPreviousButton(false) +- setFullscreenButtonClickListener { +- finish() +- } ++ // Update the player view with conditional insets ++ val playerView = PlayerView(this).apply { ++ setBackgroundColor(Color.BLACK) ++ setShowSubtitleButton(true) ++ setShowNextButton(false) ++ setShowPreviousButton(false) ++ setFullscreenButtonClickListener { ++ finish() ++ } ++ ++ layoutParams = ViewGroup.LayoutParams( ++ ViewGroup.LayoutParams.MATCH_PARENT, ++ ViewGroup.LayoutParams.MATCH_PARENT ++ ) ++ useController = true ++ controllerAutoShow = false ++ controllerHideOnTouch = true + +- layoutParams = +- ViewGroup.LayoutParams( +- ViewGroup.LayoutParams.MATCH_PARENT, +- ViewGroup.LayoutParams.MATCH_PARENT, +- ) +- useController = true +- controllerAutoShow = false +- controllerHideOnTouch = true ++ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { ++ // Apply padding dynamically for modern Android ++ setOnApplyWindowInsetsListener { _, insets -> ++ val systemInsets = insets.getInsets(android.view.WindowInsets.Type.systemBars()) ++ setPadding(0, systemInsets.top, 0, systemInsets.bottom) ++ insets ++ } ++ } else { ++ // Apply fixed padding for older Android versions ++ setPadding(0, getStatusBarHeight(), 0, getNavigationBarHeight()) + } ++ } + playerView.player = player + + setContentView(playerView) +@@ -67,4 +88,15 @@ class FullscreenActivity : AppCompatActivity() { + } + super.onDestroy() + } ++ ++ // Helper methods to calculate insets for status bar and navigation bar ++ private fun getStatusBarHeight(): Int { ++ val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android") ++ return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0 ++ } ++ ++ private fun getNavigationBarHeight(): Int { ++ val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") ++ return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0 ++ } + }