summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2013-06-08 13:01:39 -0400
committerDanesh Mondegarian <daneshm90@gmail.com>2013-06-08 18:49:08 -0400
commitcb539846b2559b40cf96361891265fd47f88d3fb (patch)
treee6726d8b4648f0bb97dd53c619cc28fa62e729db
parent0fd38fa103fdbeda8b863a58b9ff62bbe6999d3e (diff)
downloadpackages_apps_settings-cb539846b2559b40cf96361891265fd47f88d3fb.zip
packages_apps_settings-cb539846b2559b40cf96361891265fd47f88d3fb.tar.gz
packages_apps_settings-cb539846b2559b40cf96361891265fd47f88d3fb.tar.bz2
Utils : Fix tablet orientation logic
Tablets have orientations for portrait reversed, this commit addresses it. Add in a few more orientation-aware safety checks to circumvent certain devices whose default orientation does not match their device type. Change-Id: Idc627e687ca61ab29f08433664bf77148424bd6d
-rw-r--r--src/com/android/settings/Utils.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 7e92321..aa958d3 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
@@ -696,23 +697,23 @@ public class Utils {
public static void lockCurrentOrientation(Activity act) {
int currentRotation = act.getWindowManager().getDefaultDisplay().getRotation();
int frozenRotation = 0;
- boolean isTablet = isTablet(act);
+ int orientation = act.getResources().getConfiguration().orientation;
switch(currentRotation) {
case Surface.ROTATION_0:
- frozenRotation = isTablet ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE :
- ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+ frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE
+ ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case Surface.ROTATION_90:
- frozenRotation = isTablet ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT :
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
+ frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT
+ ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_180:
- frozenRotation = isTablet ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE :
- ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
+ frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE
+ ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
case Surface.ROTATION_270:
- frozenRotation = isTablet ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT :
- ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
+ frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT
+ ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
}
act.setRequestedOrientation(frozenRotation);