-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch bluesky-video to handle insets
- Loading branch information
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
+ } | ||
} |