diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh
index 8f93b0a8b7..9e756d3635 100755
--- a/scripts/analysis/analysis-wrapper.sh
+++ b/scripts/analysis/analysis-wrapper.sh
@@ -127,7 +127,12 @@ else
gplayLimitation="
Following files are beyond 500 char limit:
"$gplayLimitation
fi
- curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$codacyResult $lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage $lintMessage $findbugsMessage $gplayLimitation \" }"
+ # check for NotNull
+ if [[ $(grep org.jetbrains.annotations src/main/* -ir -c) -gt 0 ]] ; then
+ notNull="org.jetbrains.annotations.NotNull is used. Please use androidx.annotation.NonNull instead.
"
+ fi
+
+ curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$codacyResult $lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage $lintMessage $findbugsMessage $gplayLimitation $notNull\" }"
if [ ! -z "$gplayLimitation" ]; then
exit 1
@@ -141,6 +146,10 @@ else
exit $lintValue
fi
+ if [ $notNull -gt 0 ]; then
+ exit 1
+ fi
+
if [ $findbugsValue -eq 2 ]; then
exit 0
else
diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt
index 9b5c4542c7..272a4581e9 100644
--- a/scripts/analysis/findbugs-results.txt
+++ b/scripts/analysis/findbugs-results.txt
@@ -1 +1 @@
-319
+316
\ No newline at end of file
diff --git a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java
index 9e75c5ae29..0e511102c5 100644
--- a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java
+++ b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java
@@ -24,10 +24,10 @@ import com.google.gson.annotations.SerializedName;
import org.parceler.Parcel;
-@Parcel
/*
* Push data from server, https://github.com/nextcloud/notifications/blob/master/docs/push-v2.md#encrypted-subject-data
*/
+@Parcel
public class DecryptedPushMessage {
public String app;
public String type;
@@ -49,6 +49,7 @@ public class DecryptedPushMessage {
}
public DecryptedPushMessage() {
+ // empty constructor
}
public String getApp() {
diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
index 2a05c7c879..24ff2fc477 100644
--- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
+++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
@@ -1178,13 +1178,11 @@ public class FileDataStorageManager {
*/
public List getSharesByPathAndType(String path, ShareType type, String shareWith) {
Cursor cursor;
- if (shareWith == null) {
- shareWith = "";
- }
String selection = ProviderTableMeta.OCSHARES_PATH + AND
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
+
if (!ShareType.PUBLIC_LINK.equals(type)) {
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
}
@@ -1197,12 +1195,21 @@ public class FileDataStorageManager {
account.name
};
} else {
- selectionArgs = new String[]{
- path,
- Integer.toString(type.getValue()),
- account.name,
- shareWith
- };
+ if (shareWith == null) {
+ selectionArgs = new String[]{
+ path,
+ Integer.toString(type.getValue()),
+ account.name,
+ ""
+ };
+ } else {
+ selectionArgs = new String[]{
+ path,
+ Integer.toString(type.getValue()),
+ account.name,
+ shareWith
+ };
+ }
}
if (getContentResolver() != null) {
@@ -1775,11 +1782,13 @@ public class FileDataStorageManager {
}
public void saveConflict(OCFile ocFile, String etagInConflict) {
- if (!ocFile.isDown()) {
- etagInConflict = null;
- }
ContentValues cv = new ContentValues();
- cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
+ if (!ocFile.isDown()) {
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, (String) null);
+ } else {
+ cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
+ }
+
int updated = 0;
if (getContentResolver() != null) {
updated = getContentResolver().update(
@@ -1804,7 +1813,7 @@ public class FileDataStorageManager {
Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated);
if (updated > 0) {
- if (etagInConflict != null) {
+ if (etagInConflict != null && ocFile.isDown()) {
/// set conflict in all ancestor folders
long parentId = ocFile.getParentId();
@@ -1922,7 +1931,6 @@ public class FileDataStorageManager {
}
}
}
-
}
public void saveCapabilities(OCCapability capability) {
diff --git a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java
index dc315369cb..de95b5a70e 100644
--- a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java
+++ b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java
@@ -49,6 +49,7 @@ public class FileSystemDataSet {
}
public FileSystemDataSet() {
+ // empty constructor
}
public int getId() {
diff --git a/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java b/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java
index 5acc695e15..5b164012eb 100644
--- a/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java
+++ b/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java
@@ -33,9 +33,6 @@ public class MediaFoldersModel {
this.videoMediaFolders = videoMediaFolders;
}
- public MediaFoldersModel() {
- }
-
public List getImageMediaFolders() {
return this.imageMediaFolders;
}
diff --git a/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java b/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java
index cd2a77aaa5..b3552840d3 100644
--- a/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java
+++ b/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java
@@ -38,6 +38,7 @@ public class PushConfigurationState {
}
public PushConfigurationState() {
+ // empty constructor for JSON parser
}
public String getPushToken() {
diff --git a/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java b/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java
index be970accda..bb44a55352 100644
--- a/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java
+++ b/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java
@@ -34,6 +34,7 @@ public class SignatureVerification {
}
public SignatureVerification() {
+ // empty constructor
}
public boolean isSignatureValid() {
diff --git a/src/main/java/com/owncloud/android/datamodel/Template.java b/src/main/java/com/owncloud/android/datamodel/Template.java
index e98fb30efb..0e6b8cc22c 100644
--- a/src/main/java/com/owncloud/android/datamodel/Template.java
+++ b/src/main/java/com/owncloud/android/datamodel/Template.java
@@ -27,9 +27,18 @@ import java.util.Locale;
/**
* Template for creating a file from it via RichDocuments app
*/
-
@Parcel
public class Template {
+ public int id;
+ public String name;
+ public String thumbnailLink;
+ public Type type;
+ public String extension;
+
+ public Template() {
+ // empty constructor
+ }
+
public Template(int id, String name, String thumbnailLink, Type type, String extension) {
this.id = id;
this.name = name;
@@ -38,7 +47,21 @@ public class Template {
this.extension = extension;
}
- public Template() {
+ public enum Type {
+ DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN
+ }
+
+ public static Type parse(String type) {
+ switch (type.toLowerCase(Locale.US)) {
+ case "document":
+ return Type.DOCUMENT;
+ case "spreadsheet":
+ return Type.SPREADSHEET;
+ case "presentation":
+ return Type.PRESENTATION;
+ default:
+ return Type.UNKNOWN;
+ }
}
public int getId() {
@@ -80,27 +103,4 @@ public class Template {
public void setExtension(String extension) {
this.extension = extension;
}
-
- public enum Type {
- DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN
- }
-
- public static Type parse(String type) {
- switch (type.toLowerCase(Locale.US)) {
- case "document":
- return Type.DOCUMENT;
- case "spreadsheet":
- return Type.SPREADSHEET;
- case "presentation":
- return Type.PRESENTATION;
- default:
- return Type.UNKNOWN;
- }
- }
-
- public int id;
- public String name;
- public String thumbnailLink;
- public Type type;
- public String extension;
}
diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
index 04a3d1ae5f..540ced80b0 100644
--- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
+++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
@@ -933,7 +933,7 @@ public final class ThumbnailsCacheManager {
avatar = getBitmapFromDiskCache(avatarKey);
// Download avatar from server, only if older than 60 min or avatar does not exist
- if ((System.currentTimeMillis() - timestamp >= 60 * 60 * 1000 || avatar == null)) {
+ if (System.currentTimeMillis() - timestamp >= 60 * 60 * 1000 || avatar == null) {
GetMethod get = null;
try {
if (mAccount != null) {
diff --git a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java
index 2beda44341..b0458d7425 100644
--- a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java
+++ b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java
@@ -25,6 +25,11 @@ package com.owncloud.android.datastorage;
* @author Bartosz Przybylski
*/
public class StoragePoint implements Comparable {
+ private String description;
+ private String path;
+ private StorageType storageType;
+ private PrivacyType privacyType;
+
public StoragePoint(String description, String path, StorageType storageType, PrivacyType privacyType) {
this.description = description;
this.path = path;
@@ -33,6 +38,7 @@ public class StoragePoint implements Comparable {
}
public StoragePoint() {
+ // empty constructor
}
public String getDescription() {
@@ -75,11 +81,6 @@ public class StoragePoint implements Comparable {
PRIVATE, PUBLIC
}
- private String description;
- private String path;
- private StorageType storageType;
- private PrivacyType privacyType;
-
@Override
public int compareTo(StoragePoint another) {
return path.compareTo(another.getPath());
diff --git a/src/main/java/com/owncloud/android/media/MediaControlView.java b/src/main/java/com/owncloud/android/media/MediaControlView.java
index ddbc2547f9..c001ae071d 100644
--- a/src/main/java/com/owncloud/android/media/MediaControlView.java
+++ b/src/main/java/com/owncloud/android/media/MediaControlView.java
@@ -165,13 +165,11 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
- int pos;
if (msg.what == SHOW_PROGRESS) {
updatePausePlay();
- pos = setProgress();
+ int pos = setProgress();
if (!isDragging) {
- msg = obtainMessage(SHOW_PROGRESS);
- sendMessageDelayed(msg, 1000 - (pos % 1000));
+ sendMessageDelayed(obtainMessage(SHOW_PROGRESS), 1000 - (pos % 1000));
}
}
}
diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java
index 2ea40e7292..32d36be001 100644
--- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java
+++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java
@@ -46,13 +46,14 @@ import com.owncloud.android.utils.MimeType;
import java.io.File;
import java.util.UUID;
+import androidx.annotation.NonNull;
+
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
-
/**
- * Access to remote operation performing the creation of a new folder in the ownCloud server. Save the new folder in
- * Database
+ * Access to remote operation performing the creation of a new folder in the ownCloud server.
+ * Save the new folder in Database.
*/
public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener {
@@ -75,8 +76,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
String remoteParentPath = new File(getRemotePath()).getParent();
- remoteParentPath = remoteParentPath.endsWith(OCFile.PATH_SEPARATOR) ?
- remoteParentPath : remoteParentPath + OCFile.PATH_SEPARATOR;
+ remoteParentPath = remoteParentPath.endsWith(PATH_SEPARATOR) ?
+ remoteParentPath : remoteParentPath + PATH_SEPARATOR;
OCFile parent = getStorageManager().getFileByDecryptedRemotePath(remoteParentPath);
@@ -84,8 +85,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
while (parent == null) {
tempRemoteParentPath = new File(tempRemoteParentPath).getParent();
- if (!tempRemoteParentPath.endsWith(OCFile.PATH_SEPARATOR)) {
- tempRemoteParentPath = tempRemoteParentPath + OCFile.PATH_SEPARATOR;
+ if (!tempRemoteParentPath.endsWith(PATH_SEPARATOR)) {
+ tempRemoteParentPath = tempRemoteParentPath + PATH_SEPARATOR;
}
parent = getStorageManager().getFileByDecryptedRemotePath(tempRemoteParentPath);
@@ -95,13 +96,13 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager());
if (encryptedAncestor) {
- return encryptedCreate(parent, remoteParentPath, client);
+ return encryptedCreate(parent, client);
} else {
return normalCreate(client);
}
}
- private RemoteOperationResult encryptedCreate(OCFile parent, String remoteParentPath, OwnCloudClient client) {
+ private RemoteOperationResult encryptedCreate(OCFile parent, OwnCloudClient client) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
String publicKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PUBLIC_KEY);
@@ -127,20 +128,12 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
metadata = metadataPair.second;
// check if filename already exists
- for (String key : metadata.getFiles().keySet()) {
- DecryptedFolderMetadata.DecryptedFile file = metadata.getFiles().get(key);
-
- if (file != null && filename.equalsIgnoreCase(file.getEncrypted().getFilename())) {
- return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS);
- }
+ if (isFileExisting(metadata, filename)) {
+ return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS);
}
// generate new random file name, check if it exists in metadata
- String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
-
- while (metadata.getFiles().get(encryptedFileName) != null) {
- encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
- }
+ String encryptedFileName = createRandomFileName(metadata);
encryptedRemotePath = parent.getRemotePath() + encryptedFileName;
RemoteOperationResult result = new CreateFolderRemoteOperation(encryptedRemotePath,
@@ -149,23 +142,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
.execute(client);
if (result.isSuccess()) {
- // Key, always generate new one
- byte[] key = EncryptionUtils.generateKey();
-
- // IV, always generate new one
- byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength);
-
// update metadata
- DecryptedFolderMetadata.DecryptedFile decryptedFile = new DecryptedFolderMetadata.DecryptedFile();
- DecryptedFolderMetadata.Data data = new DecryptedFolderMetadata.Data();
- data.setFilename(filename);
- data.setMimetype(MimeType.WEBDAV_FOLDER);
- data.setKey(EncryptionUtils.encodeBytesToBase64String(key));
-
- decryptedFile.setEncrypted(data);
- decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv));
-
- metadata.getFiles().put(encryptedFileName, decryptedFile);
+ metadata.getFiles().put(encryptedFileName, createDecryptedFile(filename));
EncryptedFolderMetadata encryptedFolderMetadata = EncryptionUtils.encryptFolderMetadata(metadata,
privateKey);
@@ -194,15 +172,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
.execute(client);
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
- OCFile newDir = new OCFile(createdRemoteFolder.getRemotePath());
- newDir.setMimeType(MimeType.DIRECTORY);
-
- newDir.setParentId(parent.getFileId());
- newDir.setRemoteId(createdRemoteFolder.getRemoteId());
- newDir.setModificationTimestamp(System.currentTimeMillis());
- newDir.setEncrypted(true);
- newDir.setPermissions(createdRemoteFolder.getPermissions());
- newDir.setDecryptedRemotePath(parent.getDecryptedRemotePath() + filename + "/");
+ OCFile newDir = createRemoteFolderOcFile(parent, filename, createdRemoteFolder);
getStorageManager().saveFile(newDir);
RemoteOperationResult encryptionOperationResult = new ToggleEncryptionRemoteOperation(
@@ -221,16 +191,6 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
return result;
} catch (Exception e) {
-// // revert to latest metadata
-// try {
-// Pair metadataPair = EncryptionUtils.retrieveMetadata(parent,
-// client,
-// privateKey,
-// publicKey);
-// } catch (Exception metadataException) {
-// throw new RuntimeException(metadataException);
-// }
-
if (!EncryptionUtils.unlockFolder(parent, client, token).isSuccess()) {
throw new RuntimeException("Could not clean up after failing folder creation!");
}
@@ -263,6 +223,62 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
}
}
+ private boolean isFileExisting(DecryptedFolderMetadata metadata, String filename) {
+ for (String key : metadata.getFiles().keySet()) {
+ DecryptedFolderMetadata.DecryptedFile file = metadata.getFiles().get(key);
+
+ if (file != null && filename.equalsIgnoreCase(file.getEncrypted().getFilename())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @NonNull
+ private OCFile createRemoteFolderOcFile(OCFile parent, String filename, RemoteFile remoteFolder) {
+ OCFile newDir = new OCFile(remoteFolder.getRemotePath());
+
+ newDir.setMimeType(MimeType.DIRECTORY);
+ newDir.setParentId(parent.getFileId());
+ newDir.setRemoteId(remoteFolder.getRemoteId());
+ newDir.setModificationTimestamp(System.currentTimeMillis());
+ newDir.setEncrypted(true);
+ newDir.setPermissions(remoteFolder.getPermissions());
+ newDir.setDecryptedRemotePath(parent.getDecryptedRemotePath() + filename + "/");
+
+ return newDir;
+ }
+
+ @NonNull
+ private DecryptedFolderMetadata.DecryptedFile createDecryptedFile(String filename) {
+ // Key, always generate new one
+ byte[] key = EncryptionUtils.generateKey();
+
+ // IV, always generate new one
+ byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength);
+
+ DecryptedFolderMetadata.DecryptedFile decryptedFile = new DecryptedFolderMetadata.DecryptedFile();
+ DecryptedFolderMetadata.Data data = new DecryptedFolderMetadata.Data();
+ data.setFilename(filename);
+ data.setMimetype(MimeType.WEBDAV_FOLDER);
+ data.setKey(EncryptionUtils.encodeBytesToBase64String(key));
+
+ decryptedFile.setEncrypted(data);
+ decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv));
+
+ return decryptedFile;
+ }
+
+ @NonNull
+ private String createRandomFileName(DecryptedFolderMetadata metadata) {
+ String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
+
+ while (metadata.getFiles().get(encryptedFileName) != null) {
+ encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
+ }
+ return encryptedFileName;
+ }
+
private RemoteOperationResult normalCreate(OwnCloudClient client) {
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
diff --git a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
index e009581979..7f6913b18d 100644
--- a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
+++ b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
@@ -25,7 +25,6 @@ import android.accounts.Account;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.Uri;
-import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -87,7 +86,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import androidx.annotation.CheckResult;
-import androidx.annotation.RequiresApi;
/**
@@ -150,12 +148,6 @@ public class UploadFileOperation extends SyncOperation {
private boolean encryptedAncestor;
public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
-
- // MIME type
- if (TextUtils.isEmpty(mimeType)) {
- mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath);
- }
-
OCFile newFile = new OCFile(remotePath);
newFile.setStoragePath(localPath);
newFile.setLastSyncDateForProperties(0);
@@ -169,8 +161,12 @@ public class UploadFileOperation extends SyncOperation {
} // don't worry about not assigning size, the problems with localPath
// are checked when the UploadFileOperation instance is created
-
- newFile.setMimeType(mimeType);
+ // MIME type
+ if (TextUtils.isEmpty(mimeType)) {
+ newFile.setMimeType(MimeTypeUtil.getBestMimeTypeByFilename(localPath));
+ } else {
+ newFile.setMimeType(mimeType);
+ }
return newFile;
}
diff --git a/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java b/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java
index 44bfe9ae73..d8e6a5aa36 100644
--- a/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java
@@ -55,6 +55,8 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
public static final String PREFERENCE_CONTACTS_LAST_BACKUP = "PREFERENCE_CONTACTS_LAST_BACKUP";
public static final String BACKUP_TO_LIST = "BACKUP_TO_LIST";
+ @Inject BackgroundJobManager backgroundJobManager;
+
public static void startActivity(Context context) {
Intent intent = new Intent(context, ContactsPreferenceActivity.class);
context.startActivity(intent);
@@ -73,8 +75,6 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
context.startActivity(intent);
}
- @Inject BackgroundJobManager backgroundJobManager;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java
index 5f9f47cccf..2cbd300e73 100644
--- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java
@@ -330,7 +330,7 @@ public abstract class DrawerActivity extends ToolbarActivity
switch (menuItem.getItemId()) {
case R.id.nav_all_files:
- if ((this instanceof FileDisplayActivity) &&
+ if (this instanceof FileDisplayActivity &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof PhotoFragment) &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
showFiles(false);
diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
index 05ec502ff7..b0937b68f0 100644
--- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
@@ -144,7 +144,6 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
/**
* Displays, what files the user has available in his ownCloud. This is the main view.
*/
-
public class FileDisplayActivity extends FileActivity
implements FileFragment.ContainerActivity,
OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener,
@@ -153,6 +152,7 @@ public class FileDisplayActivity extends FileActivity
public static final String RESTART = "RESTART";
public static final String ALL_FILES = "ALL_FILES";
public static final String PHOTO_SEARCH = "PHOTO_SEARCH";
+ public static final int SINGLE_USER_SIZE = 1;
private FilesBinding binding;
@@ -2466,7 +2466,7 @@ public class FileDisplayActivity extends FileActivity
} else if (match.getUsers().isEmpty()) {
dismissLoadingDialog();
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found));
- } else if (match.getUsers().size() == 1) {
+ } else if (match.getUsers().size() == SINGLE_USER_SIZE) {
openFile(match.getUsers().get(0), match.getFileId());
} else {
selectUserAndOpenFile(match.getUsers(), match.getFileId());
diff --git a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java
index aad2b87f00..c6c3713158 100644
--- a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java
@@ -475,7 +475,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
PopupMenu popup = new PopupMenu(this, view);
popup.getMenuInflater().inflate(R.menu.item_account, popup.getMenu());
- if((accountManager.getUser()).equals(user)) {
+ if(accountManager.getUser().equals(user)) {
popup.getMenu().findItem(R.id.action_open_account).setVisible(false);
}
popup.setOnMenuItemClickListener(item -> {
diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java
index d4ef575522..7312913d69 100644
--- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java
@@ -230,6 +230,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
@Override
public void onNothingSelected(AdapterView> parent) {
+ // no action
}
});
diff --git a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java
index 2a7e4867cc..283bea03a4 100644
--- a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java
@@ -154,7 +154,7 @@ public class UserInfoActivity extends DrawerActivity implements Injectable {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- if ((accountManager.getUser()).equals(user)) {
+ if (accountManager.getUser().equals(user)) {
menu.findItem(R.id.action_open_account).setVisible(false);
}
return super.onPrepareOptionsMenu(menu);
diff --git a/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
index bc32062802..183e161e80 100644
--- a/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
+++ b/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
@@ -365,9 +365,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter result = new ArrayList<>();
- text = text.toLowerCase(Locale.getDefault());
+ String filterText = text.toLowerCase(Locale.getDefault());
for (File file : mFilesAll) {
- if (file.getName().toLowerCase(Locale.getDefault()).contains(text)) {
+ if (file.getName().toLowerCase(Locale.getDefault()).contains(filterText)) {
result.add(file);
}
}
diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java
index e0cb814e23..17f93fef0b 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java
@@ -144,7 +144,6 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
int accentColor = ThemeUtils.primaryAccentColor(getContext());
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
- Type type = Type.valueOf(arguments.getString(ARG_TYPE));
// Inflate the layout for the dialog
LayoutInflater inflater = activity.getLayoutInflater();
@@ -160,6 +159,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
throw new RuntimeException(e); // we'll NPE without the client
}
+ Type type = Type.valueOf(arguments.getString(ARG_TYPE));
new FetchTemplateTask(this, client).execute(type);
listView.setHasFixedSize(true);
diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
index 854123e4b0..802804126e 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
@@ -252,8 +252,6 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
return "";
}
- OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
-
final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get();
if (fragment == null) {
return "";
@@ -267,6 +265,8 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
context.getContentResolver());
+
+ OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
storageManager.saveFile(temp);
file = storageManager.getFileByPath(path);
diff --git a/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java
index 3b98008d61..2ebef76ba8 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java
@@ -144,11 +144,11 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
DrawableCompat.setTint(wrappedDrawable, primaryColor);
passwordField.setBackgroundDrawable(wrappedDrawable);
- return createDialog(primaryColor, v);
+ return createDialog(v);
}
@NonNull
- private Dialog createDialog(int accentColor, View v) {
+ private Dialog createDialog(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(v).setPositiveButton(R.string.common_ok, null)
.setNegativeButton(R.string.common_cancel, null)
diff --git a/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java b/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java
index 3428e952b6..39cec87231 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java
@@ -85,6 +85,7 @@ public class SyncedFolderParcelable implements Parcelable {
}
public SyncedFolderParcelable() {
+ // empty constructor
}
@Override
diff --git a/src/main/java/com/owncloud/android/ui/events/SearchEvent.java b/src/main/java/com/owncloud/android/ui/events/SearchEvent.java
index e555e379e3..afe654239a 100644
--- a/src/main/java/com/owncloud/android/ui/events/SearchEvent.java
+++ b/src/main/java/com/owncloud/android/ui/events/SearchEvent.java
@@ -37,6 +37,7 @@ public class SearchEvent {
}
public SearchEvent() {
+ // empty constructor to create empty object
}
public String getSearchQuery() {
diff --git a/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java b/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java
index ee786f9dbb..268dcf61a1 100644
--- a/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java
+++ b/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java
@@ -32,6 +32,7 @@ public class SyncEventFinished {
}
public SyncEventFinished() {
+ // empty constructor
}
public Intent getIntent() {
diff --git a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java
index e27477798e..1768bb9daf 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java
@@ -145,7 +145,6 @@ public class ContactListFragment extends FileFragment implements Injectable {
private ContactListAdapter contactListAdapter;
- private User user;
private List vCards = new ArrayList<>();
private OCFile ocFile;
@Inject UserAccountManager accountManager;
@@ -212,7 +211,7 @@ public class ContactListFragment extends FileFragment implements Injectable {
ocFile = getArguments().getParcelable(FILE_NAME);
setFile(ocFile);
- user = getArguments().getParcelable(USER);
+ User user = getArguments().getParcelable(USER);
fileDownloader = new TransferManagerConnection(getActivity(), user);
fileDownloader.registerTransferListener(this::onDownloadUpdate);
fileDownloader.bind();
diff --git a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java
index b4e0ae8a4a..3697bb925c 100644
--- a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java
+++ b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java
@@ -21,7 +21,6 @@ package com.owncloud.android.utils;
import android.Manifest;
import android.accounts.Account;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -64,7 +63,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import static android.os.Build.VERSION.SDK_INT;
-
/**
* Static methods to help in access to local file system.
*/
diff --git a/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java b/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java
index 469dfaa353..788d314565 100644
--- a/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java
+++ b/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java
@@ -34,6 +34,7 @@ public class SvgDecoder implements ResourceDecoder {
}
public SvgDecoder() {
+ // empty constructor
}
public Resource