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