Skip to content

Commit 54624cb

Browse files
committed
fix: Hide system bars reset after leaving fullscreen video
The system bars were shown again after leaving a full screen video. Now only the necessary bars are shown back
1 parent 6f6ece9 commit 54624cb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import android.view.ViewGroup.MarginLayoutParams
3030
import android.view.inputmethod.EditorInfo
3131
import android.view.inputmethod.InputMethodManager
3232
import android.webkit.WebView
33+
import android.widget.FrameLayout
3334
import android.widget.LinearLayout
3435
import androidx.appcompat.app.AlertDialog
3536
import androidx.appcompat.widget.ActionMenuView
@@ -666,6 +667,8 @@ class ReviewerFragment :
666667

667668
override fun onCreateWebViewClient(savedInstanceState: Bundle?): CardViewerWebViewClient = ReviewerWebViewClient(savedInstanceState)
668669

670+
override fun onCreateWebChromeClient(): CardViewerWebChromeClient = ReviewerWebChromeClient()
671+
669672
private inner class ReviewerWebViewClient(
670673
savedInstanceState: Bundle?,
671674
) : CardViewerWebViewClient(savedInstanceState) {
@@ -740,6 +743,29 @@ class ReviewerFragment :
740743
}
741744
}
742745

746+
private inner class ReviewerWebChromeClient : CardViewerWebChromeClient() {
747+
override fun onHideCustomView() {
748+
val barsToHide = Prefs.hideSystemBars
749+
if (barsToHide == HideSystemBars.NONE) {
750+
super.onHideCustomView()
751+
} else {
752+
val window = requireActivity().window
753+
(window.decorView as FrameLayout).removeView(paramView)
754+
755+
val barsToShowBack =
756+
when (barsToHide) {
757+
HideSystemBars.STATUS_BAR -> WindowInsetsCompat.Type.navigationBars()
758+
HideSystemBars.NAVIGATION_BAR -> WindowInsetsCompat.Type.statusBars()
759+
HideSystemBars.ALL, HideSystemBars.NONE -> return
760+
}
761+
with(WindowInsetsControllerCompat(window, window.decorView)) {
762+
show(barsToShowBack)
763+
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
764+
}
765+
}
766+
}
767+
}
768+
743769
companion object {
744770
fun getIntent(context: Context): Intent = CardViewerActivity.getIntent(context, ReviewerFragment::class)
745771
}

0 commit comments

Comments
 (0)