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

Commit d38b6f1f authored by Steve McKay's avatar Steve McKay Committed by Android (Google) Code Review
Browse files

Merge "Show active downloads in Files app Downloads dir." into nyc-dev

parents 875825d0 75fe6bca
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.documentsui.dirlist;

import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.State.ACTION_MANAGE;
import static com.android.documentsui.State.MODE_GRID;
import static com.android.documentsui.State.MODE_LIST;
import static com.android.documentsui.State.SORT_ORDER_UNKNOWN;
@@ -1535,7 +1534,7 @@ public class DirectoryFragment extends Fragment
                        mRoot.authority, mRoot.rootId, mQuery)
                        : DocumentsContract.buildChildDocumentsUri(
                                mDocument.authority, mDocument.documentId);
                if (state.action == ACTION_MANAGE) {
                if (mTuner.enableManagedMode()) {
                    contentsUri = DocumentsContract.setManageMode(contentsUri);
                }
                return new DirectoryLoader(
@@ -1544,6 +1543,7 @@ public class DirectoryFragment extends Fragment
            case TYPE_RECENT_OPEN:
                final RootsCache roots = DocumentsApplication.getRootsCache(context);
                return new RecentsLoader(context, roots, state);

            default:
                throw new IllegalStateException("Unknown type " + mType);
        }
+28 −0
Original line number Diff line number Diff line
@@ -81,6 +81,12 @@ public abstract class FragmentTuner {

    abstract void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch);

    /**
     * When managed mode is enabled, active downloads will be visible in the UI.
     * Presumably this should only be true when in the downloads directory.
     */
    abstract boolean enableManagedMode();

    /**
     * Provides support for Platform specific specializations of DirectoryFragment.
     */
@@ -157,6 +163,11 @@ public abstract class FragmentTuner {
                ((BaseActivity) mContext).setRootsDrawerOpen(true);
            }
        }

        @Override
        public boolean enableManagedMode() {
            return false;
        }
    }

    /**
@@ -166,6 +177,7 @@ public abstract class FragmentTuner {

        public DownloadsTuner(Context context, State state) {
            super(context, state);
            assert(state.action == ACTION_MANAGE);
        }

        @Override
@@ -192,6 +204,11 @@ public abstract class FragmentTuner {

        @Override
        void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {}

        @Override
        public boolean enableManagedMode() {
            return mState.stack.root != null && mState.stack.root.isDownloads();
        }
    }

    /**
@@ -233,6 +250,17 @@ public abstract class FragmentTuner {
                ((BaseActivity) mContext).setRootsDrawerOpen(true);
            }
        }

        @Override
        public boolean enableManagedMode() {
            // When in downloads top level directory, we also show active downloads.
            // And while we don't allow folders in Downloads, we do allow Zip files in
            // downloads that themselves can be opened and viewed like directories.
            // This method helps us understand when to kick in on those special behaviors.
            return mState.stack.root != null
                    && mState.stack.root.isDownloads()
                    && mState.stack.size() == 1;
        }
    }

    private static boolean isDirectory(String mimeType) {