Bug 905223 - Part 0 - Add target API annotations to get rid of errors in Android Studio. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 23 Apr 2016 22:29:03 +0200
changeset 372203 228680711ecefeb116bf40dfc00f5dcbe0f8a08a
parent 371419 813cd9bb48769625212e50567ef6ecf87bc884f8
child 372204 d531c2f6793b1fddc868a65cc37349d98baefedb
child 372222 a4ae2ff5005089954e0333f3c60e98a48a9fb62a
push id19474
push usermozilla@buttercookie.de
push dateFri, 27 May 2016 19:15:24 +0000
reviewersmargaret
bugs905223
milestone49.0a1
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
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- 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();
                 }
             }
         });
     }