diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-04-12 00:08:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-12 00:08:13 +0000 |
commit | 77216642884d5131290803776b0fce4d68128e97 (patch) | |
tree | 11c8e971e1ad79d88b4e3c72db1596dfd9384d4a | |
parent | b7e6a4433bda6c59540ffc51061aff5cc3d10166 (diff) | |
parent | b9ec1ac51b631c4efc9b7a7e7a2b28882105ffa3 (diff) | |
download | frameworks_base-77216642884d5131290803776b0fce4d68128e97.zip frameworks_base-77216642884d5131290803776b0fce4d68128e97.tar.gz frameworks_base-77216642884d5131290803776b0fce4d68128e97.tar.bz2 |
Merge "Implement #7341342 API request: way to determine current orientation..." into jb-mr2-dev
-rw-r--r-- | api/current.txt | 4 | ||||
-rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 30 | ||||
-rw-r--r-- | core/res/res/values/attrs_manifest.xml | 19 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 13 |
4 files changed, 62 insertions, 4 deletions
diff --git a/api/current.txt b/api/current.txt index 9ed1b3c..2fc9851 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6650,7 +6650,9 @@ package android.content.pm { field public static final int LAUNCH_SINGLE_TOP = 1; // 0x1 field public static final int SCREEN_ORIENTATION_BEHIND = 3; // 0x3 field public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10; // 0xa + field public static final int SCREEN_ORIENTATION_FULL_USER = 13; // 0xd field public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; // 0x0 + field public static final int SCREEN_ORIENTATION_LOCKED = 14; // 0xe field public static final int SCREEN_ORIENTATION_NOSENSOR = 5; // 0x5 field public static final int SCREEN_ORIENTATION_PORTRAIT = 1; // 0x1 field public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8; // 0x8 @@ -6660,6 +6662,8 @@ package android.content.pm { field public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7; // 0x7 field public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; // 0xffffffff field public static final int SCREEN_ORIENTATION_USER = 2; // 0x2 + field public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11; // 0xb + field public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12; // 0xc field public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1; // 0x1 field public int configChanges; field public int flags; diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 8f3b62d..7ccae76 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -279,6 +279,30 @@ public class ActivityInfo extends ComponentInfo public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10; /** + * Constant corresponding to <code>userLandscape</code> in + * the {@link android.R.attr#screenOrientation} attribute. + */ + public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11; + + /** + * Constant corresponding to <code>userPortrait</code> in + * the {@link android.R.attr#screenOrientation} attribute. + */ + public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12; + + /** + * Constant corresponding to <code>fullUser</code> in + * the {@link android.R.attr#screenOrientation} attribute. + */ + public static final int SCREEN_ORIENTATION_FULL_USER = 13; + + /** + * Constant corresponding to <code>locked</code> in + * the {@link android.R.attr#screenOrientation} attribute. + */ + public static final int SCREEN_ORIENTATION_LOCKED = 14; + + /** * The preferred screen orientation this activity would like to run in. * From the {@link android.R.attr#screenOrientation} attribute, one of * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, @@ -292,7 +316,11 @@ public class ActivityInfo extends ComponentInfo * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT}, * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}, * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT}, - * {@link #SCREEN_ORIENTATION_FULL_SENSOR}. + * {@link #SCREEN_ORIENTATION_FULL_SENSOR}, + * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE}, + * {@link #SCREEN_ORIENTATION_USER_PORTRAIT}, + * {@link #SCREEN_ORIENTATION_FULL_USER}, + * {@link #SCREEN_ORIENTATION_LOCKED}, */ public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 7b70e21..7f5a3dc 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -570,7 +570,8 @@ this activity. --> <enum name="behind" value="3" /> <!-- Orientation is determined by a physical orientation sensor: - the display will rotate based on how the user moves the device. --> + the display will rotate based on how the user moves the device. + Ignores user's setting to turn off sensor-based rotation. --> <enum name="sensor" value="4" /> <!-- Always ignore orientation determined by orientation sensor: the display will not rotate when the user moves the device. --> @@ -593,6 +594,22 @@ the device will normally do (for example some devices won't normally use 180 degree rotation). --> <enum name="fullSensor" value="10" /> + <!-- Would like to have the screen in landscape orientation, but if + the user has enabled sensor-based rotation then we can use the + sensor to change which direction the screen is facing. --> + <enum name="userLandscape" value="11" /> + <!-- Would like to have the screen in portrait orientation, but if + the user has enabled sensor-based rotation then we can use the + sensor to change which direction the screen is facing. --> + <enum name="userPortrait" value="12" /> + <!-- Respect the user's sensor-based rotation preference, but if + sensor-based rotation is enabled then allow the screen to rotate + in all 4 possible directions regardless of what + the device will normally do (for example some devices won't + normally use 180 degree rotation). --> + <enum name="fullUser" value="13" /> + <!-- Screen is locked to its current rotation, whatever that is. --> + <enum name="locked" value="14" /> </attr> <!-- Specify one or more configuration changes that the activity will diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 5f9e921..273ac31 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -4203,9 +4203,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Ignore sensor when plugged into HDMI. // Note that the dock orientation overrides the HDMI orientation. preferredRotation = mHdmiRotation; + } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { + // Application just wants to remain locked in the last rotation. + preferredRotation = lastRotation; } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER - || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) + || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT + || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE @@ -4221,7 +4227,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } if (sensorRotation != Surface.ROTATION_180 || mAllowAllRotations == 1 - || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) { + || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR + || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { preferredRotation = sensorRotation; } else { preferredRotation = lastRotation; @@ -4269,6 +4276,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mSeascapeRotation; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: + case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: // Return either landscape rotation. if (isLandscapeOrSeascape(preferredRotation)) { return preferredRotation; @@ -4279,6 +4287,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mLandscapeRotation; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: + case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: // Return either portrait rotation. if (isAnyPortrait(preferredRotation)) { return preferredRotation; |