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

Commit 6eaf3863 authored by Steve McKay's avatar Steve McKay
Browse files

Populate quick view intent w/ file uris.

Change-Id: Ie4f15b11be1939f8b71752505caa9d74ab9f9680
parent 29095983
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3823,6 +3823,9 @@ public class Intent implements Parcelable, Cloneable {
    public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
            "android.intent.extra.SIM_ACTIVATION_RESPONSE";

    /** {@hide} */
    public static final String EXTRA_INDEX = "android.intent.extra.INDEX";

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // Intent flags (see mFlags variable).
+29 −2
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.documentsui;

import static com.android.documentsui.DirectoryFragment.ANIM_DOWN;
import static com.android.documentsui.DirectoryFragment.ANIM_NONE;
import static com.android.documentsui.DirectoryFragment.ANIM_SIDE;
import static com.android.documentsui.DirectoryFragment.ANIM_UP;
import static com.android.internal.util.Preconditions.checkArgument;

import android.annotation.Nullable;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
@@ -79,8 +82,9 @@ abstract class BaseActivity extends Activity {
    private final String mTag;

    public abstract State getDisplayState();
    public abstract void onDocumentPicked(DocumentInfo doc);
    public abstract void onDocumentPicked(DocumentInfo doc, @Nullable DocumentContext siblings);
    public abstract void onDocumentsPicked(List<DocumentInfo> docs);

    abstract void onTaskFinished(Uri... uris);
    abstract void onDirectoryChanged(int anim);
    abstract void updateActionBar();
@@ -258,6 +262,17 @@ abstract class BaseActivity extends Activity {
                && !root.isDownloads();
    }

    void onDirectoryCreated(DocumentInfo doc) {
        checkArgument(doc.isDirectory());
        openDirectory(doc);
    }

    void openDirectory(DocumentInfo doc) {
        getDisplayState().stack.push(doc);
        getDisplayState().stackTouched = true;
        onCurrentDirectoryChanged(ANIM_DOWN);
    }

    /**
     * Call this when directory changes. Prior to root fragment update
     * the (abstract) directoryChanged method will be called.
@@ -605,7 +620,6 @@ abstract class BaseActivity extends Activity {
            if (isDestroyed()) return;
            getDisplayState().restored = true;
            onCurrentDirectoryChanged(ANIM_NONE);

            onStackRestored(mRestoredStack, mExternal);
        }
    }
@@ -843,4 +857,17 @@ abstract class BaseActivity extends Activity {
            updateActionBar();
        }
    }

    /**
     * Interface providing access to current view of documents
     * even when all documents are not homed to the same parent.
     */
    interface DocumentContext {
        /**
         * Returns the cursor for the selected document. The cursor can be used to retrieve
         * details about a document and its siblings.
         * @return
         */
        Cursor getCursor();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public class CreateDirectoryFragment extends DialogFragment {
        protected void onPostExecute(DocumentInfo result) {
            if (result != null) {
                // Navigate into newly created child
                mActivity.onDocumentPicked(result);
                mActivity.onDirectoryCreated(result);
            } else {
                Toast.makeText(mActivity, R.string.create_error, Toast.LENGTH_SHORT).show();
            }
+12 −2
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.documentsui.BaseActivity.DocumentContext;
import com.android.documentsui.BaseActivity.State;
import com.android.documentsui.MultiSelectManager.Selection;
import com.android.documentsui.ProviderExecutor.Preemptable;
@@ -457,7 +458,7 @@ public class DirectoryFragment extends Fragment {
        final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
        if (isDocumentEnabled(docMimeType, docFlags)) {
            final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
            ((BaseActivity) getActivity()).onDocumentPicked(doc);
            ((BaseActivity) getActivity()).onDocumentPicked(doc, mAdapter);
            mSelectionManager.clearSelection();
            return true;
        }
@@ -949,7 +950,8 @@ public class DirectoryFragment extends Fragment {
        }
    }

    private final class DocumentsAdapter extends RecyclerView.Adapter<DocumentHolder> {
    private final class DocumentsAdapter extends RecyclerView.Adapter<DocumentHolder>
            implements DocumentContext {

        private final Context mContext;
        private final LayoutInflater mInflater;
@@ -1213,6 +1215,14 @@ public class DirectoryFragment extends Fragment {
            }
        }

        @Override
        public Cursor getCursor() {
            if (Looper.myLooper() != Looper.getMainLooper()) {
                throw new IllegalStateException("Can't call getCursor from non-main thread.");
            }
            return mCursor;
        }

        private Cursor getItem(int position) {
            if (position < mCursorCount) {
                mCursor.moveToPosition(position);
+3 −9
Original line number Diff line number Diff line
@@ -26,12 +26,8 @@ import static com.android.documentsui.BaseActivity.State.ACTION_OPEN_TREE;
import static com.android.documentsui.DirectoryFragment.ANIM_DOWN;
import static com.android.documentsui.DirectoryFragment.ANIM_NONE;
import static com.android.documentsui.DirectoryFragment.ANIM_UP;
import static com.android.internal.util.Preconditions.checkArgument;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
@@ -608,12 +604,10 @@ public class DocumentsActivity extends BaseActivity {
    }

    @Override
    public void onDocumentPicked(DocumentInfo doc) {
    public void onDocumentPicked(DocumentInfo doc, DocumentContext context) {
        final FragmentManager fm = getFragmentManager();
        if (doc.isDirectory()) {
            mState.stack.push(doc);
            mState.stackTouched = true;
            onCurrentDirectoryChanged(ANIM_DOWN);
            openDirectory(doc);
        } else if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
            // Explicit file picked, return
            new ExistingFinishTask(doc.derivedUri).executeOnExecutor(getCurrentExecutor());
Loading