make fullscreen respect system UI
This commit is contained in:
parent
09815ccb12
commit
29f6d9e960
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package net.newpipe.newplayer
|
package net.newpipe.newplayer
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
@ -33,10 +34,15 @@ class MainActivity : AppCompatActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
|
//TODO: This is a dirty hack. Fix this later on
|
||||||
|
if (getResources().configuration.orientation != Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.newpipe.newplayer
|
||||||
|
|
||||||
|
interface NewPlayer {
|
||||||
|
|
||||||
|
interface Listener {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewPlayerImpl {
|
||||||
|
}
|
|
@ -53,19 +53,21 @@ class PlayerFragment() : Fragment() {
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
|
|
||||||
|
|
||||||
val window = activity?.window!!
|
val window = activity?.window!!
|
||||||
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
|
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
|
||||||
insetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
insetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
|
||||||
|
if (viewModel.uiState.value.fullscreen) {
|
||||||
|
println("gurken fragment created for fullscreen")
|
||||||
|
//insetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
|
}
|
||||||
|
|
||||||
val view = inflater.inflate(R.layout.player_framgent, container, false)
|
val view = inflater.inflate(R.layout.player_framgent, container, false)
|
||||||
val composeView = view.findViewById<ComposeView>(R.id.player_copose_view)
|
val composeView = view.findViewById<ComposeView>(R.id.player_copose_view)
|
||||||
val frameView = view.findViewById<FrameLayout>(R.id.frame_layout)
|
val frameView = view.findViewById<FrameLayout>(R.id.frame_layout)
|
||||||
|
|
||||||
if (viewModel.uiState.value.fullscreen) {
|
|
||||||
println("gurken fragment created for fullscreen")
|
|
||||||
insetsController.hide(WindowInsetsCompat.Type.systemBars())
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModel.listener = object : VideoPlayerViewModel.Listener {
|
viewModel.listener = object : VideoPlayerViewModel.Listener {
|
||||||
override fun requestUpdateLayoutRatio(ratio: Float) {
|
override fun requestUpdateLayoutRatio(ratio: Float) {
|
||||||
frameView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
frameView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
|
|
|
@ -29,11 +29,14 @@ import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.defaultMinSize
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.systemBars
|
||||||
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.List
|
import androidx.compose.material.icons.automirrored.filled.List
|
||||||
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
||||||
|
@ -92,9 +95,18 @@ fun VideoPlayerControllerUI(
|
||||||
switchToEmbeddedView: () -> Unit
|
switchToEmbeddedView: () -> Unit
|
||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxSize(), color = Color.Transparent
|
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = if (isFullscreen) {
|
||||||
|
Modifier
|
||||||
|
.background(Color.Transparent)
|
||||||
|
.windowInsetsPadding(WindowInsets.systemBars)
|
||||||
|
} else {
|
||||||
|
Modifier
|
||||||
|
.background(Color.Transparent)
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
Box(modifier = Modifier.background(Color.Transparent)) {
|
|
||||||
TopUI(
|
TopUI(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopStart)
|
.align(Alignment.TopStart)
|
||||||
|
|
Loading…
Reference in New Issue