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

am: d38b6f1f70

* commit 'd38b6f1f709397a884a20a6e412c29e95da81153':
  Show active downloads in Files app Downloads dir.
This commit is contained in:
Steve McKay
2016-03-08 00:39:26 +00:00
committed by android-build-merger
2 changed files with 30 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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) {