Skip to content

Commit

Permalink
feat(new reviewer): ignore display cutout
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed Jun 30, 2024
1 parent 641c44b commit 1aa20df
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/10-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,5 @@ this formatter is used if the bind only applies to both the question and the ans
>Navigation bar</string>
<string name="hide_system_bars_all_bars" comment="Setting option to hide all the system bars"
>All</string>
<string name="ignore_display_cutout">Ignore display cutout</string>
</resources>
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@

<!-- Reviewer options -->
<string name="hide_system_bars_key">hideSystemBars</string>
<string name="ignore_display_cutout_key">ignoreDisplayCutout</string>
</resources>
6 changes: 6 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences_reviewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
android:key="@string/hide_system_bars_key"
android:title="@string/hide_system_bars"
app:useSimpleSummaryProvider="true"/>

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/ignore_display_cutout_key"
android:title="@string/ignore_display_cutout"
/>
</androidx.preference.PreferenceScreen>

0 comments on commit 1aa20df

Please sign in to comment.