summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-02-23 14:49:22 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-02-23 14:50:27 -0800
commit8f3819bc51bba9e1c9a338827474a9b6e6dd07db (patch)
tree92c35b9a72388daabb649792ab1c80d43fa131f0 /src/com/android/launcher3/Utilities.java
parent261194387beebaa7927ec4e310274218b651494d (diff)
downloadandroid_packages_apps_Trebuchet-8f3819bc51bba9e1c9a338827474a9b6e6dd07db.tar.gz
android_packages_apps_Trebuchet-8f3819bc51bba9e1c9a338827474a9b6e6dd07db.tar.bz2
android_packages_apps_Trebuchet-8f3819bc51bba9e1c9a338827474a9b6e6dd07db.zip
Preserving the homescreen rotation setting on a tablet, when the display is scaled
Bug: 27040652 Change-Id: I07f5e02443379ac5b877f72d33cedf4f2feca926
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 57b583b32..d7a8a4e62 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -131,11 +131,6 @@ public final class Utilities {
CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
- // To turn on these properties, type
- // adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
- private static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate";
- private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
-
public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation";
public static boolean isPropertyEnabled(String propertyName) {
@@ -143,13 +138,24 @@ public final class Utilities {
}
public static boolean isAllowRotationPrefEnabled(Context context) {
- boolean allowRotationPref = getPrefs(context)
- .getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false);
- return sForceEnableRotation || allowRotationPref;
- }
+ boolean allowRotationPref = false;
+ if (isNycOrAbove()) {
+ // If the device was scaled, used the original dimensions to determine if rotation
+ // is allowed of not.
+ try {
+ // TODO: Use the actual field when the API is finalized.
+ int originalDensity =
+ DisplayMetrics.class.getField("DENSITY_DEVICE_STABLE").getInt(null);
+ Resources res = context.getResources();
+ int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
+ * res.getDisplayMetrics().densityDpi / originalDensity;
+ allowRotationPref = originalSmallestWidth >= 600;
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
- public static boolean isRotationAllowedForDevice(Context context) {
- return sForceEnableRotation || context.getResources().getBoolean(R.bool.allow_rotation);
+ return getPrefs(context).getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, allowRotationPref);
}
public static boolean isNycOrAbove() {