diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-09-01 11:00:49 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-09-02 19:29:51 +0000 |
commit | 6ff1ef17a20dbb45328f5ea9e4be6103b796dc23 (patch) | |
tree | 2efa77065a84bccd5846ef769bfec54fc4f37548 /src/com/android | |
parent | 171fbdbc10cb962c19f6a1d7b6e0ffe5c9a85654 (diff) | |
download | android_packages_apps_Trebuchet-6ff1ef17a20dbb45328f5ea9e4be6103b796dc23.tar.gz android_packages_apps_Trebuchet-6ff1ef17a20dbb45328f5ea9e4be6103b796dc23.tar.bz2 android_packages_apps_Trebuchet-6ff1ef17a20dbb45328f5ea9e4be6103b796dc23.zip |
Removing some reflection code
Change-Id: I8a0a707d69999e5f9911e7d8df7d4a659b3dfb8f
(cherry picked from commit e2ec8a3cd52f2322016fcadbae8963a446e2b0b3)
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 50f715634..045b1d33d 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -108,6 +108,10 @@ public final class Utilities { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1; } + public static boolean isNycOrAbove() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N; + } + public static final boolean ATLEAST_MARSHMALLOW = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; @@ -156,33 +160,14 @@ public final class Utilities { 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; - return originalSmallestWidth >= 600; - } catch (Exception e) { - // Ignore - } + Resources res = context.getResources(); + int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp + * res.getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEVICE_STABLE; + return originalSmallestWidth >= 600; } return false; } - public static boolean isNycOrAbove() { - // TODO(vadimt): Replace using reflection with looking at the API version once - // Build.VERSION.SDK_INT gets bumped to 24. b/22942492. - try { - View.class.getDeclaredField("DRAG_FLAG_OPAQUE"); - // View.DRAG_FLAG_OPAQUE doesn't exist in M-release, so it's an indication of N+. - return true; - } catch (NoSuchFieldException e) { - return false; - } - } - // TODO: Use Intent.ACTION_APPLICATION_PREFERENCES when N SDK is available. public static final String ACTION_APPLICATION_PREFERENCES = "android.intent.action.APPLICATION_PREFERENCES"; |