Improve immersive mode by using WindowInsetsControllerCompat
Description
Starting with Android 12, immersive mode can (and will) collide with gestures. It causes an issue when we try to leave the Video Player by swiping, forcing a seek gesture the first time if the HUD is not shown.
OP: https://forum.videolan.org/viewtopic.php?f=35&t=159149
The support library offers new APIs allowing us to have a finer control over the system bars visibility though. See https://developer.android.com/training/system-ui/immersive
It's pretty easy to change the dimStatusBar
method to use this new API. here is a naive implementation fixing the gesture collision (but still having inset issues).
```
/**
* Dim the status bar and/or navigation icons when needed on Android 3.x.
* Hide it on Android 4.0 and later
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
fun dimStatusBar(dim: Boolean) {
if (player.isNavMenu) return
val windowInsetsController =
ViewCompat.getWindowInsetsController(player.window.decorView) ?: return
if (dim || player.isLocked) {
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
} else {
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
}
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
}
#### Expected behavior
#### Screenshot / video
<!--Add a screenshot or screencast when applicable-->
<!--To take a screenshot, see https://support.google.com/android/answer/9075928?hl=en-->
#### App mode
<!--Remove the useless modes-->
**Smartphone**