Эх сурвалжийг харах

Merge pull request #941 from nextcloud/suppressLint

remove suppressLint
Mario Đanić 8 жил өмнө
parent
commit
e55f06ec6e

+ 1 - 3
src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -26,7 +26,6 @@ package com.owncloud.android.ui.activity;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
-import android.annotation.SuppressLint;
 import android.app.Dialog;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -609,7 +608,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
 
         @Nullable
         private File createTempFile(String filename, String text) {
-            File file = new File(((ReceiveExternalFilesActivity)getActivity()).getCacheDir(), filename);
+            File file = new File(getActivity().getCacheDir(), filename);
             FileWriter fw = null;
             try {
                 fw = new FileWriter(file);
@@ -862,7 +861,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
         finish();
     }
 
-    @SuppressLint("NewApi")
     public void uploadFiles() {
 
         UriUploader uploader = new UriUploader(

+ 1 - 5
src/main/java/com/owncloud/android/ui/preview/ImageViewCustom.java

@@ -1,6 +1,5 @@
 package com.owncloud.android.ui.preview;
 
-import android.annotation.SuppressLint;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
@@ -45,7 +44,6 @@ public class ImageViewCustom extends ImageView {
         super(context, attrs, defStyle);
     }
 
-    @SuppressLint("NewApi")
 	@Override
     protected void onDraw(Canvas canvas) {
         if(IS_ICS_OR_HIGHER && checkIfMaximumBitmapExceed(canvas) || IS_VERSION_BUGGY_ON_RECYCLES ) {
@@ -109,10 +107,8 @@ public class ImageViewCustom extends ImageView {
      * @param canvas        Canvas where the view will be drawn into.
      * @return boolean      True means that the bitmap is too big for the canvas.
      */
-    @SuppressLint("NewApi")
 	private boolean checkIfMaximumBitmapExceed(Canvas canvas) {
-        return mBitmapWidth > canvas.getMaximumBitmapWidth()
-                || mBitmapHeight > canvas.getMaximumBitmapHeight();
+        return mBitmapWidth > canvas.getMaximumBitmapWidth() || mBitmapHeight > canvas.getMaximumBitmapHeight();
 
     }
     

+ 3 - 6
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -106,7 +106,6 @@ public class PreviewImageActivity extends FileActivity implements
         // to keep our UI controls visibility in line with system bars visibility
         mFullScreenAnchorView.setOnSystemUiVisibilityChangeListener
                 (new View.OnSystemUiVisibilityChangeListener() {
-                    @SuppressLint("InlinedApi")
                     @Override
                     public void onSystemUiVisibilityChange(int flags) {
                         boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
@@ -230,9 +229,9 @@ public class PreviewImageActivity extends FileActivity implements
                 mUploaderBinder = null;
             }
         }
-    };    
-    
-    
+    }
+
+
     @Override
     public void onStop() {
         super.onStop();
@@ -427,9 +426,7 @@ public class PreviewImageActivity extends FileActivity implements
         return true;
     }
 
-    @SuppressLint("InlinedApi")
     public void toggleFullScreen() {
-
         boolean visible = (mFullScreenAnchorView.getSystemUiVisibility()
                 & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
 

+ 20 - 17
src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -19,7 +19,6 @@
 package com.owncloud.android.ui.preview;
 
 import android.accounts.Account;
-import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.Context;
 import android.content.res.Resources;
@@ -31,6 +30,7 @@ import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.graphics.drawable.PictureDrawable;
 import android.os.AsyncTask;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.StringRes;
@@ -549,7 +549,6 @@ public class PreviewImageFragment extends FileFragment {
             }
         }
 
-        @SuppressLint("InlinedApi")
         private void showLoadedImage(LoadImage result) {
             final ImageViewCustom imageView = mImageViewRef.get();
             Bitmap bitmap = result.bitmap;
@@ -575,20 +574,23 @@ public class PreviewImageFragment extends FileFragment {
                         }
                         layers[1] = bitmapDrawable;
                         LayerDrawable layerDrawable = new LayerDrawable(layers);
-                        if (result.ocFile.getMimetype().equalsIgnoreCase("image/png") ) {
-                            layerDrawable.setLayerHeight(0, convertDpToPixel(bitmap.getHeight(), getActivity()));
-                            layerDrawable.setLayerHeight(1, convertDpToPixel(bitmap.getHeight(), getActivity()));
-                            layerDrawable.setLayerWidth(0, convertDpToPixel(bitmap.getWidth(), getActivity()));
-                            layerDrawable.setLayerWidth(1, convertDpToPixel(bitmap.getWidth(), getActivity()));
-                        } else {
-                            layerDrawable.setLayerHeight(0, convertDpToPixel(bitmapDrawable.getIntrinsicHeight(),
-                                    getActivity()));
-                            layerDrawable.setLayerHeight(1, convertDpToPixel(bitmapDrawable.getIntrinsicHeight(),
-                                    getActivity()));
-                            layerDrawable.setLayerWidth(0, convertDpToPixel(bitmapDrawable.getIntrinsicWidth(),
-                                    getActivity()));
-                            layerDrawable.setLayerWidth(1, convertDpToPixel(bitmapDrawable.getIntrinsicWidth(),
-                                    getActivity()));
+
+                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                            if (result.ocFile.getMimetype().equalsIgnoreCase("image/png")) {
+                                layerDrawable.setLayerHeight(0, convertDpToPixel(bitmap.getHeight(), getActivity()));
+                                layerDrawable.setLayerHeight(1, convertDpToPixel(bitmap.getHeight(), getActivity()));
+                                layerDrawable.setLayerWidth(0, convertDpToPixel(bitmap.getWidth(), getActivity()));
+                                layerDrawable.setLayerWidth(1, convertDpToPixel(bitmap.getWidth(), getActivity()));
+                            } else {
+                                layerDrawable.setLayerHeight(0, convertDpToPixel(bitmapDrawable.getIntrinsicHeight(),
+                                        getActivity()));
+                                layerDrawable.setLayerHeight(1, convertDpToPixel(bitmapDrawable.getIntrinsicHeight(),
+                                        getActivity()));
+                                layerDrawable.setLayerWidth(0, convertDpToPixel(bitmapDrawable.getIntrinsicWidth(),
+                                        getActivity()));
+                                layerDrawable.setLayerWidth(1, convertDpToPixel(bitmapDrawable.getIntrinsicWidth(),
+                                        getActivity()));
+                            }
                         }
                         imageView.setImageDrawable(layerDrawable);
                     } else {
@@ -664,7 +666,8 @@ public class PreviewImageFragment extends FileFragment {
     }
 
     private void toggleImageBackground() {
-        if (getFile() != null && (getFile().getMimetype().equalsIgnoreCase("image/png") ||
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && getFile() != null
+                && (getFile().getMimetype().equalsIgnoreCase("image/png") ||
                 getFile().getMimetype().equalsIgnoreCase("image/svg+xml")) && getActivity() != null
                 && getActivity() instanceof PreviewImageActivity && getResources() != null) {
             PreviewImageActivity previewImageActivity = (PreviewImageActivity) getActivity();