mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Hide system bars on shorts
This commit is contained in:
parent
c1c0e5f6f1
commit
3cef897e89
@ -847,7 +847,9 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
this,
|
||||
doubleTapOverlayBinding,
|
||||
playerGestureControlsViewBinding,
|
||||
trackSelector
|
||||
trackSelector,
|
||||
viewModel,
|
||||
viewLifecycleOwner
|
||||
)
|
||||
|
||||
binding.apply {
|
||||
|
@ -14,6 +14,7 @@ import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||
@ -27,6 +28,7 @@ import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||
import com.github.libretube.ui.interfaces.PlayerGestureOptions
|
||||
import com.github.libretube.ui.interfaces.PlayerOptions
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
import com.github.libretube.ui.sheets.BaseBottomSheet
|
||||
import com.github.libretube.ui.sheets.PlaybackSpeedSheet
|
||||
import com.github.libretube.util.AudioHelper
|
||||
@ -61,6 +63,7 @@ internal class CustomExoPlayerView(
|
||||
private lateinit var brightnessHelper: BrightnessHelper
|
||||
private lateinit var audioHelper: AudioHelper
|
||||
private var doubleTapOverlayBinding: DoubleTapOverlayBinding? = null
|
||||
private var playerViewModel: PlayerViewModel? = null
|
||||
|
||||
/**
|
||||
* Objects from the parent fragment
|
||||
@ -79,6 +82,9 @@ internal class CustomExoPlayerView(
|
||||
|
||||
private var resizeModePref = PlayerHelper.resizeModePref
|
||||
|
||||
private val windowHelper
|
||||
get() = (context as? MainActivity)?.windowHelper
|
||||
|
||||
private val supportFragmentManager
|
||||
get() = (context as BaseActivity).supportFragmentManager
|
||||
|
||||
@ -97,12 +103,15 @@ internal class CustomExoPlayerView(
|
||||
playerViewInterface: OnlinePlayerOptions?,
|
||||
doubleTapOverlayBinding: DoubleTapOverlayBinding,
|
||||
playerGestureControlsViewBinding: PlayerGestureControlsViewBinding,
|
||||
trackSelector: TrackSelector?
|
||||
trackSelector: TrackSelector?,
|
||||
playerViewModel: PlayerViewModel? = null,
|
||||
viewLifecycleOwner: LifecycleOwner? = null
|
||||
) {
|
||||
this.playerOptionsInterface = playerViewInterface
|
||||
this.doubleTapOverlayBinding = doubleTapOverlayBinding
|
||||
this.trackSelector = trackSelector
|
||||
this.gestureViewBinding = playerGestureControlsViewBinding
|
||||
this.playerViewModel = playerViewModel
|
||||
this.playerGestureController = PlayerGestureController(context as BaseActivity, this)
|
||||
this.brightnessHelper = BrightnessHelper(context as Activity)
|
||||
this.audioHelper = AudioHelper(context)
|
||||
@ -186,6 +195,14 @@ internal class CustomExoPlayerView(
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->
|
||||
if (isFullscreen) {
|
||||
windowHelper?.setFullscreen()
|
||||
} else {
|
||||
windowHelper?.unsetFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePlayPauseButton() {
|
||||
@ -205,7 +222,13 @@ internal class CustomExoPlayerView(
|
||||
// remove the callback to hide the controller
|
||||
handler.removeCallbacks(hideControllerRunnable)
|
||||
super.hideController()
|
||||
(context as? MainActivity)?.windowHelper?.hideStatusBar()
|
||||
|
||||
// hide system bars if in fullscreen
|
||||
playerViewModel?.let {
|
||||
if (it.isFullscreen.value == true) {
|
||||
windowHelper?.setFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun showController() {
|
||||
|
@ -47,14 +47,6 @@ class WindowHelper(private val activity: BaseActivity) {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
|
||||
}
|
||||
|
||||
fun hideStatusBar() = activity.apply {
|
||||
WindowInsetsControllerCompat(window, window.decorView).hide(WindowInsetsCompat.Type.statusBars())
|
||||
}
|
||||
|
||||
fun showStatusBar() = activity.apply {
|
||||
WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.statusBars())
|
||||
}
|
||||
|
||||
fun hasCutout(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
activity.window.decorView.rootWindowInsets.displayCutout != null
|
||||
|
Loading…
x
Reference in New Issue
Block a user