Bug 905223 - Part 0 - Add target API annotations to get rid of errors in Android Studio. r=margaret
Android Studio doesn't recognise our version guards and is consequentially always showing two errors in GeckoApp, which makes it more difficult to spot when you've introduced an actual error.
MozReview-Commit-ID: LpNIwHOhEWE
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -44,16 +44,17 @@ import org.mozilla.gecko.util.GeckoEvent
import org.mozilla.gecko.util.GeckoRequest;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.NativeEventListener;
import org.mozilla.gecko.util.NativeJSObject;
import org.mozilla.gecko.util.PrefUtils;
import org.mozilla.gecko.util.ThreadUtils;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -1596,16 +1597,17 @@ public abstract class GeckoApp
if (ACTION_ALERT_CALLBACK.equals(action)) {
processAlertCallback(intent);
} else if (NotificationHelper.HELPER_BROADCAST_ACTION.equals(action)) {
NotificationHelper.getInstance(getApplicationContext()).handleNotificationIntent(intent);
}
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
if (Versions.preJB) {
mMainLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mMainLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
if (!mInitialized) {
@@ -2324,16 +2326,17 @@ public abstract class GeckoApp
Log.d(LOGTAG, "doRestart(\"" + restartIntent + "\")");
doShutdown();
}
private void doShutdown() {
// Shut down GeckoApp activity.
runOnUiThread(new Runnable() {
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override public void run() {
if (!isFinishing() && (Versions.preJBMR1 || !isDestroyed())) {
finish();
}
}
});
}