Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c96e494a authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "DocumentsUI: Filter out downloads root if the source documents include directory."

parents e26bd2c3 9be34298
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -37,6 +37,12 @@ abstract class BaseActivity extends Activity {
    public static String ACTION_OPEN_COPY_DESTINATION_STRING =
        "com.android.documentsui.OPEN_COPY_DESTINATION";

    /**
     * Extra boolean flag for ACTION_OPEN_COPY_DESTINATION_STRING, which
     * specifies if the destination directory needs to create new directory or not.
     */
    public static String EXTRA_DIRECTORY_COPY = "com.android.documentsui.DIRECTORY_COPY";

    public abstract State getDisplayState();
    public abstract RootInfo getCurrentRoot();
    public abstract void onStateChanged();
@@ -77,6 +83,7 @@ abstract class BaseActivity extends Activity {
        public boolean showAdvanced = false;
        public boolean stackTouched = false;
        public boolean restored = false;
        public boolean directoryCopy = false;

        /** Current user navigation stack; empty implies recents. */
        public DocumentStack stack = new DocumentStack();
+8 −0
Original line number Diff line number Diff line
@@ -687,6 +687,14 @@ public class DirectoryFragment extends Fragment {
                Uri.EMPTY,
                getActivity(),
                DocumentsActivity.class);
        boolean directoryCopy = false;
        for (DocumentInfo info : docs) {
            if (Document.MIME_TYPE_DIR.equals(info.mimeType)) {
                directoryCopy = true;
                break;
            }
        }
        intent.putExtra(BaseActivity.EXTRA_DIRECTORY_COPY, directoryCopy);
        startActivityForResult(intent, REQUEST_COPY_DESTINATION);
    }

+4 −0
Original line number Diff line number Diff line
@@ -265,6 +265,10 @@ public class DocumentsActivity extends BaseActivity {
        } else {
            mState.showSize = LocalPreferences.getDisplayFileSize(this);
        }
        if (mState.action == ACTION_OPEN_COPY_DESTINATION) {
            mState.directoryCopy = intent.getBooleanExtra(
                    BaseActivity.EXTRA_DIRECTORY_COPY, false);
        }
    }

    private class RestoreRootTask extends AsyncTask<Void, Void, RootInfo> {
+3 −0
Original line number Diff line number Diff line
@@ -367,6 +367,9 @@ public class RootsCache {
            if (!state.showAdvanced && advanced) continue;
            // Exclude non-local devices when local only
            if (state.localOnly && !localOnly) continue;
            // Exclude downloads roots that don't support directory creation
            // TODO: Add flag to check the root supports directory creation or not.
            if (state.directoryCopy && root.isDownloads()) continue;
            // Only show empty roots when creating
            if ((state.action != State.ACTION_CREATE ||
                 state.action != State.ACTION_OPEN_TREE ||