Skip to content

Commit

Permalink
Merge pull request #7508 from zackhow/lock-landscape
Browse files Browse the repository at this point in the history
Android: lock screen to landscape by default
  • Loading branch information
lioncash committed Oct 25, 2018
2 parents 74c49c9 + 9e44df1 commit 61821b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Expand Up @@ -4,6 +4,8 @@
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.hardware.usb.UsbManager; import android.hardware.usb.UsbManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
Expand Down Expand Up @@ -237,6 +239,17 @@ protected void onCreate(Bundle savedInstanceState)
int themeId; int themeId;
if (mDeviceHasTouchScreen) if (mDeviceHasTouchScreen)
{ {
// Force landscape
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
BooleanSetting lockLandscape =
(BooleanSetting) mSettings.getSection(Settings.SECTION_INI_CORE)
.getSetting(SettingsFile.KEY_LOCK_LANDSCAPE);
if (lockLandscape == null || lockLandscape.getValue())
new Handler().postDelayed(
() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
100);
}
themeId = R.style.DolphinEmulationBase; themeId = R.style.DolphinEmulationBase;


// Get a handle to the Window containing the UI. // Get a handle to the Window containing the UI.
Expand Down
Expand Up @@ -212,6 +212,7 @@ private void addGeneralSettings(ArrayList<SettingsItem> sl)
Setting audioStretch = null; Setting audioStretch = null;
Setting analytics = null; Setting analytics = null;
Setting enableSaveState; Setting enableSaveState;
Setting lockToLandscape;


SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE); SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE);
SettingSection analyticsSection = mSettings.getSection(Settings.SECTION_ANALYTICS); SettingSection analyticsSection = mSettings.getSection(Settings.SECTION_ANALYTICS);
Expand All @@ -223,6 +224,7 @@ private void addGeneralSettings(ArrayList<SettingsItem> sl)
audioStretch = coreSection.getSetting(SettingsFile.KEY_AUDIO_STRETCH); audioStretch = coreSection.getSetting(SettingsFile.KEY_AUDIO_STRETCH);
analytics = analyticsSection.getSetting(SettingsFile.KEY_ANALYTICS_ENABLED); analytics = analyticsSection.getSetting(SettingsFile.KEY_ANALYTICS_ENABLED);
enableSaveState = coreSection.getSetting(SettingsFile.KEY_ENABLE_SAVE_STATES); enableSaveState = coreSection.getSetting(SettingsFile.KEY_ENABLE_SAVE_STATES);
lockToLandscape = coreSection.getSetting(SettingsFile.KEY_LOCK_LANDSCAPE);


// TODO: Having different emuCoresEntries/emuCoresValues for each architecture is annoying. // TODO: Having different emuCoresEntries/emuCoresValues for each architecture is annoying.
// The proper solution would be to have one emuCoresEntries and one emuCoresValues // The proper solution would be to have one emuCoresEntries and one emuCoresValues
Expand Down Expand Up @@ -262,6 +264,9 @@ else if (defaultCpuCore == 4) // AArch64
sl.add(new CheckBoxSetting(SettingsFile.KEY_ENABLE_SAVE_STATES, Settings.SECTION_INI_CORE, sl.add(new CheckBoxSetting(SettingsFile.KEY_ENABLE_SAVE_STATES, Settings.SECTION_INI_CORE,
R.string.enable_save_states, R.string.enable_save_states_description, false, R.string.enable_save_states, R.string.enable_save_states_description, false,
enableSaveState)); enableSaveState));
sl.add(new CheckBoxSetting(SettingsFile.KEY_LOCK_LANDSCAPE, Settings.SECTION_INI_CORE,
R.string.lock_emulation_landscape, R.string.lock_emulation_landscape_desc, true,
lockToLandscape));
sl.add(new CheckBoxSetting(SettingsFile.KEY_ANALYTICS_ENABLED, Settings.SECTION_ANALYTICS, sl.add(new CheckBoxSetting(SettingsFile.KEY_ANALYTICS_ENABLED, Settings.SECTION_ANALYTICS,
R.string.analytics, 0, false, analytics)); R.string.analytics, 0, false, analytics));
} }
Expand Down
Expand Up @@ -50,6 +50,7 @@ public final class SettingsFile
public static final String KEY_SLOT_A_DEVICE = "SlotA"; public static final String KEY_SLOT_A_DEVICE = "SlotA";
public static final String KEY_SLOT_B_DEVICE = "SlotB"; public static final String KEY_SLOT_B_DEVICE = "SlotB";
public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates"; public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates";
public static final String KEY_LOCK_LANDSCAPE = "LockLandscape";


public static final String KEY_ANALYTICS_ENABLED = "Enabled"; public static final String KEY_ANALYTICS_ENABLED = "Enabled";
public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked"; public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked";
Expand Down
2 changes: 2 additions & 0 deletions Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -137,6 +137,8 @@
<string name="audio_stretch_description">Stretches audio to reduce stuttering. Increases latency.</string> <string name="audio_stretch_description">Stretches audio to reduce stuttering. Increases latency.</string>
<string name="enable_save_states">Enable Savestates</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="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">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_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="gametdb_thanks">Thanks to GameTDB.com for providing GameCube and Wii covers!</string> <string name="gametdb_thanks">Thanks to GameTDB.com for providing GameCube and Wii covers!</string>
Expand Down

0 comments on commit 61821b0

Please sign in to comment.