mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20: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) {
|
fun Activity.hideSystemBars() {
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||||
} else {
|
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
|
hide(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.navigationBars())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val layoutFlag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
fun Activity.showSystemBars() {
|
||||||
if (isFullscreen) {
|
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||||
window.setFlags(layoutFlag, layoutFlag)
|
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
} else {
|
show(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.navigationBars())
|
||||||
window.clearFlags(layoutFlag)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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