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

Commit 87e3c97f authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am 99f4fe07: Merge "Refactor directory API to "opening document tree."" into lmp-preview-dev

* commit '99f4fe0797adb8350f92c7d1ba11776d1947e768':
  Refactor directory API to "opening document tree."
parents a253ecb5 f4943e16
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PICK_DIRECTORY" />
                <action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
+13 −13
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import static com.android.documentsui.DocumentsActivity.State.ACTION_CREATE;
import static com.android.documentsui.DocumentsActivity.State.ACTION_GET_CONTENT;
import static com.android.documentsui.DocumentsActivity.State.ACTION_MANAGE;
import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN;
import static com.android.documentsui.DocumentsActivity.State.ACTION_PICK_DIRECTORY;
import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN_TREE;
import static com.android.documentsui.DocumentsActivity.State.MODE_GRID;
import static com.android.documentsui.DocumentsActivity.State.MODE_LIST;

@@ -203,7 +203,7 @@ public class DocumentsActivity extends Activity {
            final String mimeType = getIntent().getType();
            final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE);
            SaveFragment.show(getFragmentManager(), mimeType, title);
        } else if (mState.action == ACTION_PICK_DIRECTORY) {
        } else if (mState.action == ACTION_OPEN_TREE) {
            PickFragment.show(getFragmentManager());
        }

@@ -213,7 +213,7 @@ public class DocumentsActivity extends Activity {
            moreApps.setPackage(null);
            RootsFragment.show(getFragmentManager(), moreApps);
        } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE
                || mState.action == ACTION_PICK_DIRECTORY) {
                || mState.action == ACTION_OPEN_TREE) {
            RootsFragment.show(getFragmentManager(), null);
        }

@@ -240,8 +240,8 @@ public class DocumentsActivity extends Activity {
            mState.action = ACTION_CREATE;
        } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
            mState.action = ACTION_GET_CONTENT;
        } else if (Intent.ACTION_PICK_DIRECTORY.equals(action)) {
            mState.action = ACTION_PICK_DIRECTORY;
        } else if (Intent.ACTION_OPEN_DOCUMENT_TREE.equals(action)) {
            mState.action = ACTION_OPEN_TREE;
        } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
            mState.action = ACTION_MANAGE;
        }
@@ -441,7 +441,7 @@ public class DocumentsActivity extends Activity {
            actionBar.setIcon(new ColorDrawable());

            if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT
                    || mState.action == ACTION_PICK_DIRECTORY) {
                    || mState.action == ACTION_OPEN_TREE) {
                actionBar.setTitle(R.string.title_open);
            } else if (mState.action == ACTION_CREATE) {
                actionBar.setTitle(R.string.title_save);
@@ -583,7 +583,7 @@ public class DocumentsActivity extends Activity {
        sortSize.setVisible(mState.showSize);

        final boolean searchVisible;
        if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) {
        if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
            createDir.setVisible(cwd != null && cwd.isCreateSupported());
            searchVisible = false;

@@ -828,7 +828,7 @@ public class DocumentsActivity extends Activity {

        if (cwd == null) {
            // No directory means recents
            if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) {
            if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
                RecentsCreateFragment.show(fm);
            } else {
                DirectoryFragment.showRecentsOpen(fm, anim);
@@ -857,7 +857,7 @@ public class DocumentsActivity extends Activity {
            }
        }

        if (mState.action == ACTION_PICK_DIRECTORY) {
        if (mState.action == ACTION_OPEN_TREE) {
            final PickFragment pick = PickFragment.get(fm);
            if (pick != null) {
                final CharSequence displayName = (mState.stack.size() <= 1) ? root.title
@@ -1021,7 +1021,7 @@ public class DocumentsActivity extends Activity {
    }

    public void onPickRequested(DocumentInfo pickTarget) {
        final Uri viaUri = DocumentsContract.buildViaUri(pickTarget.authority,
        final Uri viaUri = DocumentsContract.buildTreeDocumentUri(pickTarget.authority,
                pickTarget.documentId);
        new PickFinishTask(viaUri).executeOnExecutor(getCurrentExecutor());
    }
@@ -1031,7 +1031,7 @@ public class DocumentsActivity extends Activity {
        final ContentValues values = new ContentValues();

        final byte[] rawStack = DurableUtils.writeToArrayOrNull(mState.stack);
        if (mState.action == ACTION_CREATE || mState.action == ACTION_PICK_DIRECTORY) {
        if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
            // Remember stack for last create
            values.clear();
            values.put(RecentColumns.KEY, mState.stack.buildKey());
@@ -1064,7 +1064,7 @@ public class DocumentsActivity extends Activity {

        if (mState.action == ACTION_GET_CONTENT) {
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        } else if (mState.action == ACTION_PICK_DIRECTORY) {
        } else if (mState.action == ACTION_OPEN_TREE) {
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                    | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
@@ -1202,7 +1202,7 @@ public class DocumentsActivity extends Activity {
        public static final int ACTION_OPEN = 1;
        public static final int ACTION_CREATE = 2;
        public static final int ACTION_GET_CONTENT = 3;
        public static final int ACTION_PICK_DIRECTORY = 4;
        public static final int ACTION_OPEN_TREE = 4;
        public static final int ACTION_MANAGE = 5;

        public static final int MODE_UNKNOWN = 0;
+9 −7
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public class PickFragment extends Fragment {
    public void setPickTarget(DocumentInfo pickTarget, CharSequence displayName) {
        mPickTarget = pickTarget;

        if (mContainer != null) {
            if (mPickTarget != null) {
                mContainer.setVisibility(View.VISIBLE);
                final Locale locale = getResources().getConfiguration().locale;
@@ -87,3 +88,4 @@ public class PickFragment extends Fragment {
            }
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class RootsCache {
        mRecentsRoot.rootId = null;
        mRecentsRoot.icon = R.drawable.ic_root_recent;
        mRecentsRoot.flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE
                | Root.FLAG_SUPPORTS_DIR_SELECTION;
                | Root.FLAG_SUPPORTS_IS_CHILD;
        mRecentsRoot.title = mContext.getString(R.string.root_recent);
        mRecentsRoot.availableBytes = -1;

@@ -350,7 +350,7 @@ public class RootsCache {
        final List<RootInfo> matching = Lists.newArrayList();
        for (RootInfo root : roots) {
            final boolean supportsCreate = (root.flags & Root.FLAG_SUPPORTS_CREATE) != 0;
            final boolean supportsDir = (root.flags & Root.FLAG_SUPPORTS_DIR_SELECTION) != 0;
            final boolean supportsIsChild = (root.flags & Root.FLAG_SUPPORTS_IS_CHILD) != 0;
            final boolean advanced = (root.flags & Root.FLAG_ADVANCED) != 0;
            final boolean localOnly = (root.flags & Root.FLAG_LOCAL_ONLY) != 0;
            final boolean empty = (root.flags & Root.FLAG_EMPTY) != 0;
@@ -358,7 +358,7 @@ public class RootsCache {
            // Exclude read-only devices when creating
            if (state.action == State.ACTION_CREATE && !supportsCreate) continue;
            // Exclude roots that don't support directory picking
            if (state.action == State.ACTION_PICK_DIRECTORY && !supportsDir) continue;
            if (state.action == State.ACTION_OPEN_TREE && !supportsIsChild) continue;
            // Exclude advanced devices when not requested
            if (!state.showAdvanced && advanced) continue;
            // Exclude non-local devices when local only