@@ -20,6 +20,8 @@ import android.view.*
20
20
import android.widget.Toast
21
21
import androidx.core.app.ActivityCompat
22
22
import androidx.core.content.ContextCompat
23
+ import androidx.core.view.ViewCompat
24
+ import androidx.core.view.WindowInsetsCompat
23
25
import org.koreader.launcher.device.Device
24
26
import org.koreader.launcher.dialog.LightDialog
25
27
import org.koreader.launcher.extensions.*
@@ -564,7 +566,8 @@ class MainActivity : NativeActivity(), LuaInterface,
564
566
565
567
override fun isFullscreen (): Boolean {
566
568
return if (Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR2 ||
567
- Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
569
+ Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR1 ||
570
+ Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
568
571
fullscreen
569
572
} else if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .JELLY_BEAN ) {
570
573
isFullscreenDeprecated()
@@ -681,12 +684,39 @@ class MainActivity : NativeActivity(), LuaInterface,
681
684
}
682
685
}
683
686
687
+ fun setFullscreenImmersive (enabled : Boolean ) {
688
+ val windowInsetsController = ViewCompat .getWindowInsetsController(window.decorView) ? : return
689
+
690
+ val cd = CountDownLatch (1 )
691
+ runOnUiThread {
692
+ try {
693
+ if (enabled) {
694
+ windowInsetsController.hide(WindowInsetsCompat .Type .navigationBars())
695
+ } else {
696
+ windowInsetsController.show(WindowInsetsCompat .Type .navigationBars())
697
+ }
698
+ } catch (e: Exception ) {
699
+ e.printStackTrace()
700
+ }
701
+ cd.countDown()
702
+ }
703
+
704
+ try {
705
+ cd.await()
706
+ fullscreen = enabled
707
+ } catch (ex: InterruptedException ) {
708
+ ex.printStackTrace()
709
+ }
710
+ }
711
+
684
712
override fun setFullscreen (enabled : Boolean ) {
685
713
if (Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR2 ||
686
714
Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
687
715
fullscreen = enabled
688
716
} else if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .JELLY_BEAN ) {
689
717
setFullscreenDeprecated(enabled)
718
+ } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
719
+ setFullscreenImmersive(enabled)
690
720
}
691
721
}
692
722
@@ -811,13 +841,15 @@ class MainActivity : NativeActivity(), LuaInterface,
811
841
private fun setFullscreenLayout () {
812
842
val decorView = window.decorView
813
843
when {
814
- Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ->
844
+ Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT -> {
815
845
decorView.systemUiVisibility = View .SYSTEM_UI_FLAG_FULLSCREEN or
816
846
View .SYSTEM_UI_FLAG_HIDE_NAVIGATION or
817
847
View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
818
848
View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
819
849
View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
820
850
View .SYSTEM_UI_FLAG_LAYOUT_STABLE
851
+ setFullscreenImmersive(fullscreen)
852
+ }
821
853
Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ->
822
854
decorView.systemUiVisibility = View .SYSTEM_UI_FLAG_FULLSCREEN or
823
855
View .SYSTEM_UI_FLAG_LOW_PROFILE
0 commit comments