use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
the class FilesActivity method refreshDirectory.
@Override
void refreshDirectory(int anim) {
final FragmentManager fm = getFragmentManager();
final RootInfo root = getCurrentRoot();
final DocumentInfo cwd = getCurrentDirectory();
assert (!mSearchManager.isSearching());
if (cwd == null) {
DirectoryFragment.showRecentsOpen(fm, anim);
} else {
// Normal boring directory
DirectoryFragment.showDirectory(fm, root, cwd, anim);
}
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
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);
}
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
the class DocumentClipper method getClipDataForDocuments.
/**
* Returns ClipData representing the list of docs, or null if docs is empty,
* or docs cannot be converted.
*/
@Nullable
public ClipData getClipDataForDocuments(List<DocumentInfo> docs) {
final ContentResolver resolver = mContext.getContentResolver();
final String[] mimeTypes = getMimeTypes(resolver, docs);
ClipData clipData = null;
for (DocumentInfo doc : docs) {
if (clipData == null) {
// TODO: figure out what this string should be.
// Currently it is not displayed anywhere in the UI, but this might change.
final String label = "";
clipData = new ClipData(label, mimeTypes, new ClipData.Item(doc.derivedUri));
} else {
// TODO: update list of mime types in ClipData.
clipData.addItem(new ClipData.Item(doc.derivedUri));
}
}
return clipData;
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by crdroidandroid.
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 android_frameworks_base by crdroidandroid.
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);
}
Aggregations