Bug 1291366 - Pre: Inline AppConstants.Versions in GeckoView. r=sebastian
This patch inlines most uses of Versions in GeckoView.
The Android linter can check that symbols only defined in particular
versions of Android are only accessed behind safe guards. However,
our Versions symbolic constants defeat the Android linter's simplistic
code analysis. The value of the linter is (much!) greater than the
explanatory value of our symbolic constants, especially for GeckoView,
which will only ever ship a single library AAR suitable for all
consumers.
I manually tried to squash a few linter errors; subsequent tickets
will track enabling the linter for GeckoView specifically, and burning
down the remaining linter version errors.
MozReview-Commit-ID: cZmNehx8tR
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/AndroidGamepadManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/AndroidGamepadManager.java
@@ -12,16 +12,17 @@ import java.util.TimerTask;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.util.GamepadUtils;
import org.mozilla.gecko.util.ThreadUtils;
import android.content.Context;
import android.hardware.input.InputManager;
+import android.os.Build;
import android.util.SparseArray;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
public class AndroidGamepadManager {
// This is completely arbitrary.
@@ -358,33 +359,32 @@ public class AndroidGamepadManager {
private static void removeGamepad(int deviceId) {
Gamepad gamepad = sGamepads.get(deviceId);
onGamepadChange(gamepad.id, false);
sGamepads.remove(deviceId);
}
private static void addDeviceListener() {
- if (Versions.preJB) {
+ if (Build.VERSION.SDK_INT < 16) {
// Poll known gamepads to see if they've disappeared.
sPollTimer = new Timer();
sPollTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
for (int i = 0; i < sGamepads.size(); ++i) {
final int deviceId = sGamepads.keyAt(i);
if (InputDevice.getDevice(deviceId) == null) {
removeGamepad(deviceId);
}
}
}
}, POLL_TIMER_PERIOD, POLL_TIMER_PERIOD);
- return;
- }
- sListener = new InputManager.InputDeviceListener() {
+ } else {
+ sListener = new InputManager.InputDeviceListener() {
@Override
public void onInputDeviceAdded(int deviceId) {
InputDevice device = InputDevice.getDevice(deviceId);
if (device == null) {
return;
}
if ((device.getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
addGamepad(device);
@@ -403,23 +403,24 @@ public class AndroidGamepadManager {
removeGamepad(deviceId);
}
}
@Override
public void onInputDeviceChanged(int deviceId) {
}
};
- ((InputManager)GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).registerInputDeviceListener(sListener, ThreadUtils.getUiHandler());
+ ((InputManager) GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).registerInputDeviceListener(sListener, ThreadUtils.getUiHandler());
+ }
}
private static void removeDeviceListener() {
- if (Versions.preJB) {
+ if (Build.VERSION.SDK_INT < 16) {
if (sPollTimer != null) {
sPollTimer.cancel();
sPollTimer = null;
}
- return;
+ } else {
+ ((InputManager) GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).unregisterInputDeviceListener(sListener);
+ sListener = null;
}
- ((InputManager)GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).unregisterInputDeviceListener(sListener);
- sListener = null;
}
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAccessibility.java
@@ -9,16 +9,17 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.util.GeckoBundle;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UIAsyncTask;
import android.content.Context;
import android.graphics.Rect;
+import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
@@ -46,17 +47,17 @@ public class GeckoAccessibility {
new UIAsyncTask.WithoutParams<Void>(ThreadUtils.getBackgroundHandler()) {
@Override
public Void doInBackground() {
JSONObject ret = new JSONObject();
sEnabled = false;
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
sEnabled = accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled();
- if (Versions.feature16Plus && sEnabled && sSelfBrailleClient == null) {
+ if (Build.VERSION.SDK_INT >= 16 && sEnabled && sSelfBrailleClient == null) {
sSelfBrailleClient = new SelfBrailleClient(context, false);
}
try {
ret.put("enabled", sEnabled);
} catch (Exception ex) {
Log.e(LOGTAG, "Error building JSON arguments for Accessibility:Settings:", ex);
}
@@ -141,17 +142,17 @@ public class GeckoAccessibility {
if (exitView.equals("moveNext")) {
sCurrentNode = VIRTUAL_ENTRY_POINT_AFTER;
} else if (exitView.equals("movePrevious")) {
sCurrentNode = VIRTUAL_ENTRY_POINT_BEFORE;
} else {
sCurrentNode = VIRTUAL_CURSOR_POSITION;
}
- if (Versions.preJB) {
+ if (Build.VERSION.SDK_INT < 16) {
// Before Jelly Bean we send events directly from here while spoofing the source by setting
// the package and class name manually.
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
sendDirectAccessibilityEvent(eventType, message);
}
});
@@ -231,34 +232,34 @@ public class GeckoAccessibility {
// Set either the focus blink or the current caret position/selection
data.setSelectionStart(selectionStart);
data.setSelectionEnd(selectionEnd);
sSelfBrailleClient.write(data);
}
public static void setDelegate(View view) {
// Only use this delegate in Jelly Bean.
- if (Versions.feature16Plus) {
+ if (Build.VERSION.SDK_INT >= 16) {
view.setAccessibilityDelegate(new GeckoAccessibilityDelegate());
view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
}
public static void setAccessibilityManagerListeners(final Context context) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() {
@Override
public void onAccessibilityStateChanged(boolean enabled) {
updateAccessibilitySettings(context);
}
});
- if (Versions.feature19Plus) {
+ if (Build.VERSION.SDK_INT >= 19) {
accessibilityManager.addTouchExplorationStateChangeListener(new AccessibilityManager.TouchExplorationStateChangeListener() {
@Override
public void onTouchExplorationStateChanged(boolean enabled) {
updateAccessibilitySettings(context);
}
});
}
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -24,17 +24,16 @@ import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import android.annotation.SuppressLint;
import org.mozilla.gecko.annotation.JNITarget;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
-import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.PanZoomController;
import org.mozilla.gecko.permissions.Permissions;
import org.mozilla.gecko.process.GeckoProcessManager;
import org.mozilla.gecko.process.GeckoServiceChildProcess;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.GeckoRequest;
@@ -78,16 +77,17 @@ import android.hardware.SensorEventListe
import android.hardware.SensorManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.SystemClock;
import android.os.Vibrator;
import android.provider.Settings;
import android.telephony.TelephonyManager;
@@ -1501,17 +1501,17 @@ public class GeckoAppShell
return null;
}
// An awful hack to detect Tegra devices. Easiest way to do it without spinning up a EGL context.
boolean isTegra = (new File("/system/lib/hw/gralloc.tegra.so")).exists() ||
(new File("/system/lib/hw/gralloc.tegra3.so")).exists() ||
(new File("/sys/class/nvidia-gpu")).exists();
if (isTegra) {
// disable on KitKat (bug 957694)
- if (Versions.feature19Plus) {
+ if (Build.VERSION.SDK_INT >= 19) {
Log.w(LOGTAG, "Blocking plugins because of Tegra (bug 957694)");
return null;
}
// disable Flash on Tegra ICS with CM9 and other custom firmware (bug 736421)
final File vfile = new File("/proc/version");
try {
if (vfile.canRead()) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
@@ -19,16 +19,17 @@ import org.mozilla.gecko.util.ThreadUtil
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.media.AudioManager;
+import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.Editable;
import android.text.InputType;
import android.text.Selection;
import android.text.SpannableString;
import android.text.method.KeyListener;
@@ -340,17 +341,17 @@ class GeckoInputConnection
return;
}
imm.updateSelection(v, start, end, getComposingSpanStart(editable),
getComposingSpanEnd(editable));
}
@Override
public void updateCompositionRects(final RectF[] aRects) {
- if (!Versions.feature21Plus) {
+ if (!(Build.VERSION.SDK_INT >= 21)) {
return;
}
if (mCursorAnchorInfoBuilder == null) {
mCursorAnchorInfoBuilder = new CursorAnchorInfo.Builder();
}
mCursorAnchorInfoBuilder.reset();
@@ -805,17 +806,17 @@ class GeckoInputConnection
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
case KeyEvent.KEYCODE_MEDIA_CLOSE:
case KeyEvent.KEYCODE_MEDIA_EJECT:
case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
// Forward media keypresses to the registered handler so headset controls work
// Does the same thing as Chromium
// https://chromium.googlesource.com/chromium/src/+/49.0.2623.67/chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java#445
// These are all the keys dispatchMediaKeyEvent supports.
- if (AppConstants.Versions.feature19Plus) {
+ if (Build.VERSION.SDK_INT >= 19) {
// dispatchMediaKeyEvent is only available on Android 4.4+
Context viewContext = getView().getContext();
AudioManager am = (AudioManager)viewContext.getSystemService(Context.AUDIO_SERVICE);
am.dispatchMediaKeyEvent(event);
}
break;
}
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/InputMethods.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/InputMethods.java
@@ -5,16 +5,17 @@
package org.mozilla.gecko;
import java.util.Collection;
import org.mozilla.gecko.AppConstants.Versions;
import android.content.Context;
+import android.os.Build;
import android.provider.Settings.Secure;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
final public class InputMethods {
public static final String METHOD_ANDROID_LATINIME = "com.android.inputmethod.latin/.LatinIME";
public static final String METHOD_ATOK = "com.justsystems.atokmobile.service/.AtokInputMethodService";
public static final String METHOD_GOOGLE_JAPANESE_INPUT = "com.google.android.inputmethod.japanese/.MozcService";
@@ -48,29 +49,29 @@ final public class InputMethods {
}
public static InputMethodManager getInputMethodManager(Context context) {
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}
public static boolean needsSoftResetWorkaround(String inputMethod) {
// Stock latin IME on Android 4.2 and above
- return Versions.feature17Plus &&
+ return Build.VERSION.SDK_INT >= 17 &&
(METHOD_ANDROID_LATINIME.equals(inputMethod) ||
METHOD_GOOGLE_LATINIME.equals(inputMethod));
}
public static boolean shouldCommitCharAsKey(String inputMethod) {
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
}
public static boolean isGestureKeyboard(Context context) {
// SwiftKey is a gesture keyboard, but it doesn't seem to need any special-casing
// to do AwesomeBar auto-spacing.
String inputMethod = getCurrentInputMethod(context);
- return (Versions.feature17Plus &&
+ return (Build.VERSION.SDK_INT >= 17 &&
(METHOD_ANDROID_LATINIME.equals(inputMethod) ||
METHOD_GOOGLE_LATINIME.equals(inputMethod))) ||
METHOD_SWYPE.equals(inputMethod) ||
METHOD_SWYPE_BETA.equals(inputMethod) ||
METHOD_TOUCHPAL_KEYBOARD.equals(inputMethod);
}
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.gfx;
import org.mozilla.gecko.AppConstants.Versions;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
+import android.os.Build;
import android.widget.EdgeEffect;
import java.lang.reflect.Field;
public class OverscrollEdgeEffect implements Overscroll {
// Used to index particular edges in the edges array
private static final int TOP = 0;
private static final int BOTTOM = 1;
@@ -27,17 +28,17 @@ public class OverscrollEdgeEffect implem
// All four edges of the screen
private final EdgeEffect[] mEdges = new EdgeEffect[4];
// The view we're showing this overscroll on.
private final LayerView mView;
public OverscrollEdgeEffect(final LayerView v) {
Field paintField = null;
- if (Versions.feature21Plus) {
+ if (Build.VERSION.SDK_INT >= 21) {
try {
paintField = EdgeEffect.class.getDeclaredField("mPaint");
paintField.setAccessible(true);
} catch (NoSuchFieldException e) {
}
}
mView = v;
@@ -79,17 +80,17 @@ public class OverscrollEdgeEffect implem
return mEdges[LEFT];
} else {
return mEdges[RIGHT];
}
}
}
private void invalidate() {
- if (Versions.feature16Plus) {
+ if (Build.VERSION.SDK_INT >= 16) {
mView.postInvalidateOnAnimation();
} else {
mView.postInvalidateDelayed(10);
}
}
@Override
public void setVelocity(final float velocity, final Axis axis) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
@@ -171,17 +171,17 @@ public final class GeckoLoader {
// setup the downloads path
f = Environment.getDownloadCacheDirectory();
putenv("EXTERNAL_STORAGE=" + f.getPath());
// setup the app-specific cache path
f = context.getCacheDir();
putenv("CACHE_DIRECTORY=" + f.getPath());
- if (AppConstants.Versions.feature17Plus) {
+ if (Build.VERSION.SDK_INT >= 17) {
android.os.UserManager um = (android.os.UserManager)context.getSystemService(Context.USER_SERVICE);
if (um != null) {
putenv("MOZ_ANDROID_USER_SERIAL_NUMBER=" + um.getSerialNumberForUser(android.os.Process.myUserHandle()));
} else {
Log.d(LOGTAG, "Unable to obtain user manager service on a device with SDK version " + Build.VERSION.SDK_INT);
}
}
setupLocaleEnvironment();
@@ -274,17 +274,17 @@ public final class GeckoLoader {
File outDirFile = new File(outDir);
if (!outDirFile.isDirectory()) {
if (!outDirFile.mkdirs()) {
Log.e(LOGTAG, "Couldn't create " + outDir);
return false;
}
}
- if (AppConstants.Versions.feature21Plus) {
+ if (Build.VERSION.SDK_INT >= 21) {
String[] abis = Build.SUPPORTED_ABIS;
for (String abi : abis) {
if (tryLoadWithABI(lib, outDir, apkPath, abi)) {
return true;
}
}
return false;
} else {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ActivityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ActivityUtils.java
@@ -2,35 +2,36 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.util;
import android.app.Activity;
import android.content.Intent;
+import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import org.mozilla.gecko.AppConstants.Versions;
public class ActivityUtils {
private ActivityUtils() {
}
public static void setFullScreen(Activity activity, boolean fullscreen) {
// Hide/show the system notification bar
Window window = activity.getWindow();
- if (Versions.feature16Plus) {
+ if (Build.VERSION.SDK_INT >= 16) {
int newVis;
if (fullscreen) {
newVis = View.SYSTEM_UI_FLAG_FULLSCREEN;
- if (Versions.feature19Plus) {
+ if (Build.VERSION.SDK_INT >= 19) {
newVis |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
} else {
newVis |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
@@ -44,17 +45,17 @@ public class ActivityUtils {
WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
public static boolean isFullScreen(final Activity activity) {
final Window window = activity.getWindow();
- if (Versions.feature16Plus) {
+ if (Build.VERSION.SDK_INT >= 16) {
final int vis = window.getDecorView().getSystemUiVisibility();
return (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
}
final int flags = window.getAttributes().flags;
return ((flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0);
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.util;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants.Versions;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecList;
+import android.os.Build;
import android.util.Log;
public final class HardwareCodecCapabilityUtils {
private static final String LOGTAG = "GeckoHardwareCodecCapabilityUtils";
// List of supported HW VP8 encoders.
private static final String[] supportedVp8HwEncCodecPrefixes =
{"OMX.qcom.", "OMX.Intel." };
@@ -52,34 +53,34 @@ public final class HardwareCodecCapabili
}
}
return false;
}
@WrapForJNI
public static boolean checkSupportsAdaptivePlayback(MediaCodec aCodec, String aMimeType) {
// isFeatureSupported supported on API level >= 19.
- if (!Versions.feature19Plus) {
+ if (!(Build.VERSION.SDK_INT >= 19)) {
return false;
}
try {
MediaCodecInfo info = aCodec.getCodecInfo();
MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(aMimeType);
return capabilities != null &&
capabilities.isFeatureSupported(
MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback);
} catch (IllegalArgumentException e) {
Log.e(LOGTAG, "Retrieve codec information failed", e);
}
return false;
}
public static boolean getHWEncoderCapability() {
- if (Versions.feature20Plus) {
+ if (Build.VERSION.SDK_INT >= 20) {
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
if (!info.isEncoder()) {
continue;
}
String name = null;
for (String mimeType : info.getSupportedTypes()) {
if (mimeType.equals(VP8_MIME_TYPE)) {
@@ -131,17 +132,17 @@ public final class HardwareCodecCapabili
}
@WrapForJNI
public static boolean HasHWVP9() {
return getHWDecoderCapability(VP9_MIME_TYPE);
}
public static boolean getHWDecoderCapability(String aMimeType) {
- if (Versions.feature20Plus) {
+ if (Build.VERSION.SDK_INT >= 20) {
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
if (info.isEncoder()) {
continue;
}
String name = null;
for (String mimeType : info.getSupportedTypes()) {
if (mimeType.equals(aMimeType)) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/WindowUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/WindowUtils.java
@@ -3,16 +3,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.util;
import org.mozilla.gecko.AppConstants.Versions;
import android.content.Context;
+import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import java.lang.reflect.Method;
public class WindowUtils {
@@ -27,17 +28,17 @@ public class WindowUtils {
* via http://stackoverflow.com/a/23861333
*
* @param context the calling Activity's Context
* @return The number of pixels of the device's largest dimension, ignoring software status bars
*/
public static int getLargestDimension(final Context context) {
final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
- if (Versions.feature17Plus) {
+ if (Build.VERSION.SDK_INT >= 17) {
final DisplayMetrics realMetrics = new DisplayMetrics();
display.getRealMetrics(realMetrics);
return Math.max(realMetrics.widthPixels, realMetrics.heightPixels);
} else {
int tempWidth;
int tempHeight;
try {