mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Fix two taps required for interacting with player controls
This commit is contained in:
parent
3fd5e2144d
commit
7c72c4bea1
@ -20,25 +20,24 @@ object WindowHelper {
|
|||||||
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, !isFullscreen)
|
WindowCompat.setDecorFitsSystemWindows(window, !isFullscreen)
|
||||||
|
|
||||||
val controller = WindowCompat.getInsetsController(window, window.decorView)
|
|
||||||
val flags = WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.navigationBars()
|
|
||||||
if (isFullscreen) {
|
if (isFullscreen) {
|
||||||
controller.hide(flags)
|
activity.hideSystemBars()
|
||||||
} else {
|
} else {
|
||||||
controller.show(flags)
|
activity.showSystemBars()
|
||||||
}
|
|
||||||
|
|
||||||
controller.systemBarsBehavior = if (isFullscreen) {
|
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
|
||||||
} else {
|
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
|
|
||||||
}
|
|
||||||
|
|
||||||
val layoutFlag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
|
||||||
if (isFullscreen) {
|
|
||||||
window.setFlags(layoutFlag, layoutFlag)
|
|
||||||
} else {
|
|
||||||
window.clearFlags(layoutFlag)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Activity.hideSystemBars() {
|
||||||
|
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||||
|
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
hide(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.navigationBars())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Activity.showSystemBars() {
|
||||||
|
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||||
|
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
show(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.navigationBars())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,6 +32,8 @@ import com.github.libretube.helpers.AudioHelper
|
|||||||
import com.github.libretube.helpers.BrightnessHelper
|
import com.github.libretube.helpers.BrightnessHelper
|
||||||
import com.github.libretube.helpers.PlayerHelper
|
import com.github.libretube.helpers.PlayerHelper
|
||||||
import com.github.libretube.helpers.WindowHelper
|
import com.github.libretube.helpers.WindowHelper
|
||||||
|
import com.github.libretube.helpers.hideSystemBars
|
||||||
|
import com.github.libretube.helpers.showSystemBars
|
||||||
import com.github.libretube.obj.BottomSheetItem
|
import com.github.libretube.obj.BottomSheetItem
|
||||||
import com.github.libretube.ui.base.BaseActivity
|
import com.github.libretube.ui.base.BaseActivity
|
||||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||||
@ -202,6 +204,23 @@ internal class CustomExoPlayerView(
|
|||||||
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {}
|
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setControllerVisibilityListener(
|
||||||
|
ControllerVisibilityListener { visibility ->
|
||||||
|
playerViewModel?.isFullscreen?.value?.let { isFullscreen ->
|
||||||
|
if (isFullscreen) {
|
||||||
|
when (visibility) {
|
||||||
|
View.VISIBLE -> {
|
||||||
|
activity.showSystemBars()
|
||||||
|
}
|
||||||
|
View.GONE -> {
|
||||||
|
activity.hideSystemBars()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->
|
playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->
|
||||||
WindowHelper.toggleFullscreen(activity, isFullscreen)
|
WindowHelper.toggleFullscreen(activity, isFullscreen)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user