Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10552 from Gamer64ytb/display-cutout
Android: Implement expand display cutout option.
  • Loading branch information
JosJuice committed Apr 7, 2022
2 parents a8654e2 + bed9175 commit 17b17e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Expand Up @@ -7,6 +7,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.SparseIntArray;
Expand All @@ -17,6 +18,7 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -373,6 +375,19 @@ protected void onResume()
{
super.onResume();

// Only android 9+ support this feature.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{
WindowManager.LayoutParams attributes = getWindow().getAttributes();

attributes.layoutInDisplayCutoutMode =
BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.getBoolean(mSettings) ?
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES :
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;

getWindow().setAttributes(attributes);
}

updateOrientation();

if (NativeLibrary.IsGameMetadataValid())
Expand Down
Expand Up @@ -42,6 +42,8 @@ public enum BooleanSetting implements AbstractBooleanSetting

MAIN_DSP_JIT(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "EnableJIT", true),

MAIN_EXPAND_TO_CUTOUT_AREA(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE,
"ExpandToCutoutArea", false),
MAIN_USE_PANIC_HANDLERS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE,
"UsePanicHandlers", true),
MAIN_OSD_MESSAGES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE,
Expand Down
Expand Up @@ -4,6 +4,7 @@

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;

Expand Down Expand Up @@ -292,6 +293,13 @@ private void addInterfaceSettings(ArrayList<SettingsItem> sl)
R.array.orientationValues));
}

// Only android 9+ supports this feature.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA,
R.string.expand_to_cutout_area, R.string.expand_to_cutout_area_description));
}

sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_USE_PANIC_HANDLERS,
R.string.panic_handlers, R.string.panic_handlers_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_OSD_MESSAGES, R.string.osd_messages,
Expand Down
4 changes: 2 additions & 2 deletions Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -155,8 +155,6 @@
<string name="fallback_region">Fallback Region</string>
<string name="enable_save_states">Enable Savestates</string>
<string name="enable_save_states_description">WARNING: Savestates may not be compatible with future versions of Dolphin and can make it impossible to create normal saves in some cases. Never use savestates as the only way of saving your progress.</string>
<string name="lock_emulation_landscape">Lock screen to landscape</string>
<string name="lock_emulation_landscape_desc">Some touch controls will require additional tweaking if played in portrait</string>
<string name="analytics">Enable usage statistics reporting</string>
<string name="analytics_desc">If authorized, Dolphin can collect data on its performance, feature usage, and configuration, as well as data on your system\'s hardware and operating system.\n\nNo private data is ever collected. This data helps us understand how people and emulated games use Dolphin and prioritize our efforts. It also helps us identify rare configurations that are causing bugs, performance and stability issues. This authorization can be revoked at any time through Dolphin\'s settings.</string>
<string name="analytics_new_id">Generate a New Statistics Identity</string>
Expand All @@ -165,6 +163,8 @@
<!-- Interface Preference Fragment -->
<string name="interface_submenu">Interface</string>
<string name="emulation_screen_orientation">Screen Orientation During Emulation</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="panic_handlers">Use Panic Handlers</string>
<string name="panic_handlers_description">Show a message box when a potentially serious error has occurred. Disabling this may avoid annoying and non-fatal messages, but it may result in major crashes having no explanation at all.</string>
<string name="osd_messages">Show On-Screen Display Messages</string>
Expand Down

0 comments on commit 17b17e3

Please sign in to comment.