android: Implement Expand to Display Cutout option

This commit is contained in:
Gamer64 2024-07-30 00:23:58 +02:00 committed by OpenSauce
parent 43dbe42b29
commit 5413b47844
5 changed files with 27 additions and 3 deletions

View File

@ -192,9 +192,17 @@ class EmulationActivity : AppCompatActivity() {
}
private fun enableFullscreenImmersive() {
// TODO: Remove this once we properly account for display insets in the input overlay
window.attributes.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
val attributes = window.attributes
attributes.layoutInDisplayCutoutMode =
if (BooleanSetting.EXPAND_TO_CUTOUT_AREA.boolean) {
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
} else {
// TODO: Remove this once we properly account for display insets in the input overlay
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
}
window.attributes = attributes
WindowCompat.setDecorFitsSystemWindows(window, false)

View File

@ -9,6 +9,7 @@ enum class BooleanSetting(
override val section: String,
override val defaultValue: Boolean
) : AbstractBooleanSetting {
EXPAND_TO_CUTOUT_AREA("expand_to_cutout_area", Settings.SECTION_LAYOUT, false),
SPIRV_SHADER_GEN("spirv_shader_gen", Settings.SECTION_RENDERER, true),
ASYNC_SHADERS("async_shader_compilation", Settings.SECTION_RENDERER, false),
PLUGIN_LOADER("plugin_loader", Settings.SECTION_SYSTEM, false),

View File

@ -215,6 +215,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private fun addGeneralSettings(sl: ArrayList<SettingsItem>) {
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_general))
sl.apply {
add(
SwitchSetting(
BooleanSetting.EXPAND_TO_CUTOUT_AREA,
R.string.expand_to_cutout_area,
R.string.expand_to_cutout_area_description,
BooleanSetting.EXPAND_TO_CUTOUT_AREA.key,
BooleanSetting.EXPAND_TO_CUTOUT_AREA.defaultValue
)
)
add(
SwitchSetting(
IntSetting.USE_FRAME_LIMIT,

View File

@ -251,6 +251,10 @@ custom_portrait_bottom_height =
# 0 (default): Top Screen is prominent, 1: Bottom Screen is prominent
swap_screen =
# Expands the display area to include the cutout (or notch) area
# 0 (default): Off, 1: On
expand_to_cutout_area =
# Screen placement settings when using Cardboard VR (render3d = 4)
# 30 - 100: Screen size as a percentage of the viewport. 85 (default)
cardboard_screen_size =

View File

@ -238,6 +238,8 @@
<string name="asynchronous_gpu">Enable asynchronous GPU emulation</string>
<string name="asynchronous_gpu_description">Uses a separate thread to emulate the GPU asynchronously. When enabled, performance will be improved.</string>
<string name="frame_limit_enable">Limit Speed</string>
<string name="expand_to_cutout_area">Expand to Cutout Area</string>
<string name="expand_to_cutout_area_description">Expands the display area to include the cutout (or notch) area.</string>
<string name="frame_limit_enable_description">When enabled, emulation speed will be limited to a specified percentage of normal speed.</string>
<string name="frame_limit_slider">Limit Speed Percent</string>
<string name="frame_limit_slider_description">Specifies the percentage to limit emulation speed. With the default of 100% emulation will be limited to normal speed. Values higher or lower will increase or decrease the speed limit.</string>