use of dev.dworks.apps.anexplorer.root.RootFile in project AnExplorer by 1hakr.
the class RootedStorageProvider method updateRoots.
@Override
public void updateRoots() {
mRoots.clear();
try {
final String rootId = ROOT_ID_ROOT;
final RootFile path = new RootFile("/");
final RootInfo root = new RootInfo();
mRoots.put(rootId, root);
root.rootId = rootId;
root.flags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_EDIT | Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED;
root.title = getContext().getString(R.string.root_root_storage);
root.path = path;
root.docId = getDocIdForRootFile(path);
} catch (FileNotFoundException e) {
CrashReportingManager.logException(e);
}
notifyRootsChanged(getContext());
}
use of dev.dworks.apps.anexplorer.root.RootFile in project AnExplorer by 1hakr.
the class RootedStorageProvider method openOrCreateDocumentThumbnail.
public AssetFileDescriptor openOrCreateDocumentThumbnail(String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
// final ContentResolver resolver = getContext().getContentResolver();
final RootFile file = getRootFileForDocId(docId);
final String mimeType = getTypeForFile(file);
final String typeOnly = mimeType.split("/")[0];
final long token = Binder.clearCallingIdentity();
try {
if ("audio".equals(typeOnly)) {
final long id = getAlbumForPathCleared(file.getPath());
return openOrCreateAudioThumbnailCleared(id, signal);
} else if ("image".equals(typeOnly)) {
final long id = getImageForPathCleared(file.getPath());
return openOrCreateImageThumbnailCleared(id, signal);
} else if ("video".equals(typeOnly)) {
final long id = getVideoForPathCleared(file.getPath());
return openOrCreateVideoThumbnailCleared(id, signal);
} else {
// DocumentsContract.openImageThumbnail(file);
return null;
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
use of dev.dworks.apps.anexplorer.root.RootFile in project AnExplorer by 1hakr.
the class RootedStorageProvider method renameDocument.
@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
// Since this provider treats renames as generating a completely new
// docId, we're okay with letting the MIME type change.
displayName = FileUtils.buildValidFatFilename(displayName);
final RootFile before = getRootFileForDocId(documentId);
final RootFile after = new RootFile(before.getParent(), displayName);
if (!RootCommands.renameRootTarget(before, after)) {
throw new IllegalStateException("Failed to rename " + before);
}
final String afterDocId = getDocIdForRootFile(new RootFile(after.getParent(), displayName));
if (!TextUtils.equals(documentId, afterDocId)) {
notifyDocumentsChanged(documentId);
return afterDocId;
} else {
return null;
}
}
use of dev.dworks.apps.anexplorer.root.RootFile in project AnExplorer by 1hakr.
the class RootedStorageProvider method deleteDocument.
@Override
public void deleteDocument(String docId) throws FileNotFoundException {
final RootFile file = getRootFileForDocId(docId);
if (!RootCommands.deleteFileRoot(file.getPath())) {
throw new IllegalStateException("Failed to delete " + file);
}
notifyDocumentsChanged(docId);
}
use of dev.dworks.apps.anexplorer.root.RootFile in project AnExplorer by 1hakr.
the class RootedStorageProvider method querySearchDocuments.
@SuppressWarnings("unused")
@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final RootFile parent;
synchronized (mRootsLock) {
parent = mRoots.get(rootId).path;
}
try {
BufferedReader br = RootCommands.findFiles(parent.getPath(), query);
if (null != br) {
Scanner scanner = new Scanner(br);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
try {
includeRootFile(result, null, new RootFile(parent, line));
} catch (Exception e) {
CrashReportingManager.logException(e);
}
}
scanner.close();
}
} catch (Exception e) {
CrashReportingManager.logException(e);
}
return result;
}
Aggregations