Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb969cc6a8 | ||
|
|
aaba0a8a53 | ||
|
|
688a44dd61 | ||
|
|
1e2cbff1c8 | ||
|
|
6da3a0766b | ||
|
|
ebf22f67d2 |
No files matched your search
Generated
+1
-1
@@ -193,4 +193,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
||||
@@ -12,6 +12,7 @@ import android.os.Bundle;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
@@ -88,7 +89,7 @@ public abstract class AbstractIT {
|
||||
}
|
||||
|
||||
FileDataStorageManager getStorageManager() {
|
||||
return new FileDataStorageManager(account, targetContext.getContentResolver());
|
||||
return new FileDataStorageManagerImpl(account, targetContext.getContentResolver());
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.PassCodeActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
@@ -585,7 +586,8 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(user.toPlatformAccount(),
|
||||
context);
|
||||
|
||||
String value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder));
|
||||
OCFile prefFolder = folder;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -433,7 +433,7 @@ public final class ThumbnailsCacheManager {
|
||||
return getMethod;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account){
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account) {
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -439,10 +440,7 @@ public class FileDownloader extends Service
|
||||
if (mCurrentAccount == null ||
|
||||
!mCurrentAccount.equals(mCurrentDownload.getAccount())) {
|
||||
mCurrentAccount = mCurrentDownload.getAccount();
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mCurrentAccount,
|
||||
getContentResolver()
|
||||
);
|
||||
mStorageManager = new FileDataStorageManagerImpl(mCurrentAccount, getBaseContext());
|
||||
} // else, reuse storage manager from previous operation
|
||||
|
||||
// always get client from client manager, to get fresh credentials in case
|
||||
@@ -506,7 +504,7 @@ public class FileDownloader extends Service
|
||||
file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
|
||||
mStorageManager.saveFile(file);
|
||||
if (MimeTypeUtil.isMedia(mCurrentDownload.getMimeType())) {
|
||||
FileDataStorageManager.triggerMediaScan(file.getStoragePath());
|
||||
mStorageManager.triggerMediaScan(file.getStoragePath());
|
||||
}
|
||||
mStorageManager.saveConflict(file, null);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
@@ -1082,10 +1083,7 @@ public class FileUploader extends Service
|
||||
/// prepare client object to send the request to the ownCloud server
|
||||
if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getAccount())) {
|
||||
mCurrentAccount = mCurrentUpload.getAccount();
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mCurrentAccount,
|
||||
getContentResolver()
|
||||
);
|
||||
mStorageManager = new FileDataStorageManagerImpl(mCurrentAccount, getBaseContext());
|
||||
} // else, reuse storage manager from previous operation
|
||||
|
||||
// always get client from client manager, to get fresh credentials in case of update
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.FilesystemDataProvider;
|
||||
import com.owncloud.android.datamodel.PushConfigurationState;
|
||||
import com.owncloud.android.datamodel.SyncedFolder;
|
||||
@@ -107,7 +108,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
|
||||
removeAccount(account, accountManager);
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, context);
|
||||
|
||||
// remove all files
|
||||
removeFiles(account, storageManager);
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -175,7 +176,7 @@ public class ContactsBackupJob extends Job {
|
||||
private void expireFiles(Integer daysToExpire, String backupFolderString, Account account) {
|
||||
// -1 disables expiration
|
||||
if (daysToExpire > -1) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, getContext().getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, getContext());
|
||||
OCFile backupFolder = storageManager.getFileByPath(backupFolderString);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DAY_OF_YEAR, -daysToExpire);
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -92,8 +93,7 @@ public class OfflineSyncJob extends Job {
|
||||
Account[] accounts = userAccountManager.getAccounts();
|
||||
|
||||
for (Account account : accounts) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account,
|
||||
getContext().getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, getContext());
|
||||
|
||||
OCFile ocRoot = storageManager.getFileByPath(ROOT_PATH);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||
@@ -34,6 +35,8 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
|
||||
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
|
||||
|
||||
@@ -49,6 +52,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
protected String mRemotePath;
|
||||
private boolean mCreateFullPath;
|
||||
private RemoteFile createdRemoteFolder;
|
||||
@Inject Logger logger;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -63,11 +67,11 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = new CreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
|
||||
public RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = createCreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
RemoteOperationResult remoteFolderOperationResult = new ReadFolderRemoteOperation(mRemotePath)
|
||||
RemoteOperationResult remoteFolderOperationResult = createReadFolderRemoteOperation(mRemotePath)
|
||||
.execute(client);
|
||||
|
||||
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
|
||||
@@ -79,6 +83,14 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
return result;
|
||||
}
|
||||
|
||||
CreateFolderRemoteOperation createCreateFolderRemoteOperation(String remotePath, boolean createFullPath) {
|
||||
return new CreateFolderRemoteOperation(remotePath, createFullPath);
|
||||
}
|
||||
|
||||
ReadFolderRemoteOperation createReadFolderRemoteOperation(String remotePath) {
|
||||
return new ReadFolderRemoteOperation(remotePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
||||
if (operation instanceof CreateFolderRemoteOperation) {
|
||||
@@ -124,7 +136,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
newDir.setPermissions(createdRemoteFolder.getPermissions());
|
||||
getStorageManager().saveFile(newDir);
|
||||
|
||||
Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database");
|
||||
logger.d(TAG, "Create directory " + mRemotePath + " in Database");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
||||
@@ -171,7 +172,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
|
||||
// decrypt file
|
||||
if (file.isEncrypted() && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManagerImpl(account, context);
|
||||
|
||||
OCFile parent = fileDataStorageManager.getFileByPath(file.getParentRemotePath());
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.owncloud.android.operations;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -133,7 +132,7 @@ public class RenameFileOperation extends SyncOperation {
|
||||
getStorageManager().deleteFileInMediaScan(oldPath);
|
||||
// notify to scan about new file, if it is a media file
|
||||
if (MimeTypeUtil.isMedia(file.getMimeType())) {
|
||||
FileDataStorageManager.triggerMediaScan(newPath);
|
||||
getStorageManager().triggerMediaScan(newPath);
|
||||
}
|
||||
}
|
||||
// else - NOTHING: the link to the local file is kept although the local name
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
|
||||
import com.owncloud.android.datamodel.EncryptedFolderMetadata;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
@@ -968,7 +967,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
mFile.setStoragePath(expectedFile.getAbsolutePath());
|
||||
saveUploadedFile(client);
|
||||
if (MimeTypeUtil.isMedia(mFile.getMimeType())) {
|
||||
FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath());
|
||||
getStorageManager().triggerMediaScan(expectedFile.getAbsolutePath());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -985,7 +984,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
mFile.setStoragePath(newFile.getAbsolutePath());
|
||||
saveUploadedFile(client);
|
||||
if (MimeTypeUtil.isMedia(mFile.getMimeType())) {
|
||||
FileDataStorageManager.triggerMediaScan(newFile.getAbsolutePath());
|
||||
getStorageManager().triggerMediaScan(newFile.getAbsolutePath());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1329,7 +1328,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
getStorageManager().saveConflict(file, null);
|
||||
|
||||
if (MimeTypeUtil.isMedia(file.getMimeType())) {
|
||||
FileDataStorageManager.triggerMediaScan(file.getStoragePath());
|
||||
getStorageManager().triggerMediaScan(file.getStoragePath());
|
||||
}
|
||||
|
||||
// generate new Thumbnail
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class SyncOperation extends RemoteOperation {
|
||||
* Do not call this method from the main thread.
|
||||
*
|
||||
* This method should be used whenever an ownCloud account is available, instead of
|
||||
* {@link #execute(OwnCloudClient, com.owncloud.android.datamodel.FileDataStorageManager)}.
|
||||
* {@link #execute(OwnCloudClient, FileDataStorageManager)}.
|
||||
*
|
||||
* @param storageManager
|
||||
* @param context Android context for the component calling the method.
|
||||
@@ -77,11 +77,9 @@ public abstract class SyncOperation extends RemoteOperation {
|
||||
* @param storageManager
|
||||
* @return Result of the operation.
|
||||
*/
|
||||
public RemoteOperationResult execute(OwnCloudClient client,
|
||||
FileDataStorageManager storageManager) {
|
||||
public RemoteOperationResult execute(OwnCloudClient client, FileDataStorageManager storageManager) {
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("Trying to execute a sync operation with a " +
|
||||
"NULL storage manager");
|
||||
throw new IllegalArgumentException("Trying to execute a sync operation with a NULL storage manager");
|
||||
}
|
||||
this.storageManager = storageManager;
|
||||
return super.execute(client);
|
||||
@@ -103,7 +101,7 @@ public abstract class SyncOperation extends RemoteOperation {
|
||||
* @return Thread were the remote operation is executed.
|
||||
*/
|
||||
/*
|
||||
public Thread execute(FileDataStorageManager storageManager,
|
||||
public Thread execute(FileDataStorageManagerImpl storageManager,
|
||||
Context context, OnRemoteOperationListener listener, Handler listenerHandler, Activity callerActivity) {
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("Trying to execute a sync operation
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.owncloud.android.providers;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
@@ -35,6 +34,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -63,8 +63,8 @@ public class DiskLruImageCacheFileProvider extends ContentProvider {
|
||||
|
||||
private OCFile getFile(Uri uri) {
|
||||
User user = accountManager.getUser();
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
MainApp.getAppContext().getContentResolver());
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManagerImpl(user.toPlatformAccount(),
|
||||
MainApp.getAppContext());
|
||||
|
||||
return fileDataStorageManager.getFileByPath(uri.getPath());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
@@ -55,6 +54,7 @@ import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
@@ -223,7 +223,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
OCFile finalFile = ocFile;
|
||||
Thread syncThread = new Thread(() -> {
|
||||
try {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, context);
|
||||
RemoteOperationResult result = new SynchronizeFileOperation(finalFile, null, account,
|
||||
true, context)
|
||||
.execute(storageManager, context);
|
||||
@@ -638,10 +638,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
|
||||
rootIdToStorageManager.clear();
|
||||
|
||||
ContentResolver contentResolver = getContext().getContentResolver();
|
||||
|
||||
for (Account account : accountManager.getAccounts()) {
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManager(account, contentResolver);
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, getContext());
|
||||
rootIdToStorageManager.put(account.hashCode(), storageManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public class FileContentProvider extends ContentProvider {
|
||||
String[] whereArgs = new String[]{remotePath, accountName};
|
||||
Cursor doubleCheck = query(db, uri, projection, where, whereArgs, null);
|
||||
// ugly patch; serious refactorization is needed to reduce work in
|
||||
// FileDataStorageManager and bring it to FileContentProvider
|
||||
// FileDataStorageManagerImpl and bring it to FileContentProvider
|
||||
if (doubleCheck == null || !doubleCheck.moveToFirst()) {
|
||||
if (doubleCheck != null) {
|
||||
doubleCheck.close();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
package com.owncloud.android.providers;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.SearchManager;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
@@ -38,6 +37,7 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation;
|
||||
@@ -214,8 +214,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
Uri remoteBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_REMOTE).build();
|
||||
Uri emailBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_EMAIL).build();
|
||||
|
||||
FileDataStorageManager manager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
getContext().getContentResolver());
|
||||
FileDataStorageManager manager = new FileDataStorageManagerImpl(user.toPlatformAccount(), getContext());
|
||||
boolean federatedShareAllowed = manager.getCapability(user.getAccountName())
|
||||
.getFilesSharingFederationOutgoing()
|
||||
.isTrue();
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.util.Pair;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -435,10 +436,8 @@ public class OperationsService extends Service {
|
||||
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, mService);
|
||||
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mLastTarget.mAccount,
|
||||
mService.getContentResolver()
|
||||
);
|
||||
mStorageManager = new FileDataStorageManagerImpl(mLastTarget.mAccount,
|
||||
mService.getBaseContext());
|
||||
} else {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(mLastTarget.mServerUrl, null);
|
||||
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.os.Message;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.files.services.IndexedForest;
|
||||
@@ -105,10 +106,7 @@ class SyncFolderHandler extends Handler {
|
||||
|
||||
if (mCurrentAccount == null || !mCurrentAccount.equals(account)) {
|
||||
mCurrentAccount = account;
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
account,
|
||||
mService.getContentResolver()
|
||||
);
|
||||
mStorageManager = new FileDataStorageManagerImpl(account, mService.getBaseContext());
|
||||
} // else, reuse storage manager from previous operation
|
||||
|
||||
// always get client from client manager, to get fresh credentials in case of update
|
||||
@@ -123,7 +121,7 @@ class SyncFolderHandler extends Handler {
|
||||
} catch (AccountsException | IOException e) {
|
||||
sendBroadcastFinishedSyncFolder(account, remotePath, false);
|
||||
mService.dispatchResultToOperationListeners(mCurrentSyncOperation, new RemoteOperationResult(e));
|
||||
|
||||
|
||||
Log_OC.e(TAG, "Error while trying to get authorization", e);
|
||||
} finally {
|
||||
mPendingOperations.removePayload(account.name, remotePath);
|
||||
|
||||
@@ -46,7 +46,7 @@ import lombok.Setter;
|
||||
/**
|
||||
* Base synchronization adapter for ownCloud designed to be subclassed for different
|
||||
* resource types, like FileSync, ConcatsSync, CalendarSync, etc..
|
||||
*
|
||||
*
|
||||
* Implements the standard {@link AbstractThreadedSyncAdapter}.
|
||||
*/
|
||||
abstract class AbstractOwnCloudSyncAdapter extends
|
||||
|
||||
@@ -36,7 +36,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
@@ -154,7 +154,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
|
||||
this.setAccount(account);
|
||||
this.setContentProviderClient(providerClient);
|
||||
this.setStorageManager(new FileDataStorageManager(account, providerClient));
|
||||
this.setStorageManager(new FileDataStorageManagerImpl(account, providerClient, getContext()));
|
||||
|
||||
try {
|
||||
this.initClientForCurrentAccount();
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.Toast;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichObject;
|
||||
@@ -168,7 +169,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
emptyContentProgressBar.getIndeterminateDrawable().setColorFilter(ThemeUtils.primaryAccentColor(this),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(getAccount(), this);
|
||||
adapter = new ActivityListAdapter(this, getUserAccountManager(), this, storageManager,
|
||||
getCapabilities(), false);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class FilesServiceApiImpl implements FilesServiceApi {
|
||||
|
||||
if (resultRemoteFileOp.isSuccess()) {
|
||||
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) resultRemoteFileOp.getData().get(0));
|
||||
remoteOcFile = baseActivity.getStorageManager().saveFileWithParent(temp, context);
|
||||
remoteOcFile = baseActivity.getStorageManager().saveFileWithParent(temp);
|
||||
|
||||
if (remoteOcFile.isFolder()) {
|
||||
// perform folder synchronization
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
@@ -160,7 +161,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
}
|
||||
|
||||
if(currentAccount != null) {
|
||||
storageManager = new FileDataStorageManager(currentAccount, getContentResolver());
|
||||
storageManager = new FileDataStorageManagerImpl(currentAccount, this);
|
||||
capabilities = storageManager.getCapability(currentAccount.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,23 +34,23 @@ public interface ComponentsGetter {
|
||||
*/
|
||||
public FileDownloaderBinder getFileDownloaderBinder();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To be invoked when the parent activity is fully created to get a reference
|
||||
* to the FileUploader service API.
|
||||
*/
|
||||
public FileUploaderBinder getFileUploaderBinder();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To be invoked when the parent activity is fully created to get a reference
|
||||
* to the OperationsSerivce service API.
|
||||
*/
|
||||
public OperationsServiceBinder getOperationsServiceBinder();
|
||||
|
||||
|
||||
|
||||
public FileDataStorageManager getStorageManager();
|
||||
|
||||
|
||||
public FileOperationsHelper getFileOperationsHelper();
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ExternalLinksProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
@@ -370,8 +371,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
|
||||
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(user.toPlatformAccount(), this);
|
||||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, user.toPlatformAccount(), getResources(), true);
|
||||
|
||||
+4
-3
@@ -38,6 +38,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
|
||||
@@ -94,7 +95,7 @@ public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity implem
|
||||
mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT);
|
||||
mRemotePaths = intent.getStringArrayListExtra(EXTRA_REMOTE_PATHS);
|
||||
mLocalPaths = intent.getStringArrayListExtra(EXTRA_LOCAL_PATHS);
|
||||
mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
|
||||
mStorageManager = new FileDataStorageManagerImpl(mAccount, this);
|
||||
mHandler = new Handler();
|
||||
if (mCurrentDialog != null) {
|
||||
mCurrentDialog.dismiss();
|
||||
@@ -150,8 +151,8 @@ public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity implem
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public View getView (int position, View convertView, @NonNull ViewGroup parent) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View view = convertView;
|
||||
if (view == null) {
|
||||
LayoutInflater vi = (LayoutInflater) getSystemService(
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.VirtualFolderType;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
@@ -2656,7 +2657,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
FileDataStorageManager storageManager = getStorageManager();
|
||||
|
||||
if (storageManager == null) {
|
||||
storageManager = new FileDataStorageManager(newAccount, getContentResolver());
|
||||
storageManager = new FileDataStorageManagerImpl(newAccount, this);
|
||||
}
|
||||
|
||||
FetchRemoteFileTask fetchRemoteFileTask = new FetchRemoteFileTask(newAccount,
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
@@ -238,7 +239,7 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the view, reading data from {@link com.owncloud.android.datamodel.FileDataStorageManager}.
|
||||
* Updates the view, reading data from {@link FileDataStorageManagerImpl}.
|
||||
*/
|
||||
private void refreshSharesFromStorageManager() {
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.view.View;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
@@ -433,7 +434,7 @@ public class StorageMigration {
|
||||
}
|
||||
|
||||
private void updateIndex(Context context) throws MigrationException {
|
||||
FileDataStorageManager manager = new FileDataStorageManager(null, context.getContentResolver());
|
||||
FileDataStorageManager manager = new FileDataStorageManagerImpl(null, context);
|
||||
|
||||
try {
|
||||
manager.migrateStoredFiles(mStorageSource, mStorageTarget);
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.datamodel.VirtualFolderType;
|
||||
@@ -797,7 +798,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
|
||||
if (mStorageManager == null) {
|
||||
mStorageManager = new FileDataStorageManager(user.toPlatformAccount(), activity.getContentResolver());
|
||||
mStorageManager = new FileDataStorageManagerImpl(user.toPlatformAccount(), activity);
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
@@ -863,7 +864,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
if (result.isSuccess()) {
|
||||
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.toPlatformAccount());
|
||||
file = mStorageManager.saveFileWithParent(file, activity);
|
||||
file = mStorageManager.saveFileWithParent(file);
|
||||
|
||||
ShareType newShareType = ocShare.getShareType();
|
||||
if (newShareType == ShareType.PUBLIC_LINK) {
|
||||
@@ -924,7 +925,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
mStorageManager.saveFile(ocFile);
|
||||
} else {
|
||||
|
||||
ocFile = mStorageManager.saveFileWithParent(ocFile, activity);
|
||||
ocFile = mStorageManager.saveFileWithParent(ocFile);
|
||||
|
||||
// also sync folder content
|
||||
if (ocFile.isFolder()) {
|
||||
|
||||
@@ -50,14 +50,16 @@ public class UploaderAdapter extends SimpleAdapter {
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public UploaderAdapter(Context context,
|
||||
List<? extends Map<String, ?>> data, int resource, String[] from,
|
||||
int[] to, FileDataStorageManager storageManager, Account account) {
|
||||
List<? extends Map<String, ?>> data,
|
||||
int resource, String[] from,
|
||||
int[] to,
|
||||
FileDataStorageManager storageManager,
|
||||
Account account) {
|
||||
super(context, data, resource, from, to);
|
||||
mAccount = account;
|
||||
mStorageManager = storageManager;
|
||||
mContext = context;
|
||||
inflater = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,15 +32,9 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
@@ -56,6 +50,14 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Adapter to show a user/group/email/remote in Sharing list in file details view.
|
||||
*/
|
||||
@@ -82,7 +84,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
this.userId = userId;
|
||||
|
||||
accentColor = ThemeUtils.primaryAccentColor(context);
|
||||
capabilities = new FileDataStorageManager(account, context.getContentResolver()).getCapability(account.name);
|
||||
capabilities = new FileDataStorageManagerImpl(account, context).getCapability(account.name);
|
||||
avatarRadiusDimension = context.getResources().getDimension(R.dimen.user_icon_radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
|
||||
|
||||
OCFile ocFile = FileStorageUtils.fillOCFile(remoteFile);
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, account);
|
||||
ocFile = storageManager.saveFileWithParent(ocFile, fileDisplayActivity);
|
||||
ocFile = storageManager.saveFileWithParent(ocFile);
|
||||
|
||||
// also sync folder content
|
||||
OCFile toSync;
|
||||
|
||||
+3
-2
@@ -44,6 +44,7 @@ import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.Template;
|
||||
import com.owncloud.android.files.CreateFileFromTemplateOperation;
|
||||
@@ -249,9 +250,9 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
|
||||
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
|
||||
|
||||
if (chooseTemplateDialogFragmentWeakReference.get() != null) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(
|
||||
user.toPlatformAccount(),
|
||||
chooseTemplateDialogFragmentWeakReference.get().requireContext().getContentResolver());
|
||||
chooseTemplateDialogFragmentWeakReference.get().requireContext());
|
||||
storageManager.saveFile(temp);
|
||||
file = storageManager.getFileByPath(path);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.Creator;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -253,9 +254,9 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
|
||||
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
|
||||
|
||||
if (chooseTemplateDialogFragmentWeakReference.get() != null) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(
|
||||
user.toPlatformAccount(),
|
||||
chooseTemplateDialogFragmentWeakReference.get().requireContext().getContentResolver());
|
||||
chooseTemplateDialogFragmentWeakReference.get().requireContext());
|
||||
storageManager.saveFile(temp);
|
||||
file = storageManager.getFileByPath(path);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -112,7 +113,7 @@ public class EditShareFragment extends Fragment {
|
||||
mAccount = getArguments().getParcelable(ARG_ACCOUNT);
|
||||
}
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(mAccount, getContext().getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(mAccount, getContext());
|
||||
mCapabilities = storageManager.getCapability(mAccount.name);
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ public class EditShareFragment extends Fragment {
|
||||
/**
|
||||
* Get known server capabilities from DB
|
||||
* <p/>
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshCapabilitiesFromDB() {
|
||||
@@ -418,7 +419,7 @@ public class EditShareFragment extends Fragment {
|
||||
/**
|
||||
* Get {@link OCShare} instance from DB and updates the UI.
|
||||
*
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshUiFromDB() {
|
||||
@@ -431,7 +432,7 @@ public class EditShareFragment extends Fragment {
|
||||
/**
|
||||
* Get {@link OCShare} instance from DB and updates the UI.
|
||||
*
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*
|
||||
* @param editShareView Root view in the fragment.
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -244,7 +245,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, requireActivity().getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, requireActivity());
|
||||
operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
|
||||
|
||||
OCCapability capability = storageManager.getCapability(account.name);
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -202,7 +203,7 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
if (fileDataStorageManager == null) {
|
||||
fileDataStorageManager = new FileDataStorageManager(account, fileDisplayActivity.getContentResolver());
|
||||
fileDataStorageManager = new FileDataStorageManagerImpl(account, fileDisplayActivity);
|
||||
}
|
||||
|
||||
setupView();
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
@@ -153,7 +154,7 @@ public class SearchShareesFragment extends Fragment implements ShareUserListAdap
|
||||
/**
|
||||
* Get users and groups from the DB to fill in the "share with" list
|
||||
*
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshUsersOrGroupsListFromDB (){
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.widget.TextView;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -587,7 +588,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
|
||||
/**
|
||||
* Get known server capabilities from DB
|
||||
* <p/>
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshCapabilitiesFromDB() {
|
||||
@@ -599,7 +600,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
|
||||
/**
|
||||
* Get users and groups from the DB to fill in the "share with" list.
|
||||
* <p/>
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshUsersOrGroupsListFromDB() {
|
||||
@@ -662,7 +663,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
|
||||
* <p/>
|
||||
* Takes into account server capabilities before reading database.
|
||||
* <p/>
|
||||
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
|
||||
* Depends on the parent Activity provides a {@link FileDataStorageManagerImpl}
|
||||
* instance ready to use. If not ready, does nothing.
|
||||
*/
|
||||
public void refreshPublicShareFromDB() {
|
||||
|
||||
+3
-2
@@ -63,6 +63,7 @@ import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.jobs.ContactsImportJob;
|
||||
@@ -515,8 +516,8 @@ public class ContactListFragment extends FileFragment implements Injectable {
|
||||
if (FileDownloader.getDownloadFinishMessage().equalsIgnoreCase(intent.getAction())) {
|
||||
String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account,
|
||||
context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account,
|
||||
context);
|
||||
ocFile = storageManager.getFileByPath(downloadedRemotePath);
|
||||
loadContactsTask.execute();
|
||||
}
|
||||
|
||||
+3
-2
@@ -43,6 +43,7 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.jobs.ContactsBackupJob;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -213,8 +214,8 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
|
||||
AsyncTask<String, Integer, Boolean> task = new AsyncTask<String, Integer, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(String... path) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account,
|
||||
contactsPreferenceActivity.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account,
|
||||
contactsPreferenceActivity);
|
||||
|
||||
OCFile folder = storageManager.getFileByPath(path[0]);
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.StreamMediaFileOperation;
|
||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
@@ -196,8 +197,8 @@ public class FileOperationsHelper {
|
||||
public void startSyncForFileAndIntent(OCFile file, Intent intent) {
|
||||
new Thread(() -> {
|
||||
Account account = fileActivity.getAccount();
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(fileActivity.getAccount(),
|
||||
fileActivity.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(fileActivity.getAccount(),
|
||||
fileActivity);
|
||||
|
||||
// check if file is in conflict (this is known due to latest folder refresh)
|
||||
if (file.isInConflict()) {
|
||||
@@ -296,7 +297,7 @@ public class FileOperationsHelper {
|
||||
public void run() {
|
||||
User user = currentAccount.getUser();
|
||||
FileDataStorageManager storageManager =
|
||||
new FileDataStorageManager(user.toPlatformAccount(), fileActivity.getContentResolver());
|
||||
new FileDataStorageManagerImpl(user.toPlatformAccount(), fileActivity);
|
||||
// a fresh object is needed; many things could have occurred to the file
|
||||
// since it was registered to observe again, assuming that local files
|
||||
// are linked to a remote file AT MOST, SOMETHING TO BE DONE;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
@@ -37,7 +36,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.MainApp;
|
||||
|
||||
@@ -64,9 +64,12 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
|
||||
* @param parentFolder Folder where images will be searched for.
|
||||
* @param storageManager Bridge to database.
|
||||
*/
|
||||
public PreviewImagePagerAdapter(FragmentManager fragmentManager, OCFile parentFolder,
|
||||
Account account, FileDataStorageManager storageManager,
|
||||
boolean onlyOnDevice, AppPreferences preferences) {
|
||||
public PreviewImagePagerAdapter(FragmentManager fragmentManager,
|
||||
OCFile parentFolder,
|
||||
Account account,
|
||||
FileDataStorageManager storageManager,
|
||||
boolean onlyOnDevice,
|
||||
AppPreferences preferences) {
|
||||
super(fragmentManager);
|
||||
|
||||
if (fragmentManager == null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.util.Pair;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -58,7 +59,7 @@ public class GetShareWithUsersAsyncTask extends AsyncTask<Object, Void, Pair<Rem
|
||||
if (params != null && params.length == 3) {
|
||||
OCFile file = (OCFile) params[0];
|
||||
Account account = (Account) params[1];
|
||||
FileDataStorageManager fileDataStorageManager = (FileDataStorageManager) params[2];
|
||||
FileDataStorageManager fileDataStorageManager = (FileDataStorageManagerImpl) params[2];
|
||||
|
||||
try {
|
||||
// Get shares request
|
||||
@@ -93,4 +94,4 @@ public class GetShareWithUsersAsyncTask extends AsyncTask<Object, Void, Pair<Rem
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.ui.activity.ToolbarActivity;
|
||||
@@ -631,7 +632,7 @@ public final class ThemeUtils {
|
||||
}
|
||||
|
||||
if (account != null) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, context);
|
||||
return storageManager.getCapability(account.name);
|
||||
} else {
|
||||
return new OCCapability();
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentValues;
|
||||
import android.content.OperationApplicationException;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.VirtualFolderType;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class FileDataStorageManagerLocal implements FileDataStorageManager {
|
||||
private Map<String, OCFile> pathToFile = new HashMap<>();
|
||||
private long currentMaxId = 0;
|
||||
|
||||
public FileDataStorageManagerLocal() {
|
||||
// always have root file
|
||||
pathToFile.put("/", createOCFile("/"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile getFileByPath(String path) {
|
||||
return pathToFile.get(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account getAccount() {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OCFile getFileById(long id) {
|
||||
for (Map.Entry<String, OCFile> entry : pathToFile.entrySet()) {
|
||||
if (entry.getValue().getFileId() == id) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConflict(OCFile file, String etagInConflict) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFileInMediaScan(String path) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveFile(OCFile file) {
|
||||
pathToFile.put(file.getRemotePath(), file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fileExists(long id) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fileExists(String path) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OCFile> getFolderContent(OCFile f, boolean onlyOnDevice) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFolder(OCFile folder, Collection<OCFile> updatedFiles, Collection<OCFile> filesToRemove) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFile(OCFile file, boolean removeDBData, boolean removeLocalCopy) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFolder(OCFile folder, boolean removeDBData, boolean removeLocalContent) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveLocalFile(OCFile file, String targetPath, String targetParentPath) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveShare(OCShare share) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OCShare> getSharesWithForAFile(String filePath, String accountName) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeShare(OCShare share) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyLocalFile(OCFile file, String targetPath) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCCapability saveCapabilities(OCCapability capability) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public OCCapability getCapability(String accountName) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSharesDB(List<OCShare> shares) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSharesForFile(String remotePath) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCShare getShareById(long id) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerMediaScan(String path) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile getFileByLocalPath(String path) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OCFile getFileByRemoteId(String remoteId) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile saveFileWithParent(OCFile file) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNewFile(OCFile newFile) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrateStoredFiles(String srcPath, String dstPath) throws RemoteException, OperationApplicationException {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShares(Collection<OCShare> shares) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSharedFiles(Collection<OCFile> sharedFiles) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSharesInFolder(List<OCShare> shares, OCFile folder) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVirtuals(VirtualFolderType type) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVirtuals(VirtualFolderType type, List<ContentValues> values) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVirtual(VirtualFolderType type, OCFile file) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OCFile> getVirtualFolderContent(VirtualFolderType type, boolean onlyImages) {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllFiles() {
|
||||
throw new UnsupportedOperationException("to implement");
|
||||
}
|
||||
|
||||
public OCFile createOCFile(String path) {
|
||||
OCFile file = new OCFile(path);
|
||||
|
||||
file.setFileId(currentMaxId);
|
||||
currentMaxId++;
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.owncloud.android.FileDataStorageManagerLocal;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class CreateFolderOperationTest {
|
||||
private FileDataStorageManager fileDataStorageManager = new FileDataStorageManagerLocal();
|
||||
|
||||
@Mock OwnCloudClient client;
|
||||
|
||||
@Mock CreateFolderRemoteOperation createFolderRemoteOperation;
|
||||
@Mock ReadFolderRemoteOperation readFolderRemoteOperation;
|
||||
|
||||
@Mock Logger logger;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFolder() {
|
||||
// setup
|
||||
String path = "/testFolder/";
|
||||
CreateFolderOperation sut = spy(new CreateFolderOperation(path, true));
|
||||
|
||||
sut.logger = logger;
|
||||
|
||||
when(createFolderRemoteOperation.execute(any(OwnCloudClient.class)))
|
||||
.thenReturn(new RemoteOperationResult(RemoteOperationResult.ResultCode.OK));
|
||||
|
||||
RemoteOperationResult result = new RemoteOperationResult(RemoteOperationResult.ResultCode.OK);
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
list.add(new RemoteFile("/testFolder"));
|
||||
|
||||
result.setData(list);
|
||||
|
||||
when(readFolderRemoteOperation.execute(any(OwnCloudClient.class))).thenReturn(result);
|
||||
doReturn(createFolderRemoteOperation).
|
||||
when(sut).createCreateFolderRemoteOperation(any(String.class), any(Boolean.class));
|
||||
doReturn(readFolderRemoteOperation)
|
||||
.when(sut).createReadFolderRemoteOperation(any(String.class));
|
||||
|
||||
// tests
|
||||
// folder does not exist yet
|
||||
assertNull(fileDataStorageManager.getFileByPath(path));
|
||||
|
||||
// run
|
||||
RemoteOperationResult syncResult = sut.execute(client, fileDataStorageManager);
|
||||
|
||||
// verify
|
||||
assertTrue(syncResult.isSuccess());
|
||||
|
||||
// folder exists
|
||||
assertTrue(fileDataStorageManager.getFileByPath(path).isFolder());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user