diff options
-rw-r--r-- | res/values/strings.xml | 7 | ||||
-rw-r--r-- | res/xml/preferences.xml | 11 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/preference/PreferencesProvider.java | 9 |
4 files changed, 29 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index a47ccb13f..0dc3a6f23 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -246,8 +246,8 @@ s --> <string name="preferences_title">Preferences</string> <!-- UI --> <string name="preferences_interface_title">Interface</string> - <!-- General --> - <string name="preferences_general_title">General</string> + <!-- Application --> + <string name="preferences_application_title">Application</string> <!-- UI --> <!-- Homescreen --> @@ -270,4 +270,7 @@ s --> <!-- Icons --> <string name="preferences_interface_icons_title">Icons</string> + <!-- General --> + <string name="preferences_interface_general_title">General</string> + <string name="preferences_interface_general_orientation_title">Auto-rotate screen</string> </resources> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 8ffe86f34..8fba933ad 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -53,9 +53,16 @@ android:title="@string/preferences_interface_icons_title"> </PreferenceScreen> + + <!-- General --> + <PreferenceScreen android:key="ui_general" + android:title="@string/preferences_interface_general_title"> + <CheckBoxPreference android:key="ui_general_orientation" + android:title="@string/preferences_interface_general_orientation_title" /> + </PreferenceScreen> </PreferenceCategory> - <!-- General --> - <PreferenceCategory android:title="@string/preferences_general_title"> + <!-- Application --> + <PreferenceCategory android:title="@string/preferences_application_title"> </PreferenceCategory> </PreferenceScreen> diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index b7de4329c..aaa479b04 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -29,6 +29,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.app.SearchManager; import android.app.StatusBarManager; +import android.app.UiModeManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ActivityNotFoundException; @@ -350,9 +351,13 @@ public final class Launcher extends Activity } mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible); - // On large interfaces, we want the screen to auto-rotate based on the current orientation - if (LauncherApplication.isScreenLarge()) { + + final UiModeManager uiModeManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE); + if (PreferencesProvider.Interface.General.getAutoRotate(this) || + uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_NORMAL) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } } diff --git a/src/com/android/launcher2/preference/PreferencesProvider.java b/src/com/android/launcher2/preference/PreferencesProvider.java index 46fb21f97..ed0fe2aaf 100644 --- a/src/com/android/launcher2/preference/PreferencesProvider.java +++ b/src/com/android/launcher2/preference/PreferencesProvider.java @@ -34,9 +34,16 @@ public final class PreferencesProvider { public static class Icons { } + + public static class General { + public static boolean getAutoRotate(Context context) { + final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); + return preferences.getBoolean("ui_general_orientation", false); + } + } } - public static class General { + public static class Application { } } |