When launched into empty recents, show drawer.
Pull out drawer to give users more context about meaningful places
to navigate to. Also fix bug where restored roots weren't being
highlighted.
Bug: 10852518
Change-Id: Id294f6923477ca4dc505c4b0a21a5bdf8b722cf4
diff --git a/src/com/android/documentsui/DirectoryFragment.java b/src/com/android/documentsui/DirectoryFragment.java
index 59caad0..d34fb07 100644
--- a/src/com/android/documentsui/DirectoryFragment.java
+++ b/src/com/android/documentsui/DirectoryFragment.java
@@ -291,6 +291,11 @@
updateDisplayState();
+ // When launched into empty recents, show drawer
+ if (mType == TYPE_RECENT_OPEN && mAdapter.isEmpty() && !state.stackTouched) {
+ ((DocumentsActivity) context).setRootsDrawerOpen(true);
+ }
+
// Restore any previous instance state
final SparseArray<Parcelable> container = state.dirState.remove(mStateKey);
if (container != null && !getArguments().getBoolean(EXTRA_IGNORE_STATE, false)) {
diff --git a/src/com/android/documentsui/RecentsCreateFragment.java b/src/com/android/documentsui/RecentsCreateFragment.java
index 3954173..05766f5 100644
--- a/src/com/android/documentsui/RecentsCreateFragment.java
+++ b/src/com/android/documentsui/RecentsCreateFragment.java
@@ -109,6 +109,11 @@
public void onLoadFinished(
Loader<List<DocumentStack>> loader, List<DocumentStack> data) {
mAdapter.swapStacks(data);
+
+ // When launched into empty recents, show drawer
+ if (mAdapter.isEmpty() && !state.stackTouched) {
+ ((DocumentsActivity) context).setRootsDrawerOpen(true);
+ }
}
@Override
diff --git a/src/com/android/documentsui/RootsFragment.java b/src/com/android/documentsui/RootsFragment.java
index 2fb12bb..fdbc3ab 100644
--- a/src/com/android/documentsui/RootsFragment.java
+++ b/src/com/android/documentsui/RootsFragment.java
@@ -142,9 +142,12 @@
final RootInfo root = ((DocumentsActivity) getActivity()).getCurrentRoot();
for (int i = 0; i < mAdapter.getCount(); i++) {
final Object item = mAdapter.getItem(i);
- if (Objects.equal(item, root)) {
- mList.setItemChecked(i, true);
- return;
+ if (item instanceof RootItem) {
+ final RootInfo testRoot = ((RootItem) item).root;
+ if (Objects.equal(testRoot, root)) {
+ mList.setItemChecked(i, true);
+ return;
+ }
}
}
}