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:
@@ -17,7 +17,6 @@
|
|||||||
package com.android.documentsui.dirlist;
|
package com.android.documentsui.dirlist;
|
||||||
|
|
||||||
import static com.android.documentsui.Shared.DEBUG;
|
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_GRID;
|
||||||
import static com.android.documentsui.State.MODE_LIST;
|
import static com.android.documentsui.State.MODE_LIST;
|
||||||
import static com.android.documentsui.State.SORT_ORDER_UNKNOWN;
|
import static com.android.documentsui.State.SORT_ORDER_UNKNOWN;
|
||||||
@@ -1535,7 +1534,7 @@ public class DirectoryFragment extends Fragment
|
|||||||
mRoot.authority, mRoot.rootId, mQuery)
|
mRoot.authority, mRoot.rootId, mQuery)
|
||||||
: DocumentsContract.buildChildDocumentsUri(
|
: DocumentsContract.buildChildDocumentsUri(
|
||||||
mDocument.authority, mDocument.documentId);
|
mDocument.authority, mDocument.documentId);
|
||||||
if (state.action == ACTION_MANAGE) {
|
if (mTuner.enableManagedMode()) {
|
||||||
contentsUri = DocumentsContract.setManageMode(contentsUri);
|
contentsUri = DocumentsContract.setManageMode(contentsUri);
|
||||||
}
|
}
|
||||||
return new DirectoryLoader(
|
return new DirectoryLoader(
|
||||||
@@ -1544,6 +1543,7 @@ public class DirectoryFragment extends Fragment
|
|||||||
case TYPE_RECENT_OPEN:
|
case TYPE_RECENT_OPEN:
|
||||||
final RootsCache roots = DocumentsApplication.getRootsCache(context);
|
final RootsCache roots = DocumentsApplication.getRootsCache(context);
|
||||||
return new RecentsLoader(context, roots, state);
|
return new RecentsLoader(context, roots, state);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unknown type " + mType);
|
throw new IllegalStateException("Unknown type " + mType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ public abstract class FragmentTuner {
|
|||||||
|
|
||||||
abstract void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch);
|
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.
|
* Provides support for Platform specific specializations of DirectoryFragment.
|
||||||
*/
|
*/
|
||||||
@@ -157,6 +163,11 @@ public abstract class FragmentTuner {
|
|||||||
((BaseActivity) mContext).setRootsDrawerOpen(true);
|
((BaseActivity) mContext).setRootsDrawerOpen(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enableManagedMode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,6 +177,7 @@ public abstract class FragmentTuner {
|
|||||||
|
|
||||||
public DownloadsTuner(Context context, State state) {
|
public DownloadsTuner(Context context, State state) {
|
||||||
super(context, state);
|
super(context, state);
|
||||||
|
assert(state.action == ACTION_MANAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -192,6 +204,11 @@ public abstract class FragmentTuner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {}
|
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);
|
((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) {
|
private static boolean isDirectory(String mimeType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user