[Android] Suppress lint warnings for new APIs used

Geoffrey Métais git at videolan.org
Thu Feb 12 17:12:32 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 12 11:33:30 2015 +0100| [cf39adf78090503f56929c75057a4f86123773f7] | committer: Geoffrey Métais

Suppress lint warnings for new APIs used

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=cf39adf78090503f56929c75057a4f86123773f7
---

 .../src/org/videolan/vlc/gui/MainActivity.java     |   23 ++++++++++++--------
 .../src/org/videolan/vlc/util/AndroidDevices.java  |    3 +++
 vlc-android/src/org/videolan/vlc/util/Util.java    |    2 ++
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 917434d..605b166 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -192,15 +192,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
         /*** Start initializing the UI ***/
 
 
-        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
-        boolean enableBlackTheme = pref.getBoolean("enable_black_theme", false);
-        if (enableBlackTheme) {
-            setTheme(R.style.Theme_VLC_Black);
-            //We need to manually change statusbar color, otherwise, it remains orange.
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-                getWindow().setStatusBarColor(Color.DKGRAY);
-            }
-        }
+        applyTheme();
 
         View v_main = LayoutInflater.from(this).inflate(R.layout.main, null);
         setContentView(v_main);
@@ -283,6 +275,19 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
         reloadPreferences();
     }
 
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+    private void applyTheme() {
+        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+        boolean enableBlackTheme = pref.getBoolean("enable_black_theme", false);
+        if (enableBlackTheme) {
+            setTheme(R.style.Theme_VLC_Black);
+            //We need to manually change statusbar color, otherwise, it remains orange.
+            if (LibVlcUtil.isLolliPopOrLater()) {
+                getWindow().setStatusBarColor(Color.DKGRAY);
+            }
+        }
+    }
+
 
     @Override
     protected void onPostCreate(Bundle savedInstanceState) {
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 81a8191..183f70c 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -33,9 +33,11 @@ import java.util.StringTokenizer;
 import org.videolan.libvlc.LibVlcUtil;
 import org.videolan.vlc.VLCApplication;
 
+import android.annotation.TargetApi;
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
+import android.os.Build;
 import android.os.Build.VERSION;
 import android.os.Build.VERSION_CODES;
 import android.os.Environment;
@@ -149,6 +151,7 @@ public class AndroidDevices {
         return list.toArray(new String[list.size()]);
     }
 
+    @TargetApi(VERSION_CODES.HONEYCOMB_MR1)
     public static float getCenteredAxis(MotionEvent event,
             InputDevice device, int axis) {
         final InputDevice.MotionRange range =
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 6844614..caf821b 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -45,6 +45,7 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.TypedArray;
 import android.net.Uri;
+import android.os.Build;
 import android.provider.MediaStore;
 import android.text.TextUtils.TruncateAt;
 import android.util.DisplayMetrics;
@@ -253,6 +254,7 @@ public class Util {
             editor.commit();
     }
 
+    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
     public static boolean deleteFile (Context context, String path){
         boolean deleted = false;
         if (path.startsWith("file://"))



More information about the Android mailing list