Allow video to extend into the display cutout
This commit is contained in:
parent
1cbd08c517
commit
f4d2859090
2 changed files with 23 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
package dev.jdtech.jellyfin
|
package dev.jdtech.jellyfin
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -7,6 +8,7 @@ import android.view.WindowManager
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
import androidx.navigation.navArgs
|
import androidx.navigation.navArgs
|
||||||
import com.google.android.exoplayer2.C
|
import com.google.android.exoplayer2.C
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer
|
import com.google.android.exoplayer2.SimpleExoPlayer
|
||||||
|
@ -35,6 +37,22 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
|
|
||||||
binding.playerView.player = viewModel.player
|
binding.playerView.player = viewModel.player
|
||||||
|
|
||||||
|
val playerControls = binding.playerView.findViewById<View>(R.id.player_controls)
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
binding.playerView.findViewById<View>(R.id.player_controls)
|
||||||
|
.setOnApplyWindowInsetsListener { _, windowInsets ->
|
||||||
|
val cutout = windowInsets.displayCutout
|
||||||
|
playerControls.updatePadding(
|
||||||
|
left = cutout?.safeInsetLeft ?: 0,
|
||||||
|
top = cutout?.safeInsetTop ?: 0,
|
||||||
|
right = cutout?.safeInsetRight ?: 0,
|
||||||
|
bottom = cutout?.safeInsetBottom ?: 0,
|
||||||
|
)
|
||||||
|
return@setOnApplyWindowInsetsListener windowInsets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.playerView.findViewById<View>(R.id.back_button).setOnClickListener {
|
binding.playerView.findViewById<View>(R.id.back_button).setOnClickListener {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -155,6 +173,10 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||||
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
window.attributes.layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isRendererType(
|
private fun isRendererType(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/player_controls"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/player_background">
|
android:background="@color/player_background">
|
||||||
|
|
Loading…
Reference in a new issue