use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.
the class AbstractJobTest method createJob.
final T createJob(List<Uri> srcs, Uri srcParent, Uri destination) throws Exception {
DocumentStack stack = new DocumentStack();
stack.push(DocumentInfo.fromUri(mResolver, destination));
List<DocumentInfo> srcDocs = Lists.newArrayList();
for (Uri src : srcs) {
srcDocs.add(DocumentInfo.fromUri(mResolver, src));
}
return createJob(srcDocs, DocumentInfo.fromUri(mResolver, srcParent), stack);
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.
the class FileOperationServiceTest method createDoc.
private static DocumentInfo createDoc(Uri destination) {
DocumentInfo destDoc = new DocumentInfo();
destDoc.derivedUri = destination;
return destDoc;
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.
the class DirectoryFragment method transferDocuments.
private void transferDocuments(final Selection selected, @OpType final int mode) {
if (mode == FileOperationService.OPERATION_COPY) {
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_COPY_TO);
} else if (mode == FileOperationService.OPERATION_MOVE) {
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_MOVE_TO);
}
// Pop up a dialog to pick a destination. This is inadequate but works for now.
// TODO: Implement a picker that is to spec.
final Intent intent = new Intent(Shared.ACTION_PICK_COPY_DESTINATION, Uri.EMPTY, getActivity(), DocumentsActivity.class);
// Relay any config overrides bits present in the original intent.
Intent original = getActivity().getIntent();
if (original != null && original.hasExtra(Shared.EXTRA_PRODUCTIVITY_MODE)) {
intent.putExtra(Shared.EXTRA_PRODUCTIVITY_MODE, original.getBooleanExtra(Shared.EXTRA_PRODUCTIVITY_MODE, false));
}
// Set an appropriate title on the drawer when it is shown in the picker.
// Coupled with the fact that we auto-open the drawer for copy/move operations
// it should basically be the thing people see first.
int drawerTitleId = mode == FileOperationService.OPERATION_MOVE ? R.string.menu_move : R.string.menu_copy;
intent.putExtra(DocumentsContract.EXTRA_PROMPT, getResources().getString(drawerTitleId));
// Model must be accessed in UI thread, since underlying cursor is not threadsafe.
List<DocumentInfo> docs = mModel.getDocuments(selected);
// TODO: Can this move to Fragment bundle state?
getDisplayState().selectedDocumentsForCopy = docs;
// Determine if there is a directory in the set of documents
// to be copied? Why? Directory creation isn't supported by some roots
// (like Downloads). This informs DocumentsActivity (the "picker")
// to restrict available roots to just those with support.
intent.putExtra(Shared.EXTRA_DIRECTORY_COPY, hasDirectory(docs));
intent.putExtra(FileOperationService.EXTRA_OPERATION, mode);
// This just identifies the type of request...we'll check it
// when we reveive a response.
startActivityForResult(intent, REQUEST_COPY_DESTINATION);
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.
the class Model method getDocuments.
List<DocumentInfo> getDocuments(Selection items) {
final int size = (items != null) ? items.size() : 0;
final List<DocumentInfo> docs = new ArrayList<>(size);
for (String modelId : items.getAll()) {
final Cursor cursor = getItem(modelId);
if (cursor == null) {
Log.w(TAG, "Skipping document. Unabled to obtain cursor for modelId: " + modelId);
continue;
}
docs.add(DocumentInfo.fromDirectoryCursor(cursor));
}
return docs;
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.
the class DirectoryFragment method shareDocuments.
private void shareDocuments(final Selection selected) {
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SHARE);
// Model must be accessed in UI thread, since underlying cursor is not threadsafe.
List<DocumentInfo> docs = mModel.getDocuments(selected);
Intent intent;
// Filter out directories and virtual files - those can't be shared.
List<DocumentInfo> docsForSend = new ArrayList<>();
for (DocumentInfo doc : docs) {
if (!doc.isDirectory() && !doc.isVirtualDocument()) {
docsForSend.add(doc);
}
}
if (docsForSend.size() == 1) {
final DocumentInfo doc = docsForSend.get(0);
intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType(doc.mimeType);
intent.putExtra(Intent.EXTRA_STREAM, doc.derivedUri);
} else if (docsForSend.size() > 1) {
intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_DEFAULT);
final ArrayList<String> mimeTypes = new ArrayList<>();
final ArrayList<Uri> uris = new ArrayList<>();
for (DocumentInfo doc : docsForSend) {
mimeTypes.add(doc.mimeType);
uris.add(doc.derivedUri);
}
intent.setType(findCommonMimeType(mimeTypes));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
} else {
return;
}
intent = Intent.createChooser(intent, getActivity().getText(R.string.share_via));
startActivity(intent);
}
Aggregations