Merge pull request #7127 from nextcloud/codacy

Codacy: Code Style Improvements
This commit is contained in:
Andy Scherzinger 2020-10-28 18:30:23 +01:00 committed by GitHub
commit af09ee9191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 170 additions and 139 deletions

View file

@ -127,7 +127,12 @@ else
gplayLimitation="<h1>Following files are beyond 500 char limit:</h1><br><br>"$gplayLimitation gplayLimitation="<h1>Following files are beyond 500 char limit:</h1><br><br>"$gplayLimitation
fi 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.<br><br>"
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 if [ ! -z "$gplayLimitation" ]; then
exit 1 exit 1
@ -141,6 +146,10 @@ else
exit $lintValue exit $lintValue
fi fi
if [ $notNull -gt 0 ]; then
exit 1
fi
if [ $findbugsValue -eq 2 ]; then if [ $findbugsValue -eq 2 ]; then
exit 0 exit 0
else else

View file

@ -1 +1 @@
319 316

View file

@ -24,10 +24,10 @@ import com.google.gson.annotations.SerializedName;
import org.parceler.Parcel; import org.parceler.Parcel;
@Parcel
/* /*
* Push data from server, https://github.com/nextcloud/notifications/blob/master/docs/push-v2.md#encrypted-subject-data * Push data from server, https://github.com/nextcloud/notifications/blob/master/docs/push-v2.md#encrypted-subject-data
*/ */
@Parcel
public class DecryptedPushMessage { public class DecryptedPushMessage {
public String app; public String app;
public String type; public String type;
@ -49,6 +49,7 @@ public class DecryptedPushMessage {
} }
public DecryptedPushMessage() { public DecryptedPushMessage() {
// empty constructor
} }
public String getApp() { public String getApp() {

View file

@ -1178,13 +1178,11 @@ public class FileDataStorageManager {
*/ */
public List<OCShare> getSharesByPathAndType(String path, ShareType type, String shareWith) { public List<OCShare> getSharesByPathAndType(String path, ShareType type, String shareWith) {
Cursor cursor; Cursor cursor;
if (shareWith == null) {
shareWith = "";
}
String selection = ProviderTableMeta.OCSHARES_PATH + AND String selection = ProviderTableMeta.OCSHARES_PATH + AND
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND + ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?"; + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
if (!ShareType.PUBLIC_LINK.equals(type)) { if (!ShareType.PUBLIC_LINK.equals(type)) {
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?"; selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
} }
@ -1196,6 +1194,14 @@ public class FileDataStorageManager {
Integer.toString(type.getValue()), Integer.toString(type.getValue()),
account.name account.name
}; };
} else {
if (shareWith == null) {
selectionArgs = new String[]{
path,
Integer.toString(type.getValue()),
account.name,
""
};
} else { } else {
selectionArgs = new String[]{ selectionArgs = new String[]{
path, path,
@ -1204,6 +1210,7 @@ public class FileDataStorageManager {
shareWith shareWith
}; };
} }
}
if (getContentResolver() != null) { if (getContentResolver() != null) {
cursor = getContentResolver().query( cursor = getContentResolver().query(
@ -1775,11 +1782,13 @@ public class FileDataStorageManager {
} }
public void saveConflict(OCFile ocFile, String etagInConflict) { public void saveConflict(OCFile ocFile, String etagInConflict) {
if (!ocFile.isDown()) {
etagInConflict = null;
}
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
if (!ocFile.isDown()) {
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, (String) null);
} else {
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict); cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
}
int updated = 0; int updated = 0;
if (getContentResolver() != null) { if (getContentResolver() != null) {
updated = getContentResolver().update( updated = getContentResolver().update(
@ -1804,7 +1813,7 @@ public class FileDataStorageManager {
Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated); Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated);
if (updated > 0) { if (updated > 0) {
if (etagInConflict != null) { if (etagInConflict != null && ocFile.isDown()) {
/// set conflict in all ancestor folders /// set conflict in all ancestor folders
long parentId = ocFile.getParentId(); long parentId = ocFile.getParentId();
@ -1922,7 +1931,6 @@ public class FileDataStorageManager {
} }
} }
} }
} }
public void saveCapabilities(OCCapability capability) { public void saveCapabilities(OCCapability capability) {

View file

@ -49,6 +49,7 @@ public class FileSystemDataSet {
} }
public FileSystemDataSet() { public FileSystemDataSet() {
// empty constructor
} }
public int getId() { public int getId() {

View file

@ -33,9 +33,6 @@ public class MediaFoldersModel {
this.videoMediaFolders = videoMediaFolders; this.videoMediaFolders = videoMediaFolders;
} }
public MediaFoldersModel() {
}
public List<String> getImageMediaFolders() { public List<String> getImageMediaFolders() {
return this.imageMediaFolders; return this.imageMediaFolders;
} }

View file

@ -38,6 +38,7 @@ public class PushConfigurationState {
} }
public PushConfigurationState() { public PushConfigurationState() {
// empty constructor for JSON parser
} }
public String getPushToken() { public String getPushToken() {

View file

@ -34,6 +34,7 @@ public class SignatureVerification {
} }
public SignatureVerification() { public SignatureVerification() {
// empty constructor
} }
public boolean isSignatureValid() { public boolean isSignatureValid() {

View file

@ -27,9 +27,18 @@ import java.util.Locale;
/** /**
* Template for creating a file from it via RichDocuments app * Template for creating a file from it via RichDocuments app
*/ */
@Parcel @Parcel
public class Template { 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) { public Template(int id, String name, String thumbnailLink, Type type, String extension) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -38,7 +47,21 @@ public class Template {
this.extension = extension; 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() { public int getId() {
@ -80,27 +103,4 @@ public class Template {
public void setExtension(String extension) { public void setExtension(String extension) {
this.extension = 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;
} }

View file

@ -933,7 +933,7 @@ public final class ThumbnailsCacheManager {
avatar = getBitmapFromDiskCache(avatarKey); avatar = getBitmapFromDiskCache(avatarKey);
// Download avatar from server, only if older than 60 min or avatar does not exist // 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; GetMethod get = null;
try { try {
if (mAccount != null) { if (mAccount != null) {

View file

@ -25,6 +25,11 @@ package com.owncloud.android.datastorage;
* @author Bartosz Przybylski * @author Bartosz Przybylski
*/ */
public class StoragePoint implements Comparable<StoragePoint> { public class StoragePoint implements Comparable<StoragePoint> {
private String description;
private String path;
private StorageType storageType;
private PrivacyType privacyType;
public StoragePoint(String description, String path, StorageType storageType, PrivacyType privacyType) { public StoragePoint(String description, String path, StorageType storageType, PrivacyType privacyType) {
this.description = description; this.description = description;
this.path = path; this.path = path;
@ -33,6 +38,7 @@ public class StoragePoint implements Comparable<StoragePoint> {
} }
public StoragePoint() { public StoragePoint() {
// empty constructor
} }
public String getDescription() { public String getDescription() {
@ -75,11 +81,6 @@ public class StoragePoint implements Comparable<StoragePoint> {
PRIVATE, PUBLIC PRIVATE, PUBLIC
} }
private String description;
private String path;
private StorageType storageType;
private PrivacyType privacyType;
@Override @Override
public int compareTo(StoragePoint another) { public int compareTo(StoragePoint another) {
return path.compareTo(another.getPath()); return path.compareTo(another.getPath());

View file

@ -165,13 +165,11 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
private Handler handler = new Handler() { private Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
int pos;
if (msg.what == SHOW_PROGRESS) { if (msg.what == SHOW_PROGRESS) {
updatePausePlay(); updatePausePlay();
pos = setProgress(); int pos = setProgress();
if (!isDragging) { if (!isDragging) {
msg = obtainMessage(SHOW_PROGRESS); sendMessageDelayed(obtainMessage(SHOW_PROGRESS), 1000 - (pos % 1000));
sendMessageDelayed(msg, 1000 - (pos % 1000));
} }
} }
} }

View file

@ -46,13 +46,14 @@ import com.owncloud.android.utils.MimeType;
import java.io.File; import java.io.File;
import java.util.UUID; import java.util.UUID;
import androidx.annotation.NonNull;
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH; 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 * Access to remote operation performing the creation of a new folder in the ownCloud server.
* Database * Save the new folder in Database.
*/ */
public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener { public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener {
@ -75,8 +76,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
@Override @Override
protected RemoteOperationResult run(OwnCloudClient client) { protected RemoteOperationResult run(OwnCloudClient client) {
String remoteParentPath = new File(getRemotePath()).getParent(); String remoteParentPath = new File(getRemotePath()).getParent();
remoteParentPath = remoteParentPath.endsWith(OCFile.PATH_SEPARATOR) ? remoteParentPath = remoteParentPath.endsWith(PATH_SEPARATOR) ?
remoteParentPath : remoteParentPath + OCFile.PATH_SEPARATOR; remoteParentPath : remoteParentPath + PATH_SEPARATOR;
OCFile parent = getStorageManager().getFileByDecryptedRemotePath(remoteParentPath); OCFile parent = getStorageManager().getFileByDecryptedRemotePath(remoteParentPath);
@ -84,8 +85,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
while (parent == null) { while (parent == null) {
tempRemoteParentPath = new File(tempRemoteParentPath).getParent(); tempRemoteParentPath = new File(tempRemoteParentPath).getParent();
if (!tempRemoteParentPath.endsWith(OCFile.PATH_SEPARATOR)) { if (!tempRemoteParentPath.endsWith(PATH_SEPARATOR)) {
tempRemoteParentPath = tempRemoteParentPath + OCFile.PATH_SEPARATOR; tempRemoteParentPath = tempRemoteParentPath + PATH_SEPARATOR;
} }
parent = getStorageManager().getFileByDecryptedRemotePath(tempRemoteParentPath); parent = getStorageManager().getFileByDecryptedRemotePath(tempRemoteParentPath);
@ -95,13 +96,13 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager()); boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager());
if (encryptedAncestor) { if (encryptedAncestor) {
return encryptedCreate(parent, remoteParentPath, client); return encryptedCreate(parent, client);
} else { } else {
return normalCreate(client); 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()); ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY); String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
String publicKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PUBLIC_KEY); String publicKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PUBLIC_KEY);
@ -127,20 +128,12 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
metadata = metadataPair.second; metadata = metadataPair.second;
// check if filename already exists // check if filename already exists
for (String key : metadata.getFiles().keySet()) { if (isFileExisting(metadata, filename)) {
DecryptedFolderMetadata.DecryptedFile file = metadata.getFiles().get(key);
if (file != null && filename.equalsIgnoreCase(file.getEncrypted().getFilename())) {
return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS); return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS);
} }
}
// generate new random file name, check if it exists in metadata // generate new random file name, check if it exists in metadata
String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); String encryptedFileName = createRandomFileName(metadata);
while (metadata.getFiles().get(encryptedFileName) != null) {
encryptedFileName = UUID.randomUUID().toString().replaceAll("-", "");
}
encryptedRemotePath = parent.getRemotePath() + encryptedFileName; encryptedRemotePath = parent.getRemotePath() + encryptedFileName;
RemoteOperationResult result = new CreateFolderRemoteOperation(encryptedRemotePath, RemoteOperationResult result = new CreateFolderRemoteOperation(encryptedRemotePath,
@ -149,23 +142,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
.execute(client); .execute(client);
if (result.isSuccess()) { 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 // update metadata
DecryptedFolderMetadata.DecryptedFile decryptedFile = new DecryptedFolderMetadata.DecryptedFile(); metadata.getFiles().put(encryptedFileName, createDecryptedFile(filename));
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);
EncryptedFolderMetadata encryptedFolderMetadata = EncryptionUtils.encryptFolderMetadata(metadata, EncryptedFolderMetadata encryptedFolderMetadata = EncryptionUtils.encryptFolderMetadata(metadata,
privateKey); privateKey);
@ -194,15 +172,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
.execute(client); .execute(client);
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0); createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
OCFile newDir = new OCFile(createdRemoteFolder.getRemotePath()); OCFile newDir = createRemoteFolderOcFile(parent, filename, createdRemoteFolder);
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 + "/");
getStorageManager().saveFile(newDir); getStorageManager().saveFile(newDir);
RemoteOperationResult encryptionOperationResult = new ToggleEncryptionRemoteOperation( RemoteOperationResult encryptionOperationResult = new ToggleEncryptionRemoteOperation(
@ -221,16 +191,6 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
return result; return result;
} catch (Exception e) { } catch (Exception e) {
// // revert to latest metadata
// try {
// Pair<Boolean, DecryptedFolderMetadata> metadataPair = EncryptionUtils.retrieveMetadata(parent,
// client,
// privateKey,
// publicKey);
// } catch (Exception metadataException) {
// throw new RuntimeException(metadataException);
// }
if (!EncryptionUtils.unlockFolder(parent, client, token).isSuccess()) { if (!EncryptionUtils.unlockFolder(parent, client, token).isSuccess()) {
throw new RuntimeException("Could not clean up after failing folder creation!"); 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) { private RemoteOperationResult normalCreate(OwnCloudClient client) {
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client); RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client);

View file

@ -25,7 +25,6 @@ import android.accounts.Account;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
@ -87,7 +86,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import androidx.annotation.RequiresApi;
/** /**
@ -150,12 +148,6 @@ public class UploadFileOperation extends SyncOperation {
private boolean encryptedAncestor; private boolean encryptedAncestor;
public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) { 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); OCFile newFile = new OCFile(remotePath);
newFile.setStoragePath(localPath); newFile.setStoragePath(localPath);
newFile.setLastSyncDateForProperties(0); newFile.setLastSyncDateForProperties(0);
@ -169,8 +161,12 @@ public class UploadFileOperation extends SyncOperation {
} // don't worry about not assigning size, the problems with localPath } // don't worry about not assigning size, the problems with localPath
// are checked when the UploadFileOperation instance is created // are checked when the UploadFileOperation instance is created
// MIME type
if (TextUtils.isEmpty(mimeType)) {
newFile.setMimeType(MimeTypeUtil.getBestMimeTypeByFilename(localPath));
} else {
newFile.setMimeType(mimeType); newFile.setMimeType(mimeType);
}
return newFile; return newFile;
} }

View file

@ -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 PREFERENCE_CONTACTS_LAST_BACKUP = "PREFERENCE_CONTACTS_LAST_BACKUP";
public static final String BACKUP_TO_LIST = "BACKUP_TO_LIST"; public static final String BACKUP_TO_LIST = "BACKUP_TO_LIST";
@Inject BackgroundJobManager backgroundJobManager;
public static void startActivity(Context context) { public static void startActivity(Context context) {
Intent intent = new Intent(context, ContactsPreferenceActivity.class); Intent intent = new Intent(context, ContactsPreferenceActivity.class);
context.startActivity(intent); context.startActivity(intent);
@ -73,8 +75,6 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
context.startActivity(intent); context.startActivity(intent);
} }
@Inject BackgroundJobManager backgroundJobManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View file

@ -330,7 +330,7 @@ public abstract class DrawerActivity extends ToolbarActivity
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.nav_all_files: case R.id.nav_all_files:
if ((this instanceof FileDisplayActivity) && if (this instanceof FileDisplayActivity &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof PhotoFragment) && !(((FileDisplayActivity) this).getLeftFragment() instanceof PhotoFragment) &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) { !(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
showFiles(false); showFiles(false);

View file

@ -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. * Displays, what files the user has available in his ownCloud. This is the main view.
*/ */
public class FileDisplayActivity extends FileActivity public class FileDisplayActivity extends FileActivity
implements FileFragment.ContainerActivity, implements FileFragment.ContainerActivity,
OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener, OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener,
@ -153,6 +152,7 @@ public class FileDisplayActivity extends FileActivity
public static final String RESTART = "RESTART"; public static final String RESTART = "RESTART";
public static final String ALL_FILES = "ALL_FILES"; public static final String ALL_FILES = "ALL_FILES";
public static final String PHOTO_SEARCH = "PHOTO_SEARCH"; public static final String PHOTO_SEARCH = "PHOTO_SEARCH";
public static final int SINGLE_USER_SIZE = 1;
private FilesBinding binding; private FilesBinding binding;
@ -2466,7 +2466,7 @@ public class FileDisplayActivity extends FileActivity
} else if (match.getUsers().isEmpty()) { } else if (match.getUsers().isEmpty()) {
dismissLoadingDialog(); dismissLoadingDialog();
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found)); 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()); openFile(match.getUsers().get(0), match.getFileId());
} else { } else {
selectUserAndOpenFile(match.getUsers(), match.getFileId()); selectUserAndOpenFile(match.getUsers(), match.getFileId());

View file

@ -475,7 +475,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
PopupMenu popup = new PopupMenu(this, view); PopupMenu popup = new PopupMenu(this, view);
popup.getMenuInflater().inflate(R.menu.item_account, popup.getMenu()); 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.getMenu().findItem(R.id.action_open_account).setVisible(false);
} }
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {

View file

@ -230,6 +230,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
@Override @Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
// no action
} }
}); });

View file

@ -154,7 +154,7 @@ public class UserInfoActivity extends DrawerActivity implements Injectable {
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
if ((accountManager.getUser()).equals(user)) { if (accountManager.getUser().equals(user)) {
menu.findItem(R.id.action_open_account).setVisible(false); menu.findItem(R.id.action_open_account).setVisible(false);
} }
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);

View file

@ -365,9 +365,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
mFiles = mFilesAll; mFiles = mFilesAll;
} else { } else {
List<File> result = new ArrayList<>(); List<File> result = new ArrayList<>();
text = text.toLowerCase(Locale.getDefault()); String filterText = text.toLowerCase(Locale.getDefault());
for (File file : mFilesAll) { for (File file : mFilesAll) {
if (file.getName().toLowerCase(Locale.getDefault()).contains(text)) { if (file.getName().toLowerCase(Locale.getDefault()).contains(filterText)) {
result.add(file); result.add(file);
} }
} }

View file

@ -144,7 +144,6 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
int accentColor = ThemeUtils.primaryAccentColor(getContext()); int accentColor = ThemeUtils.primaryAccentColor(getContext());
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER); parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
Type type = Type.valueOf(arguments.getString(ARG_TYPE));
// Inflate the layout for the dialog // Inflate the layout for the dialog
LayoutInflater inflater = activity.getLayoutInflater(); LayoutInflater inflater = activity.getLayoutInflater();
@ -160,6 +159,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
throw new RuntimeException(e); // we'll NPE without the client throw new RuntimeException(e); // we'll NPE without the client
} }
Type type = Type.valueOf(arguments.getString(ARG_TYPE));
new FetchTemplateTask(this, client).execute(type); new FetchTemplateTask(this, client).execute(type);
listView.setHasFixedSize(true); listView.setHasFixedSize(true);

View file

@ -252,8 +252,6 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
return ""; return "";
} }
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get(); final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get();
if (fragment == null) { if (fragment == null) {
return ""; return "";
@ -267,6 +265,8 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
context.getContentResolver()); context.getContentResolver());
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
storageManager.saveFile(temp); storageManager.saveFile(temp);
file = storageManager.getFileByPath(path); file = storageManager.getFileByPath(path);

View file

@ -144,11 +144,11 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
DrawableCompat.setTint(wrappedDrawable, primaryColor); DrawableCompat.setTint(wrappedDrawable, primaryColor);
passwordField.setBackgroundDrawable(wrappedDrawable); passwordField.setBackgroundDrawable(wrappedDrawable);
return createDialog(primaryColor, v); return createDialog(v);
} }
@NonNull @NonNull
private Dialog createDialog(int accentColor, View v) { private Dialog createDialog(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(v).setPositiveButton(R.string.common_ok, null) builder.setView(v).setPositiveButton(R.string.common_ok, null)
.setNegativeButton(R.string.common_cancel, null) .setNegativeButton(R.string.common_cancel, null)

View file

@ -85,6 +85,7 @@ public class SyncedFolderParcelable implements Parcelable {
} }
public SyncedFolderParcelable() { public SyncedFolderParcelable() {
// empty constructor
} }
@Override @Override

View file

@ -37,6 +37,7 @@ public class SearchEvent {
} }
public SearchEvent() { public SearchEvent() {
// empty constructor to create empty object
} }
public String getSearchQuery() { public String getSearchQuery() {

View file

@ -32,6 +32,7 @@ public class SyncEventFinished {
} }
public SyncEventFinished() { public SyncEventFinished() {
// empty constructor
} }
public Intent getIntent() { public Intent getIntent() {

View file

@ -145,7 +145,6 @@ public class ContactListFragment extends FileFragment implements Injectable {
private ContactListAdapter contactListAdapter; private ContactListAdapter contactListAdapter;
private User user;
private List<VCard> vCards = new ArrayList<>(); private List<VCard> vCards = new ArrayList<>();
private OCFile ocFile; private OCFile ocFile;
@Inject UserAccountManager accountManager; @Inject UserAccountManager accountManager;
@ -212,7 +211,7 @@ public class ContactListFragment extends FileFragment implements Injectable {
ocFile = getArguments().getParcelable(FILE_NAME); ocFile = getArguments().getParcelable(FILE_NAME);
setFile(ocFile); setFile(ocFile);
user = getArguments().getParcelable(USER); User user = getArguments().getParcelable(USER);
fileDownloader = new TransferManagerConnection(getActivity(), user); fileDownloader = new TransferManagerConnection(getActivity(), user);
fileDownloader.registerTransferListener(this::onDownloadUpdate); fileDownloader.registerTransferListener(this::onDownloadUpdate);
fileDownloader.bind(); fileDownloader.bind();

View file

@ -21,7 +21,6 @@ package com.owncloud.android.utils;
import android.Manifest; import android.Manifest;
import android.accounts.Account; import android.accounts.Account;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
@ -64,7 +63,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION.SDK_INT;
/** /**
* Static methods to help in access to local file system. * Static methods to help in access to local file system.
*/ */

View file

@ -34,6 +34,7 @@ public class SvgDecoder implements ResourceDecoder<InputStream, SVG> {
} }
public SvgDecoder() { public SvgDecoder() {
// empty constructor
} }
public Resource<SVG> decode(InputStream source, int w, int h) throws IOException { public Resource<SVG> decode(InputStream source, int w, int h) throws IOException {