Making the 'Allow rotation' setting dependent on system state

The setting will not be available on a tablet, where rotation is
always enabled. On mobiles, it will be disabled when auto-rotate
is disabled in display settings.
Also removing content provider dependency from settings, as its in the
same process as launcher.

Bug: 28704055
Change-Id: Ibe6b1e67411fb0e4b2e36446710f463e4a3d6883
This commit is contained in:
Sunny Goyal committed 2016-05-16 12:07:41 -07:00
1 parent f898b970cc
commit f48e59268b
5 files changed
+70 -75

No files matched your search

+7 -4
View File
@@ -142,7 +142,11 @@ public final class Utilities {
}
public static boolean isAllowRotationPrefEnabled(Context context) {
boolean allowRotationPref = false;
return getPrefs(context).getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
getAllowRotationDefaultValue(context));
}
public static boolean getAllowRotationDefaultValue(Context context) {
if (isNycOrAbove()) {
// If the device was scaled, used the original dimensions to determine if rotation
// is allowed of not.
@@ -153,13 +157,12 @@ public final class Utilities {
Resources res = context.getResources();
int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
* res.getDisplayMetrics().densityDpi / originalDensity;
allowRotationPref = originalSmallestWidth >= 600;
return originalSmallestWidth >= 600;
} catch (Exception e) {
// Ignore
}
}
return getPrefs(context).getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, allowRotationPref);
return false;
}
public static boolean isNycOrAbove() {