Search in sources :

Example 16 with DocumentInfo

use of com.android.documentsui.model.DocumentInfo in project platform_frameworks_base by android.

the class DocumentsActivity method refreshDirectory.

@Override
void refreshDirectory(int anim) {
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();
    if (cwd == null) {
        // No directory means recents
        if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE || mState.action == ACTION_PICK_COPY_DESTINATION) {
            RecentsCreateFragment.show(fm);
        } else {
            DirectoryFragment.showRecentsOpen(fm, anim);
            // In recents we pick layout mode based on the mimetype,
            // picking GRID for visual types. We intentionally don't
            // consult a user's saved preferences here since they are
            // set per root (not per root and per mimetype).
            boolean visualMimes = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes);
            mState.derivedMode = visualMimes ? State.MODE_GRID : State.MODE_LIST;
        }
    } else {
        // Normal boring directory
        DirectoryFragment.showDirectory(fm, root, cwd, anim);
    }
    // Forget any replacement target
    if (mState.action == ACTION_CREATE) {
        final SaveFragment save = SaveFragment.get(fm);
        if (save != null) {
            save.setReplaceTarget(null);
        }
    }
    if (mState.action == ACTION_OPEN_TREE || mState.action == ACTION_PICK_COPY_DESTINATION) {
        final PickFragment pick = PickFragment.get(fm);
        if (pick != null) {
            pick.setPickTarget(mState.action, mState.copyOperationSubType, cwd);
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(com.android.documentsui.model.RootInfo) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 17 with DocumentInfo

use of com.android.documentsui.model.DocumentInfo in project platform_frameworks_base by android.

the class BaseActivity method canCreateDirectory.

/**
     * Returns true if a directory can be created in the current location.
     * @return
     */
boolean canCreateDirectory() {
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();
    return cwd != null && cwd.isCreateSupported() && !mSearchManager.isSearching() && !root.isRecents() && !root.isDownloads();
}
Also used : RootInfo(com.android.documentsui.model.RootInfo) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 18 with DocumentInfo

use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.

the class BaseActivity method reloadSearch.

private void reloadSearch(String query) {
    FragmentManager fm = getFragmentManager();
    RootInfo root = getCurrentRoot();
    DocumentInfo cwd = getCurrentDirectory();
    DirectoryFragment.reloadSearch(fm, root, cwd, query);
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(com.android.documentsui.model.RootInfo) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 19 with DocumentInfo

use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.

the class DocumentClipper method getMimeTypes.

private static String[] getMimeTypes(ContentResolver resolver, List<DocumentInfo> docs) {
    final HashSet<String> mimeTypes = new HashSet<>();
    for (DocumentInfo doc : docs) {
        assert (doc != null);
        assert (doc.derivedUri != null);
        final Uri uri = doc.derivedUri;
        if ("content".equals(uri.getScheme())) {
            mimeTypes.add(resolver.getType(uri));
            final String[] streamTypes = resolver.getStreamTypes(uri, "*/*");
            if (streamTypes != null) {
                mimeTypes.addAll(Arrays.asList(streamTypes));
            }
        }
    }
    return mimeTypes.toArray(new String[0]);
}
Also used : Uri(android.net.Uri) HashSet(java.util.HashSet) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 20 with DocumentInfo

use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by ResurrectionRemix.

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;
}
Also used : ClipData(android.content.ClipData) ContentResolver(android.content.ContentResolver) DocumentInfo(com.android.documentsui.model.DocumentInfo) Nullable(android.support.annotation.Nullable)

Aggregations

DocumentInfo (com.android.documentsui.model.DocumentInfo)150 Uri (android.net.Uri)40 Cursor (android.database.Cursor)30 DocumentInfo.getCursorString (com.android.documentsui.model.DocumentInfo.getCursorString)30 FragmentManager (android.app.FragmentManager)20 Point (android.graphics.Point)20 RootInfo (com.android.documentsui.model.RootInfo)20 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)15 DocumentsContract.buildChildDocumentsUri (android.provider.DocumentsContract.buildChildDocumentsUri)15 DocumentsContract.buildDocumentUri (android.provider.DocumentsContract.buildDocumentUri)15 ClipData (android.content.ClipData)10 ContentResolver (android.content.ContentResolver)10 DialogInterface (android.content.DialogInterface)10 RemoteException (android.os.RemoteException)10 BaseActivity (com.android.documentsui.BaseActivity)10 DocumentStack (com.android.documentsui.model.DocumentStack)10 Activity (android.app.Activity)5 AlertDialog (android.app.AlertDialog)5 ContentProviderClient (android.content.ContentProviderClient)5