use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onSaveDocuments.
public boolean onSaveDocuments(ArrayList<DocumentInfo> docs) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
boolean hadTrouble = false;
for (DocumentInfo doc : docs) {
if (!doc.isCopySupported()) {
Log.w(TAG, "Skipping " + doc);
hadTrouble = true;
continue;
}
try {
Uri appBackupUri = DocumentsContract.buildDocumentUri(ExternalStorageProvider.AUTHORITY, DIRECTORY_APPBACKUP);
hadTrouble = DocumentsContract.copyDocument(resolver, doc.derivedUri, appBackupUri) == null;
} catch (Exception e) {
Log.w(TAG, "Failed to save " + doc);
CrashReportingManager.logException(e);
hadTrouble = true;
}
}
return hadTrouble;
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onCompressDocuments.
public boolean onCompressDocuments(DocumentInfo parent, ArrayList<DocumentInfo> docs) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
boolean hadTrouble = false;
if (!parent.isArchiveSupported()) {
Log.w(TAG, "Skipping " + doc);
hadTrouble = true;
}
try {
ArrayList<String> documentIds = new ArrayList<>();
for (DocumentInfo doc : docs) {
documentIds.add(DocumentsContract.getDocumentId(doc.derivedUri));
}
hadTrouble = !DocumentsContract.compressDocument(resolver, doc.derivedUri, documentIds);
} catch (Exception e) {
Log.w(TAG, "Failed to Compress " + doc);
CrashReportingManager.logException(e);
hadTrouble = true;
}
return hadTrouble;
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onDeleteDocuments.
private boolean onDeleteDocuments(ArrayList<DocumentInfo> docs) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
boolean hadTrouble = false;
for (DocumentInfo doc : docs) {
if (!doc.isDeleteSupported()) {
Log.w(TAG, "Skipping " + doc);
hadTrouble = true;
continue;
}
try {
hadTrouble = !DocumentsContract.deleteDocument(resolver, doc.derivedUri);
} catch (Exception e) {
Log.w(TAG, "Failed to delete " + doc);
CrashReportingManager.logException(e);
hadTrouble = true;
}
}
return hadTrouble;
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method showPopupMenu.
private void showPopupMenu(View view, final int position) {
PopupMenu popup = new PopupMenu(getActivity(), view);
int menuId = R.menu.popup_simple_directory;
if (isApp) {
menuId = R.menu.popup_apps;
} else {
menuId = R.menu.popup_directory;
}
popup.getMenuInflater().inflate(menuId, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onPopupMenuItemClick(menuItem, position);
}
});
if (isApp) {
final MenuItem open = popup.getMenu().findItem(R.id.menu_open);
final MenuItem delete = popup.getMenu().findItem(R.id.menu_delete);
final MenuItem save = popup.getMenu().findItem(R.id.menu_save);
open.setVisible(root.isAppPackage());
save.setVisible(root.isAppPackage());
delete.setVisible(root.isUserApp());
} else {
final State state = getDisplayState(DirectoryFragment.this);
final MenuItem share = popup.getMenu().findItem(R.id.menu_share);
final MenuItem delete = popup.getMenu().findItem(R.id.menu_delete);
final MenuItem rename = popup.getMenu().findItem(R.id.menu_rename);
final MenuItem copy = popup.getMenu().findItem(R.id.menu_copy);
final MenuItem cut = popup.getMenu().findItem(R.id.menu_cut);
final MenuItem compress = popup.getMenu().findItem(R.id.menu_compress);
final MenuItem uncompress = popup.getMenu().findItem(R.id.menu_uncompress);
final MenuItem bookmark = popup.getMenu().findItem(R.id.menu_bookmark);
final Cursor cursor = mAdapter.getItem(position);
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
final boolean manageMode = state.action == ACTION_BROWSE;
if (null != doc) {
final boolean isCompressed = doc != null && MimePredicate.mimeMatches(MimePredicate.COMPRESSED_MIMES, doc.mimeType);
if (null != compress)
compress.setVisible(manageMode && doc.isArchiveSupported() && !isCompressed && !isOperationSupported);
if (null != uncompress)
uncompress.setVisible(manageMode && doc.isArchiveSupported() && isCompressed && !isOperationSupported);
if (null != bookmark) {
bookmark.setVisible(manageMode && doc.isBookmarkSupported() && Utils.isDir(doc.mimeType) && !isOperationSupported);
}
share.setVisible(manageMode);
delete.setVisible(manageMode && doc.isDeleteSupported());
rename.setVisible(manageMode && doc.isRenameSupported());
copy.setVisible(manageMode && doc.isCopySupported());
cut.setVisible(manageMode && doc.isMoveSupported());
}
}
popup.show();
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class StandaloneActivity method dumpStack.
private void dumpStack() {
Log.d(TAG, "Current stack: ");
Log.d(TAG, " * " + mState.stack.root);
for (DocumentInfo doc : mState.stack) {
Log.d(TAG, " +-- " + doc);
}
}
Aggregations