From 97da0cbc94c61ef312e17781b3cc750286467e86 Mon Sep 17 00:00:00 2001 From: Iskra Delta Date: Thu, 13 Oct 2016 10:57:15 +0000 Subject: [PATCH] FindBugs appeased --- build.gradle | 1 + src/com/owncloud/android/MainApp.java | 4 ++- .../authentication/AuthenticatorActivity.java | 3 +- .../datamodel/FileDataStorageManager.java | 31 +++++++++---------- .../owncloud/android/datamodel/OCFile.java | 23 ++++++++------ .../datamodel/ThumbnailsCacheManager.java | 8 +++-- .../android/media/MediaControlView.java | 15 ++++----- .../owncloud/android/media/MediaService.java | 2 +- .../operations/OAuth2GetAccessToken.java | 4 --- .../ui/activity/LogHistoryActivity.java | 11 ++++--- .../ui/activity/ManageAccountsActivity.java | 8 ----- .../ReceiveExternalFilesActivity.java | 2 +- .../adapter/ExpandableUploadListAdapter.java | 4 +++ .../ui/adapter/FileListListAdapter.java | 9 ++---- .../ui/helpers/FileOperationsHelper.java | 7 +++-- .../ui/notifications/NotificationUtils.java | 4 +-- .../ui/preview/PreviewImageActivity.java | 8 +++-- .../ui/preview/PreviewImageFragment.java | 2 ++ .../ui/preview/PreviewTextFragment.java | 5 +-- .../android/utils/FileStorageUtils.java | 7 +++++ src/com/owncloud/android/utils/UriUtils.java | 4 ++- .../cube/GridViewWithHeaderAndFooter.java | 2 +- 22 files changed, 91 insertions(+), 73 deletions(-) diff --git a/build.gradle b/build.gradle index a61c40d90d..d11428f6d3 100644 --- a/build.gradle +++ b/build.gradle @@ -47,6 +47,7 @@ dependencies { compile 'com.jakewharton:disklrucache:2.0.2' compile "com.android.support:appcompat-v7:${supportLibraryVersion}" compile 'com.getbase:floatingactionbutton:1.10.1' + compile 'com.google.code.findbugs:annotations:2.0.1' /// dependencies for local unit tests diff --git a/src/com/owncloud/android/MainApp.java b/src/com/owncloud/android/MainApp.java index d77c674df7..de0d17026b 100644 --- a/src/com/owncloud/android/MainApp.java +++ b/src/com/owncloud/android/MainApp.java @@ -37,6 +37,8 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.Preferences; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Main Application of the project @@ -61,7 +63,7 @@ public class MainApp extends Application { private static boolean mOnlyOnDevice = false; - + @SuppressFBWarnings("ST") public void onCreate(){ super.onCreate(); MainApp.mContext = getApplicationContext(); diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index f703d14fb4..99f0b5b2a0 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -91,7 +91,7 @@ import com.owncloud.android.ui.dialog.SamlWebViewDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener; import com.owncloud.android.utils.DisplayUtils; - +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.security.cert.X509Certificate; import java.util.Map; @@ -1576,6 +1576,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * * TODO Decide how to name the OAuth accounts */ + @SuppressFBWarnings("DMI") private boolean createAccount(RemoteOperationResult authResult) { /// create and save new ownCloud account boolean isOAuth = AccountTypeUtils. diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 34ba10bd19..3eb3407fb8 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -1111,7 +1111,7 @@ public class FileDataStorageManager { * @return First {@OCShare} instance found in DB bound to the file in 'path' */ public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) { - Cursor c = null; + Cursor cursor = null; if (shareWith == null) { shareWith = ""; } @@ -1140,14 +1140,14 @@ public class FileDataStorageManager { } if (getContentResolver() != null) { - c = getContentResolver().query( + cursor = getContentResolver().query( ProviderTableMeta.CONTENT_URI_SHARE, null, selection, selectionArgs, null); } else { try { - c = getContentProviderClient().query( + cursor = getContentProviderClient().query( ProviderTableMeta.CONTENT_URI_SHARE, null, selection, selectionArgs, @@ -1155,14 +1155,14 @@ public class FileDataStorageManager { } catch (RemoteException e) { Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); - c = null; + cursor = null; } } OCShare share = null; - if (c.moveToFirst()) { - share = createShareInstance(c); + if (cursor != null && cursor.moveToFirst()) { + share = createShareInstance(cursor); + cursor.close(); } - c.close(); return share; } @@ -1666,32 +1666,31 @@ public class FileDataStorageManager { Integer.toString(ShareType.GROUP.getValue()), Integer.toString(ShareType.FEDERATED.getValue())}; - Cursor c = null; + Cursor cursor = null; if (getContentResolver() != null) { - c = getContentResolver().query( + cursor = getContentResolver().query( ProviderTableMeta.CONTENT_URI_SHARE, null, where, whereArgs, null); } else { try { - c = getContentProviderClient().query( + cursor = getContentProviderClient().query( ProviderTableMeta.CONTENT_URI_SHARE, null, where, whereArgs, null); } catch (RemoteException e) { Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage()); - c = null; + cursor = null; } } ArrayList shares = new ArrayList(); OCShare share = null; - if (c.moveToFirst()) { + if (cursor != null && cursor.moveToFirst()) { do { - share = createShareInstance(c); + share = createShareInstance(cursor); shares.add(share); - // } - } while (c.moveToNext()); + } while (cursor.moveToNext()); + cursor.close(); } - c.close(); return shares; } diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index b2bc883ff1..34761b98f3 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -549,22 +549,27 @@ public class OCFile implements Parcelable, Comparable { @Override public boolean equals(Object o) { - if (o instanceof OCFile) { - OCFile that = (OCFile) o; - if (that != null) { - return this.mId == that.mId; - } - } + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - return false; + OCFile ocFile = (OCFile) o; + + return mId == ocFile.mId && mParentId == ocFile.mParentId; + } + + @Override + public int hashCode() { + int result = (int) (mId ^ (mId >>> 32)); + result = 31 * result + (int) (mParentId ^ (mParentId >>> 32)); + return result; } @Override public String toString() { String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " + "parentId=%s, favorite=%s etag=%s]"; - asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), - mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mFavorite), + asString = String.format(asString, mId, getFileName(), mMimeType, isDown(), + mLocalPath, mRemotePath, mParentId, mFavorite, mEtag); return asString; } diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 9778ab406c..619c58645e 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -57,6 +57,8 @@ import java.io.File; import java.io.InputStream; import java.lang.ref.WeakReference; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Manager for concurrent access to thumbnails cache. */ @@ -75,13 +77,13 @@ public class ThumbnailsCacheManager { private static final int mCompressQuality = 70; private static OwnCloudClient mClient = null; - public static Bitmap mDefaultImg = + public static final Bitmap mDefaultImg = BitmapFactory.decodeResource( MainApp.getAppContext().getResources(), R.drawable.file_image ); - public static Bitmap mDefaultVideo = + public static final Bitmap mDefaultVideo = BitmapFactory.decodeResource( MainApp.getAppContext().getResources(), R.drawable.file_movie @@ -180,6 +182,7 @@ public class ThumbnailsCacheManager { mImageViewReference = new WeakReference(imageView); } + @SuppressFBWarnings("Dm") @Override protected Bitmap doInBackground(Object... params) { Bitmap thumbnail = null; @@ -403,6 +406,7 @@ public class ThumbnailsCacheManager { mAccount = account; } + @SuppressFBWarnings("Dm") @Override protected Bitmap doInBackground(String... params) { Bitmap thumbnail = null; diff --git a/src/com/owncloud/android/media/MediaControlView.java b/src/com/owncloud/android/media/MediaControlView.java index 5f2d46d4c6..0978f3436d 100644 --- a/src/com/owncloud/android/media/MediaControlView.java +++ b/src/com/owncloud/android/media/MediaControlView.java @@ -265,14 +265,12 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi @Override public void handleMessage(Message msg) { int pos; - switch (msg.what) { - case SHOW_PROGRESS: - pos = setProgress(); - if (!mDragging) { - msg = obtainMessage(SHOW_PROGRESS); - sendMessageDelayed(msg, 1000 - (pos % 1000)); - } - break; + if (msg.what == SHOW_PROGRESS) { + pos = setProgress(); + if (!mDragging) { + msg = obtainMessage(SHOW_PROGRESS); + sendMessageDelayed(msg, 1000 - (pos % 1000)); + } } } }; @@ -417,7 +415,6 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi if (!playing) mPlayer.pause(); // necessary in some 2.3.x devices setProgress(); break; - } } diff --git a/src/com/owncloud/android/media/MediaService.java b/src/com/owncloud/android/media/MediaService.java index 8be6c614ed..f7ca1689f5 100644 --- a/src/com/owncloud/android/media/MediaService.java +++ b/src/com/owncloud/android/media/MediaService.java @@ -68,7 +68,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre /// Keys to add extras to the action public static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE"; public static final String EXTRA_ACCOUNT = MY_PACKAGE + ".extra.ACCOUNT"; - public static String EXTRA_START_POSITION = MY_PACKAGE + ".extra.START_POSITION"; + public static final String EXTRA_START_POSITION = MY_PACKAGE + ".extra.START_POSITION"; public static final String EXTRA_PLAY_ON_LOAD = MY_PACKAGE + ".extra.PLAY_ON_LOAD"; diff --git a/src/com/owncloud/android/operations/OAuth2GetAccessToken.java b/src/com/owncloud/android/operations/OAuth2GetAccessToken.java index 918c57bb8b..590f018b2a 100644 --- a/src/com/owncloud/android/operations/OAuth2GetAccessToken.java +++ b/src/com/owncloud/android/operations/OAuth2GetAccessToken.java @@ -141,7 +141,6 @@ public class OAuth2GetAccessToken extends RemoteOperation { int i = 0; String key = ""; String value = ""; - StringBuilder sb = new StringBuilder(); while (pairs.length > i) { int j = 0; String[] part = pairs[i].split("="); @@ -149,13 +148,10 @@ public class OAuth2GetAccessToken extends RemoteOperation { String p = part[j]; if (j == 0) { key = p; - sb.append(key + " = "); } else if (j == 1) { value = p; mOAuth2ParsedAuthorizationResponse.put(key, value); - sb.append(value + "\n"); } - Log_OC.v(TAG, "[" + i + "," + j + "] = " + p); j++; } diff --git a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java index 3c13c0d07f..084503a1e4 100644 --- a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java +++ b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java @@ -41,8 +41,10 @@ import com.owncloud.android.utils.FileStorageUtils; import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.util.ArrayList; @@ -191,7 +193,7 @@ public class LogHistoryActivity extends ToolbarActivity { } protected void onPostExecute(String result) { - if (textViewReference != null && result != null) { + if (result != null) { final TextView logTV = textViewReference.get(); if (logTV != null) { mLogText = result; @@ -219,8 +221,9 @@ public class LogHistoryActivity extends ToolbarActivity { File file = new File(mLogPath,logFileName[i]); if (file.exists()) { // Check if FileReader is ready - if (new FileReader(file).ready()) { - br = new BufferedReader(new FileReader(file)); + final InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), "UTF8"); + if (inputStreamReader.ready()) { + br = new BufferedReader(inputStreamReader); while ((line = br.readLine()) != null) { // Append the log info text.append(line); @@ -231,7 +234,7 @@ public class LogHistoryActivity extends ToolbarActivity { } } catch (IOException e) { - Log_OC.d(TAG, e.getMessage().toString()); + Log_OC.d(TAG, e.getMessage()); } finally { if (br != null) { diff --git a/src/com/owncloud/android/ui/activity/ManageAccountsActivity.java b/src/com/owncloud/android/ui/activity/ManageAccountsActivity.java index a4866ffa39..560611b9c9 100644 --- a/src/com/owncloud/android/ui/activity/ManageAccountsActivity.java +++ b/src/com/owncloud/android/ui/activity/ManageAccountsActivity.java @@ -75,8 +75,6 @@ public class ManageAccountsActivity extends FileActivity private final Handler mHandler = new Handler(); private String mAccountName; private AccountListAdapter mAccountListAdapter; - protected FileUploader.FileUploaderBinder mUploaderBinder = null; - protected FileDownloader.FileDownloaderBinder mDownloaderBinder = null; private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null; Set mOriginalAccounts; String mOriginalCurrentAccount; @@ -329,12 +327,6 @@ public class ManageAccountsActivity extends FileActivity public Handler getHandler() { return mHandler; } - // Methods for ComponentsGetter - @Override - public FileDownloader.FileDownloaderBinder getFileDownloaderBinder() { - return mDownloaderBinder; - } - @Override public FileUploader.FileUploaderBinder getFileUploaderBinder() { return mUploaderBinder; diff --git a/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 5b820bd921..58214dec89 100644 --- a/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -361,7 +361,7 @@ public class ReceiveExternalFilesActivity extends FileActivity PrintWriter out; try { File f = File.createTempFile("nextcloud", TEXT_FILE_SUFFIX); - out = new PrintWriter(f); + out = new PrintWriter(f, "UTF8"); out.println(getIntent().getStringExtra(Intent.EXTRA_TEXT)); out.close(); diff --git a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java index ec59c70154..2c9a7f709f 100755 --- a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java @@ -58,6 +58,8 @@ import java.util.Comparator; import java.util.Observable; import java.util.Observer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * This Adapter populates a ListView with following types of uploads: pending, * active, completed. Filtering possible. @@ -116,10 +118,12 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple } } + @SuppressFBWarnings("Bx") private int compareUploadId(OCUpload upload1, OCUpload upload2) { return Long.valueOf(upload1.getUploadId()).compareTo(upload2.getUploadId()); } + @SuppressFBWarnings("Bx") private int compareUpdateTime(OCUpload upload1, OCUpload upload2) { return Long.valueOf(upload2.getUploadEndTimestamp()).compareTo(upload1.getUploadEndTimestamp()); } diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index a884201149..2a22073a9b 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -394,19 +394,16 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd if (mJustFolders) { mFiles = getFolders(mFiles); } - if (!mShowHiddenFiles) { mFiles = filterHiddenFiles(mFiles); } + mFiles = FileStorageUtils.sortOcFolder(mFiles); + mFilesAll.addAll(mFiles); } else { mFiles = null; + mFilesAll.clear(); } - mFiles = FileStorageUtils.sortOcFolder(mFiles); - - mFilesAll.clear(); - mFilesAll.addAll(mFiles); - notifyDataSetChanged(); } diff --git a/src/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/src/com/owncloud/android/ui/helpers/FileOperationsHelper.java index b1aaadb16b..5b81ecd6b8 100755 --- a/src/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/src/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -51,8 +51,11 @@ import com.owncloud.android.ui.activity.ShareActivity; import com.owncloud.android.ui.dialog.ShareLinkToDialog; import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.List; import java.util.regex.Matcher; @@ -83,10 +86,10 @@ public class FileOperationsHelper { private String getUrlFromFile(String storagePath, Pattern pattern) { String url = null; - FileReader fr = null; + InputStreamReader fr = null; BufferedReader br = null; try { - fr = new FileReader(storagePath); + fr = new InputStreamReader(new FileInputStream(storagePath), "UTF8"); br = new BufferedReader(fr); String line; diff --git a/src/com/owncloud/android/ui/notifications/NotificationUtils.java b/src/com/owncloud/android/ui/notifications/NotificationUtils.java index 1cde2a189e..252c549b11 100644 --- a/src/com/owncloud/android/ui/notifications/NotificationUtils.java +++ b/src/com/owncloud/android/ui/notifications/NotificationUtils.java @@ -27,7 +27,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Process; import android.support.v4.app.NotificationCompat; - +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import com.owncloud.android.R; public class NotificationUtils { @@ -52,7 +52,7 @@ public class NotificationUtils { setColor(context.getResources().getColor(R.color.primary)); } - + @SuppressFBWarnings("DMI") public static void cancelWithDelay( final NotificationManager notificationManager, final int notificationId, diff --git a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java index 01177a2f81..fd70dddd56 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -59,6 +59,8 @@ import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.MimeTypeUtil; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Holds a swiping galley where image files contained in an ownCloud directory are shown @@ -348,10 +350,11 @@ public class PreviewImageActivity extends FileActivity implements private void backToDisplayActivity() { finish(); } - + + @SuppressFBWarnings("DLS") @Override public void showDetails(OCFile file) { - Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class); + final Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class); showDetailsIntent.setAction(FileDisplayActivity.ACTION_DETAILS); showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, file); showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, @@ -359,7 +362,6 @@ public class PreviewImageActivity extends FileActivity implements startActivity(showDetailsIntent); int pos = mPreviewImagePagerAdapter.getFilePosition(file); file = mPreviewImagePagerAdapter.getFileAt(pos); - } private void requestForDownload(OCFile file) { diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index fd168baeb8..c781a37581 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -52,6 +52,7 @@ import com.owncloud.android.utils.MimeTypeUtil; import java.lang.ref.WeakReference; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import third_parties.michaelOrtiz.TouchImageViewCustom; @@ -340,6 +341,7 @@ public class PreviewImageFragment extends FileFragment { super.onPause(); } + @SuppressFBWarnings("Dm") @Override public void onDestroy() { if (mBitmap != null) { diff --git a/src/com/owncloud/android/ui/preview/PreviewTextFragment.java b/src/com/owncloud/android/ui/preview/PreviewTextFragment.java index 2e2abdf1b7..27f3d2014c 100644 --- a/src/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -47,6 +47,7 @@ import com.owncloud.android.utils.MimeTypeUtil; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.io.StringWriter; import java.lang.ref.WeakReference; import java.util.LinkedList; @@ -175,12 +176,12 @@ public class PreviewTextFragment extends FileFragment { } final String location = (String) params[0]; - FileInputStream inputStream = null; + InputStreamReader inputStream = null; Scanner sc = null; StringWriter source = new StringWriter(); BufferedWriter bufferedWriter = new BufferedWriter(source); try { - inputStream = new FileInputStream(location); + inputStream = new InputStreamReader(new FileInputStream(location), "UTF8"); sc = new Scanner(inputStream); while (sc.hasNextLine()) { bufferedWriter.append(sc.nextLine()); diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index e9dd630927..937bd912dd 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -50,6 +50,7 @@ import java.util.List; import java.util.Locale; import java.util.Vector; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import third_parties.daveKoeller.AlphanumComparator; @@ -271,6 +272,7 @@ public class FileStorageUtils { final int multiplier = mSortAscending ? 1 : -1; Collections.sort(files, new Comparator() { + @SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level") public int compare(OCFile o1, OCFile o2) { Long obj1 = o1.getModificationTimestamp(); return multiplier * obj1.compareTo(o2.getModificationTimestamp()); @@ -290,6 +292,7 @@ public class FileStorageUtils { List files = new ArrayList(Arrays.asList(filesArray)); Collections.sort(files, new Comparator() { + @SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level") public int compare(File o1, File o2) { Long obj1 = o1.lastModified(); return multiplier * obj1.compareTo(o2.lastModified()); @@ -307,12 +310,14 @@ public class FileStorageUtils { final int multiplier = mSortAscending ? 1 : -1; Collections.sort(files, new Comparator() { + @SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level") public int compare(OCFile o1, OCFile o2) { if (o1.isFolder() && o2.isFolder()) { Long obj1 = o1.getFileLength(); return multiplier * obj1.compareTo(o2.getFileLength()); } else if (o1.isFolder()) { return -1; + } else if (o2.isFolder()) { return 1; } else { @@ -334,6 +339,7 @@ public class FileStorageUtils { List files = new ArrayList(Arrays.asList(filesArray)); Collections.sort(files, new Comparator() { + @SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level") public int compare(File o1, File o2) { if (o1.isDirectory() && o2.isDirectory()) { Long obj1 = getFolderSize(o1); @@ -357,6 +363,7 @@ public class FileStorageUtils { * Sorts list by Name * @param files files to sort */ + @SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level") public static Vector sortOCFilesByName(Vector files){ final int multiplier = mSortAscending ? 1 : -1; diff --git a/src/com/owncloud/android/utils/UriUtils.java b/src/com/owncloud/android/utils/UriUtils.java index 598e784d8a..b0ebd809cd 100644 --- a/src/com/owncloud/android/utils/UriUtils.java +++ b/src/com/owncloud/android/utils/UriUtils.java @@ -33,6 +33,8 @@ import android.webkit.MimeTypeMap; import com.owncloud.android.lib.common.utils.Log_OC; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * A helper class for some Uri operations. @@ -123,6 +125,7 @@ public class UriUtils { * @return The path in the file system to the content or null if it could not be found (not a file) */ @TargetApi(Build.VERSION_CODES.KITKAT) + @SuppressFBWarnings("Bx") public static String getLocalPath(Uri uri, Context context) { final boolean isKitKatOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; @@ -246,7 +249,6 @@ public class UriUtils { } else if (MimeTypeUtil.isAudio(mimeType)) { displayNameColumn = MediaStore.Audio.AudioColumns.DISPLAY_NAME; - } else { displayNameColumn = MediaStore.Files.FileColumns.DISPLAY_NAME; } diff --git a/src/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java b/src/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java index 0f05732d21..51c0249481 100644 --- a/src/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java +++ b/src/third_parties/in/srain/cube/GridViewWithHeaderAndFooter.java @@ -45,7 +45,7 @@ import java.util.ArrayList; */ public class GridViewWithHeaderAndFooter extends GridView { - public static boolean DEBUG = false; + public static final boolean DEBUG = false; /** * A class that represents a fixed view in a list, for example a header at the top