summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java/org
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-12-10 16:17:44 +0100
committerGitHub <noreply@github.com>2020-12-10 16:17:44 +0100
commitc9e83867a101befc7d33db0cdf1798459f4a6138 (patch)
tree76c5aa4449cf2025e5baa906f9e89918c3d3fc4b /Source/Android/app/src/main/java/org
parent19324e6ed960f058fad81412ff70985b69a695a2 (diff)
parentff4b7ca7f45a92900e82eb92775752ee1cf20b11 (diff)
Merge pull request #9089 from JosJuice/android-orientation-setting
Android: Move orientation setting to main settings screen
Diffstat (limited to 'Source/Android/app/src/main/java/org')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java58
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java4
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java13
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java14
4 files changed, 29 insertions, 60 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
index 4456dad6c6..0602128a56 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
@@ -4,7 +4,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -98,9 +97,8 @@ public final class EmulationActivity extends AppCompatActivity
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC,
MENU_ACTION_RESET_OVERLAY, MENU_SET_IR_SENSITIVITY, MENU_ACTION_CHOOSE_DOUBLETAP,
- MENU_ACTION_SCREEN_ORIENTATION, MENU_ACTION_MOTION_CONTROLS, MENU_ACTION_PAUSE_EMULATION,
- MENU_ACTION_UNPAUSE_EMULATION, MENU_ACTION_OVERLAY_CONTROLS, MENU_ACTION_SETTINGS_CORE,
- MENU_ACTION_SETTINGS_GRAPHICS})
+ MENU_ACTION_MOTION_CONTROLS, MENU_ACTION_PAUSE_EMULATION, MENU_ACTION_UNPAUSE_EMULATION,
+ MENU_ACTION_OVERLAY_CONTROLS, MENU_ACTION_SETTINGS_CORE, MENU_ACTION_SETTINGS_GRAPHICS})
public @interface MenuAction
{
}
@@ -134,13 +132,12 @@ public final class EmulationActivity extends AppCompatActivity
public static final int MENU_ACTION_RESET_OVERLAY = 26;
public static final int MENU_SET_IR_SENSITIVITY = 27;
public static final int MENU_ACTION_CHOOSE_DOUBLETAP = 28;
- public static final int MENU_ACTION_SCREEN_ORIENTATION = 29;
- public static final int MENU_ACTION_MOTION_CONTROLS = 30;
- public static final int MENU_ACTION_PAUSE_EMULATION = 31;
- public static final int MENU_ACTION_UNPAUSE_EMULATION = 32;
- public static final int MENU_ACTION_OVERLAY_CONTROLS = 33;
- public static final int MENU_ACTION_SETTINGS_CORE = 34;
- public static final int MENU_ACTION_SETTINGS_GRAPHICS = 35;
+ public static final int MENU_ACTION_MOTION_CONTROLS = 29;
+ public static final int MENU_ACTION_PAUSE_EMULATION = 30;
+ public static final int MENU_ACTION_UNPAUSE_EMULATION = 31;
+ public static final int MENU_ACTION_OVERLAY_CONTROLS = 32;
+ public static final int MENU_ACTION_SETTINGS_CORE = 33;
+ public static final int MENU_ACTION_SETTINGS_GRAPHICS = 34;
private static final SparseIntArray buttonsActionsMap = new SparseIntArray();
@@ -309,6 +306,8 @@ public final class EmulationActivity extends AppCompatActivity
{
super.onResume();
+ updateOrientation();
+
if (NativeLibrary.IsGameMetadataValid())
updateMotionListener();
}
@@ -408,8 +407,7 @@ public final class EmulationActivity extends AppCompatActivity
private void updateOrientation()
{
- setRequestedOrientation(mPreferences.getInt("emulationActivityOrientation",
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));
+ setRequestedOrientation(IntSetting.MAIN_EMULATION_ORIENTATION.getInt(mSettings));
}
private boolean closeSubmenu()
@@ -628,10 +626,6 @@ public final class EmulationActivity extends AppCompatActivity
chooseDoubleTapButton();
break;
- case MENU_ACTION_SCREEN_ORIENTATION:
- chooseOrientation();
- break;
-
case MENU_ACTION_MOTION_CONTROLS:
showMotionControlsOptions();
break;
@@ -898,36 +892,6 @@ public final class EmulationActivity extends AppCompatActivity
builder.show();
}
- private void chooseOrientation()
- {
- final int[] orientationValues = getResources().getIntArray(R.array.orientationValues);
- int initialChoice = mPreferences.getInt("emulationActivityOrientation",
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- int initialIndex = -1;
- for (int i = 0; i < orientationValues.length; i++)
- {
- if (orientationValues[i] == initialChoice)
- initialIndex = i;
- }
-
- final SharedPreferences.Editor editor = mPreferences.edit();
- AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
- builder.setTitle(R.string.emulation_screen_orientation);
- builder.setSingleChoiceItems(R.array.orientationEntries, initialIndex,
- (dialog, indexSelected) ->
- {
- int orientation = orientationValues[indexSelected];
- editor.putInt("emulationActivityOrientation", orientation);
- });
- builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
- {
- editor.apply();
- updateOrientation();
- });
-
- builder.show();
- }
-
private void setIRSensitivity()
{
// IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
index 821f76ac76..fc4e86bcc2 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
@@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model;
+import android.content.pm.ActivityInfo;
+
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.overlay.InputOverlayPointer;
@@ -20,6 +22,8 @@ public enum IntSetting implements AbstractIntSetting
MAIN_AUDIO_VOLUME(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "Volume", 100),
MAIN_CONTROL_SCALE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "ControlScale", 50),
+ MAIN_EMULATION_ORIENTATION(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
+ "EmulationOrientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
MAIN_LAST_PLATFORM_TAB(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "LastPlatformTab", 0),
MAIN_MOTION_CONTROLS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "MotionControls", 1),
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
index 2acafe765a..b2071e84af 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
@@ -1,8 +1,10 @@
package org.dolphinemu.dolphinemu.features.settings.ui;
+import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
+import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
@@ -246,6 +248,17 @@ public final class SettingsFragmentPresenter
private void addInterfaceSettings(ArrayList<SettingsItem> sl)
{
+ // Hide the orientation setting if the device only supports one orientation. Old devices which
+ // support both portrait and landscape may report support for neither, so we use ==, not &&.
+ PackageManager packageManager = DolphinApplication.getAppContext().getPackageManager();
+ if (packageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) ==
+ packageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE))
+ {
+ sl.add(new SingleChoiceSetting(IntSetting.MAIN_EMULATION_ORIENTATION,
+ R.string.emulation_screen_orientation, 0, R.array.orientationEntries,
+ R.array.orientationValues));
+ }
+
sl.add(new CheckBoxSetting(BooleanSetting.MAIN_USE_PANIC_HANDLERS, R.string.panic_handlers,
R.string.panic_handlers_description));
sl.add(new CheckBoxSetting(BooleanSetting.MAIN_OSD_MESSAGES, R.string.osd_messages,
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
index b99cda75bc..90b3ee7d2d 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
@@ -46,8 +46,6 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
.append(R.id.menu_overlay_controls, EmulationActivity.MENU_ACTION_OVERLAY_CONTROLS);
buttonsActionsMap
.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES);
- buttonsActionsMap
- .append(R.id.menu_screen_orientation, EmulationActivity.MENU_ACTION_SCREEN_ORIENTATION);
buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
buttonsActionsMap.append(R.id.menu_settings_core, EmulationActivity.MENU_ACTION_SETTINGS_CORE);
@@ -90,9 +88,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
updatePauseUnpauseVisibility();
- PackageManager packageManager = requireActivity().getPackageManager();
-
- if (!packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN))
+ if (!requireActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN))
{
options.findViewById(R.id.menu_overlay_controls).setVisibility(View.GONE);
}
@@ -102,14 +98,6 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
options.findViewById(R.id.menu_refresh_wiimotes).setVisibility(View.GONE);
}
- // Old devices which support both portrait and landscape may report support for neither,
- // so we only hide the orientation button if the device only supports one orientation
- if (packageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT) !=
- packageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE))
- {
- options.findViewById(R.id.menu_screen_orientation).setVisibility(View.GONE);
- }
-
int bottomPaddingRequired = getBottomPaddingRequired();
// Provide a safe zone between the navigation bar and Exit Emulation to avoid accidental touches