Allow video to extend into the display cutout

This commit is contained in:
jarnedemeulemeester 2021-09-19 18:55:27 +02:00
parent 1cbd08c517
commit f4d2859090
No known key found for this signature in database
GPG key ID: B61B7B150DB6A6D2
2 changed files with 23 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package dev.jdtech.jellyfin
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
@ -7,6 +8,7 @@ import android.view.WindowManager
import android.widget.ImageButton
import android.widget.TextView
import androidx.activity.viewModels
import androidx.core.view.updatePadding
import androidx.navigation.navArgs
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.SimpleExoPlayer
@ -35,6 +37,22 @@ class PlayerActivity : AppCompatActivity() {
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 {
onBackPressed()
}
@ -155,6 +173,10 @@ class PlayerActivity : AppCompatActivity() {
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
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(

View file

@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/player_controls"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/player_background">