use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class AbstractCopyJobTest method runCopyDirRecursivelyTest.
public void runCopyDirRecursivelyTest() throws Exception {
Uri testDir1 = mDocs.createFolder(mSrcRoot, "dir1");
mDocs.createDocument(testDir1, "text/plain", "test1.txt");
Uri testDir2 = mDocs.createFolder(testDir1, "dir2");
mDocs.createDocument(testDir2, "text/plain", "test2.txt");
createJob(newArrayList(testDir1)).run();
mJobListener.waitForFinished();
DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1");
mDocs.assertChildCount(dir1Copy.derivedUri, 2);
mDocs.assertHasDirectory(dir1Copy.derivedUri, "dir2");
mDocs.assertHasFile(dir1Copy.derivedUri, "test1.txt");
DocumentInfo dir2Copy = mDocs.findDocument(dir1Copy.documentId, "dir2");
mDocs.assertChildCount(dir2Copy.derivedUri, 1);
mDocs.assertHasFile(dir2Copy.derivedUri, "test2.txt");
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
the class DirectoryFragment method getDraggableDocuments.
private List<DocumentInfo> getDraggableDocuments(View currentItemView) {
String modelId = getModelId(currentItemView);
if (modelId == null) {
return Collections.EMPTY_LIST;
}
final List<DocumentInfo> selectedDocs = mModel.getDocuments(mSelectionManager.getSelection());
if (!selectedDocs.isEmpty()) {
if (!isSelected(modelId)) {
// There is a selection that does not include the current item, drag nothing.
return Collections.EMPTY_LIST;
}
return selectedDocs;
}
final Cursor cursor = mModel.getItem(modelId);
if (cursor == null) {
Log.w(TAG, "Undraggable document. Can't obtain cursor for modelId " + modelId);
return Collections.EMPTY_LIST;
}
return Lists.newArrayList(DocumentInfo.fromDirectoryCursor(cursor));
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
the class DirectoryFragment method generateDeleteMessage.
private String generateDeleteMessage(final List<DocumentInfo> docs) {
String message;
int dirsCount = 0;
for (DocumentInfo doc : docs) {
if (doc.isDirectory()) {
++dirsCount;
}
}
if (docs.size() == 1) {
// Deleteing 1 file xor 1 folder in cwd
// Address b/28772371, where including user strings in message can result in
// broken bidirectional support.
String displayName = BidiFormatter.getInstance().unicodeWrap(docs.get(0).displayName);
message = dirsCount == 0 ? getActivity().getString(R.string.delete_filename_confirmation_message, displayName) : getActivity().getString(R.string.delete_foldername_confirmation_message, displayName);
} else if (dirsCount == 0) {
// Deleting only files in cwd
message = Shared.getQuantityString(getActivity(), R.plurals.delete_files_confirmation_message, docs.size());
} else if (dirsCount == docs.size()) {
// Deleting only folders in cwd
message = Shared.getQuantityString(getActivity(), R.plurals.delete_folders_confirmation_message, docs.size());
} else {
// Deleting mixed items (files and folders) in cwd
message = Shared.getQuantityString(getActivity(), R.plurals.delete_items_confirmation_message, docs.size());
}
return message;
}
use of com.android.documentsui.model.DocumentInfo in project platform_frameworks_base by android.
the class DocumentsActivity method onPrepareOptionsMenu.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
final DocumentInfo cwd = getCurrentDirectory();
boolean picking = mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE || mState.action == ACTION_PICK_COPY_DESTINATION;
if (picking) {
// May already be hidden because the root
// doesn't support search.
mSearchManager.showMenu(false);
}
final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
final MenuItem grid = menu.findItem(R.id.menu_grid);
final MenuItem list = menu.findItem(R.id.menu_list);
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
createDir.setVisible(picking);
createDir.setEnabled(canCreateDirectory());
// No display options in recent directories
boolean inRecents = cwd == null;
if (picking && inRecents) {
grid.setVisible(false);
list.setVisible(false);
}
fileSize.setVisible(fileSize.isVisible() && !picking);
if (mState.action == ACTION_CREATE) {
final FragmentManager fm = getFragmentManager();
SaveFragment.get(fm).prepareForDirectory(cwd);
}
Menus.disableHiddenItems(menu);
return true;
}
use of com.android.documentsui.model.DocumentInfo in project platform_frameworks_base by android.
the class FilesActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mClipper = new DocumentClipper(this);
RootsFragment.show(getFragmentManager(), null);
final Intent intent = getIntent();
final Uri uri = intent.getData();
if (mState.restored) {
if (DEBUG)
Log.d(TAG, "Stack already resolved for uri: " + intent.getData());
} else if (!mState.stack.isEmpty()) {
// in downloads.
if (uri != null && uri.getAuthority() != null && !uri.equals(mState.stack.peek()) && !LauncherActivity.isLaunchUri(uri)) {
if (DEBUG)
Log.w(TAG, "Launching with non-empty stack. Ignoring unexpected uri: " + uri);
} else {
if (DEBUG)
Log.d(TAG, "Launching with non-empty stack.");
}
refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE);
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
assert (uri != null);
new OpenUriForViewTask(this).executeOnExecutor(ProviderExecutor.forAuthority(uri.getAuthority()), uri);
} else if (DocumentsContract.isRootUri(this, uri)) {
if (DEBUG)
Log.d(TAG, "Launching with root URI.");
// If we've got a specific root to display, restore that root using a dedicated
// authority. That way a misbehaving provider won't result in an ANR.
loadRoot(uri);
} else {
if (DEBUG)
Log.d(TAG, "All other means skipped. Launching into default directory.");
loadRoot(getDefaultRoot());
}
@DialogType final int dialogType = intent.getIntExtra(FileOperationService.EXTRA_DIALOG_TYPE, DIALOG_TYPE_UNKNOWN);
// Only show it manually for the first time (icicle is null).
if (icicle == null && dialogType != DIALOG_TYPE_UNKNOWN) {
final int opType = intent.getIntExtra(FileOperationService.EXTRA_OPERATION, FileOperationService.OPERATION_COPY);
final ArrayList<DocumentInfo> srcList = intent.getParcelableArrayListExtra(FileOperationService.EXTRA_SRC_LIST);
OperationDialogFragment.show(getFragmentManager(), dialogType, srcList, mState.stack, opType);
}
}
Aggregations