From 168f7a5d3c982914fd2df6216cde02642c4431f6 Mon Sep 17 00:00:00 2001
From: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
Date: Sun, 30 Jun 2024 10:53:52 -0300
Subject: [PATCH] feat(new reviewer): ignore display cutout
https://developer.android.com/develop/ui/views/layout/edge-to-edge#cutout-insets
---
.../ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt | 9 ++++++++-
AnkiDroid/src/main/res/values/10-preferences.xml | 1 +
AnkiDroid/src/main/res/values/preferences.xml | 1 +
AnkiDroid/src/main/res/xml/preferences_reviewer.xml | 6 ++++++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
index 55d3c111c12c..ab46baf60a55 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
@@ -54,6 +54,7 @@ import com.ichi2.anki.snackbar.SnackbarBuilder
import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.utils.ext.collectIn
import com.ichi2.anki.utils.ext.collectLatestIn
+import com.ichi2.anki.utils.ext.sharedPrefs
import com.ichi2.anki.utils.navBarNeedsScrim
import com.ichi2.libanki.sched.Counts
import com.ichi2.utils.increaseHorizontalPaddingOfOverflowMenuIcons
@@ -318,8 +319,14 @@ class ReviewerFragment :
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
+ val ignoreDisplayCutout = sharedPrefs().getBoolean(getString(R.string.ignore_display_cutout_key), false)
ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
- val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
+ val typeMask = if (ignoreDisplayCutout) {
+ WindowInsetsCompat.Type.systemBars()
+ } else {
+ WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
+ }
+ val bars = insets.getInsets(typeMask)
v.updatePadding(
left = bars.left,
top = bars.top,
diff --git a/AnkiDroid/src/main/res/values/10-preferences.xml b/AnkiDroid/src/main/res/values/10-preferences.xml
index 976dede5ab39..03cefdecc4cd 100644
--- a/AnkiDroid/src/main/res/values/10-preferences.xml
+++ b/AnkiDroid/src/main/res/values/10-preferences.xml
@@ -442,4 +442,5 @@ this formatter is used if the bind only applies to both the question and the ans
>Navigation bar
All
+ Ignore display cutout
diff --git a/AnkiDroid/src/main/res/values/preferences.xml b/AnkiDroid/src/main/res/values/preferences.xml
index 0f885dbd17a5..58568cf0e84e 100644
--- a/AnkiDroid/src/main/res/values/preferences.xml
+++ b/AnkiDroid/src/main/res/values/preferences.xml
@@ -202,4 +202,5 @@
hideSystemBars
+ ignoreDisplayCutout
\ No newline at end of file
diff --git a/AnkiDroid/src/main/res/xml/preferences_reviewer.xml b/AnkiDroid/src/main/res/xml/preferences_reviewer.xml
index 0c7e3bce6ea3..428b2125cd3c 100644
--- a/AnkiDroid/src/main/res/xml/preferences_reviewer.xml
+++ b/AnkiDroid/src/main/res/xml/preferences_reviewer.xml
@@ -9,4 +9,10 @@
android:key="@string/hide_system_bars_key"
android:title="@string/hide_system_bars"
app:useSimpleSummaryProvider="true"/>
+
+
\ No newline at end of file