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());
}
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());
}
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;
}
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);
}
}
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();
}
Aggregations