mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
fix status bar
This commit is contained in:
parent
29afd06478
commit
1f13c0a67f
@ -494,6 +494,8 @@ class MainActivity : BaseActivity() {
|
|||||||
private fun unsetFullscreen() {
|
private fun unsetFullscreen() {
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
|
||||||
|
|
||||||
|
showSystemBars()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
window.attributes.layoutInDisplayCutoutMode =
|
window.attributes.layoutInDisplayCutoutMode =
|
||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
|
||||||
@ -512,6 +514,36 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hide the status bar
|
||||||
|
*/
|
||||||
|
fun hideSystemBars() {
|
||||||
|
if (resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE) return
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
window.insetsController?.hide(WindowInsets.Type.statusBars())
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
window.setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show the status bar
|
||||||
|
*/
|
||||||
|
fun showSystemBars() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
window.insetsController?.show(WindowInsets.Type.statusBars())
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
window.clearFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onUserLeaveHint() {
|
override fun onUserLeaveHint() {
|
||||||
super.onUserLeaveHint()
|
super.onUserLeaveHint()
|
||||||
supportFragmentManager.fragments.forEach { fragment ->
|
supportFragmentManager.fragments.forEach { fragment ->
|
||||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import com.github.libretube.activities.MainActivity
|
||||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||||
import com.github.libretube.interfaces.DoubleTapInterface
|
import com.github.libretube.interfaces.DoubleTapInterface
|
||||||
import com.github.libretube.util.DoubleTapListener
|
import com.github.libretube.util.DoubleTapListener
|
||||||
@ -31,7 +32,7 @@ internal class CustomExoPlayerView(
|
|||||||
if (isControllerFullyVisible) hideController() else showController()
|
if (isControllerFullyVisible) hideController() else showController()
|
||||||
}
|
}
|
||||||
|
|
||||||
val doubleTouchListener = object : DoubleTapListener() {
|
private val doubleTouchListener = object : DoubleTapListener() {
|
||||||
override fun onDoubleClick() {
|
override fun onDoubleClick() {
|
||||||
doubleTapListener?.onEvent(xPos)
|
doubleTapListener?.onEvent(xPos)
|
||||||
}
|
}
|
||||||
@ -46,6 +47,11 @@ internal class CustomExoPlayerView(
|
|||||||
setOnClickListener(doubleTouchListener)
|
setOnClickListener(doubleTouchListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hideController() {
|
||||||
|
(context as? MainActivity)?.hideSystemBars()
|
||||||
|
super.hideController()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
// save the x position of the touch event
|
// save the x position of the touch event
|
||||||
xPos = event.x
|
xPos = event.x
|
||||||
|
Loading…
Reference in New Issue
Block a user