Search in sources :

Example 26 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by nextcloud.

the class ConflictsResolveActivityIT method screenshotTextFiles.

@Test
@ScreenshotTest
public void screenshotTextFiles() {
    OCFile newFile = new OCFile("/newFile.txt");
    newFile.setFileLength(56000);
    newFile.setModificationTimestamp(1522019340);
    newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
    OCFile existingFile = new OCFile("/newFile.txt");
    existingFile.setFileLength(1024000);
    existingFile.setModificationTimestamp(1582019340);
    FileDataStorageManager storageManager = new FileDataStorageManager(user, targetContext.getContentResolver());
    storageManager.saveNewFile(existingFile);
    Intent intent = new Intent(targetContext, ConflictsResolveActivity.class);
    intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, newFile);
    intent.putExtra(ConflictsResolveActivity.EXTRA_EXISTING_FILE, existingFile);
    ConflictsResolveActivity sut = activityRule.launchActivity(intent);
    ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(existingFile, newFile, UserAccountManagerImpl.fromContext(targetContext).getUser());
    dialog.showDialog(sut);
    getInstrumentation().waitForIdleSync();
    shortSleep();
    shortSleep();
    shortSleep();
    shortSleep();
    screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) Intent(android.content.Intent) ConflictsResolveDialog(com.owncloud.android.ui.dialog.ConflictsResolveDialog) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 27 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by nextcloud.

the class DiskLruImageCacheFileProvider method getFile.

private OCFile getFile(Uri uri) {
    User user = accountManager.getUser();
    FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(user, MainApp.getAppContext().getContentResolver());
    return fileDataStorageManager.getFileByPath(uri.getPath());
}
Also used : User(com.nextcloud.client.account.User) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 28 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by nextcloud.

the class DocumentsStorageProvider method querySearchDocuments.

@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) {
    Log.d(TAG, "querySearchDocuments(), rootId=" + rootId);
    FileCursor result = new FileCursor(projection);
    FileDataStorageManager storageManager = getStorageManager(rootId);
    if (storageManager == null) {
        return result;
    }
    for (Document d : findFiles(new Document(storageManager, ROOT_PATH), query)) {
        result.addFile(d);
    }
    return result;
}
Also used : FileCursor(org.nextcloud.providers.cursors.FileCursor) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 29 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by nextcloud.

the class DocumentsStorageProvider method initiateStorageMap.

private void initiateStorageMap() {
    rootIdToStorageManager.clear();
    ContentResolver contentResolver = getContext().getContentResolver();
    for (User user : accountManager.getAllUsers()) {
        final FileDataStorageManager storageManager = new FileDataStorageManager(user, contentResolver);
        rootIdToStorageManager.put(user.hashCode(), storageManager);
    }
}
Also used : User(com.nextcloud.client.account.User) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) ContentResolver(android.content.ContentResolver)

Example 30 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by nextcloud.

the class DocumentsStorageProvider method createFolder.

private String createFolder(Document targetFolder, String displayName) throws FileNotFoundException {
    Context context = getNonNullContext();
    String newDirPath = targetFolder.getRemotePath() + displayName + PATH_SEPARATOR;
    FileDataStorageManager storageManager = targetFolder.getStorageManager();
    RemoteOperationResult result = new CreateFolderOperation(newDirPath, accountManager.getUser(), context, storageManager).execute(targetFolder.getClient());
    if (!result.isSuccess()) {
        Log_OC.e(TAG, result.toString());
        throw new FileNotFoundException("Failed to create document with name " + displayName + " and documentId " + targetFolder.getDocumentId());
    }
    RemoteOperationResult updateParent = new RefreshFolderOperation(targetFolder.getFile(), System.currentTimeMillis(), false, false, true, storageManager, targetFolder.getUser(), context).execute(targetFolder.getClient());
    if (!updateParent.isSuccess()) {
        Log_OC.e(TAG, updateParent.toString());
        throw new FileNotFoundException("Failed to create document with documentId " + targetFolder.getDocumentId());
    }
    Document newFolder = new Document(storageManager, newDirPath);
    context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
    return newFolder.getDocumentId();
}
Also used : Context(android.content.Context) CreateFolderOperation(com.owncloud.android.operations.CreateFolderOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)91 OCFile (com.owncloud.android.datamodel.OCFile)42 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)22 Account (android.accounts.Account)19 User (com.nextcloud.client.account.User)17 Intent (android.content.Intent)12 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)12 ArrayList (java.util.ArrayList)10 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)9 File (java.io.File)9 Context (android.content.Context)8 Test (org.junit.Test)8 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)7 OCUpload (com.owncloud.android.db.OCUpload)6 AccountManager (android.accounts.AccountManager)5 OperationCancelledException (com.owncloud.android.lib.common.operations.OperationCancelledException)5 UploadFileOperation (com.owncloud.android.operations.UploadFileOperation)5 Handler (android.os.Handler)4 DialogFragment (androidx.fragment.app.DialogFragment)4 IOException (java.io.IOException)4