Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed Dec 20, 2024
1 parent adf6977 commit 890cfc8
Showing 1 changed file with 47 additions and 62 deletions.
109 changes: 47 additions & 62 deletions patches/@haileyok+bluesky-video+0.2.4.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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
index d4f83cc..b5f8461 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 @@
@@ -1,10 +1,15 @@
package expo.modules.blueskyvideo

import android.graphics.Color
Expand All @@ -11,50 +11,28 @@ index d4f83cc..a7b1d16 100644
+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.core.view.ViewCompat
+import androidx.core.view.WindowCompat
import androidx.media3.common.util.UnstableApi
@@ -25,37 +29,54 @@ class FullscreenActivity : AppCompatActivity() {
import androidx.media3.ui.PlayerView
import java.lang.ref.WeakReference
@@ -25,40 +30,49 @@ 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)
+ }
+ // Enable edge-to-edge mode but keep navigation bar persistent
+ WindowCompat.setDecorFitsSystemWindows(window, false)

+ // Keep screen on if requested
+ val keepDisplayOn = this.intent.getBooleanExtra("keepDisplayOn", false)
if (keepDisplayOn) {
- val keepDisplayOn = this.getIntent().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)
Expand All @@ -63,14 +41,33 @@ index d4f83cc..a7b1d16 100644
+ setFullscreenButtonClickListener {
+ finish()
+ }
+
+ layoutParams = ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT
+ )
+ useController = true
+ controllerAutoShow = false
+ controllerHideOnTouch = true
}
+ playerView.player = player
+ setContentView(playerView)

- // Update the player viewz
- val playerView =
- PlayerView(this).apply {
- setBackgroundColor(Color.BLACK)
- setShowSubtitleButton(true)
- setShowNextButton(false)
- setShowPreviousButton(false)
- setFullscreenButtonClickListener {
- finish()
- }
+ // Adjust layout for system insets to accommodate persistent nav bar
+ ViewCompat.setOnApplyWindowInsetsListener(playerView) { view, insets ->
+ val systemBarsInsets = insets.getInsets(WindowInsets.Type.systemBars())
+ view.setPadding(0, systemBarsInsets.top, 0, systemBarsInsets.bottom)
+ insets
+ }

- layoutParams =
- ViewGroup.LayoutParams(
Expand All @@ -80,34 +77,22 @@ index d4f83cc..a7b1d16 100644
- 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())
+ // Prevent hiding of the navigation bar
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ window.insetsController?.let {
+ it.systemBarsBehavior = android.view.WindowInsetsController.BEHAVIOR_DEFAULT
}
- playerView.player = player
+ } else {
+ @Suppress("DEPRECATION")
+ window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ }
playerView.player = player

setContentView(playerView)
@@ -67,4 +88,15 @@ class FullscreenActivity : AppCompatActivity() {
}
super.onDestroy()
- setContentView(playerView)
+ val keepDisplayOn = this.intent.getBooleanExtra("keepDisplayOn", false)
+ if (keepDisplayOn) {
+ this.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ }
}
+
+ // 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
+ }
}

override fun onDestroy() {

0 comments on commit 890cfc8

Please sign in to comment.