Android: Add option to expand display to cutout

This commit is contained in:
Connor McLaughlin 2021-06-04 21:16:00 +10:00
parent ebcc11750d
commit 8cf4c4f211
3 changed files with 30 additions and 0 deletions

View file

@ -203,6 +203,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
updateRequestedOrientation(); updateRequestedOrientation();
updateControllers(); updateControllers();
updateSustainedPerformanceMode(); updateSustainedPerformanceMode();
updateDisplayInCutout();
} }
private void applySettings() { private void applySettings() {
@ -296,6 +297,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
// Sort out rotation. // Sort out rotation.
updateOrientation(); updateOrientation();
updateSustainedPerformanceMode(); updateSustainedPerformanceMode();
updateDisplayInCutout();
// Hook up controller input. // Hook up controller input.
updateControllers(); updateControllers();
@ -425,6 +427,24 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
mContentView.requestFocus(); mContentView.requestFocus();
} }
private void updateDisplayInCutout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return;
final boolean shouldExpand = getBooleanSetting("Display/ExpandToCutout", false);
final boolean isExpanded = getWindow().getAttributes().layoutInDisplayCutoutMode ==
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
if (shouldExpand == isExpanded)
return;
WindowManager.LayoutParams attribs = getWindow().getAttributes();
attribs.layoutInDisplayCutoutMode = shouldExpand ?
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES :
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
getWindow().setAttributes(attribs);
}
private static final int REQUEST_CODE_SETTINGS = 0; private static final int REQUEST_CODE_SETTINGS = 0;
private static final int REQUEST_IMPORT_PATCH_CODES = 1; private static final int REQUEST_IMPORT_PATCH_CODES = 1;
private static final int REQUEST_CHANGE_DISC_FILE = 2; private static final int REQUEST_CHANGE_DISC_FILE = 2;

View file

@ -363,4 +363,6 @@
<string name="settings_cdrom_load_image_patches">Apply Image Patches</string> <string name="settings_cdrom_load_image_patches">Apply Image Patches</string>
<string name="settings_summary_load_image_patches">Automatically applies patches to disc images when they are present, currently only PPF is supported.</string> <string name="settings_summary_load_image_patches">Automatically applies patches to disc images when they are present, currently only PPF is supported.</string>
<string name="menu_edit_game_directories_force_saf">Force Scoped Storage</string> <string name="menu_edit_game_directories_force_saf">Force Scoped Storage</string>
<string name="settings_expand_to_cutout">Expand To Cutout Area</string>
<string name="settings_summary_expand_to_cutout">Expands the display area to include the cutout (or notch) area.</string>
</resources> </resources>

View file

@ -81,6 +81,14 @@
app:summary="@string/settings_summary_display_stretch" app:summary="@string/settings_summary_display_stretch"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
app:key="Display/ExpandToCutout"
app:title="@string/settings_expand_to_cutout"
app:defaultValue="false"
app:dependency="Display/IntegerScaling"
app:summary="@string/settings_summary_expand_to_cutout"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:key="Display/ShowOSDMessages" app:key="Display/ShowOSDMessages"
app:title="@string/settings_osd_show_messages" app:title="@string/settings_osd_show_messages"