Merge "Disable auto-drawer opening if intent is creating doc on empty dir." into nyc-dev

am: 3a1ae58

* commit '3a1ae582864f0728584b53c068b2300b38f8c3f0':
  Disable auto-drawer opening if intent is creating doc on empty dir.

Change-Id: Ia283ac2d760ca235d9de08fb67144fe0add7032f
This commit is contained in:
Ben Lin
2016-04-15 00:15:24 +00:00
committed by android-build-merger
2 changed files with 11 additions and 3 deletions

View File

@@ -17,6 +17,7 @@
package com.android.documentsui; package com.android.documentsui;
import static com.android.documentsui.Shared.TAG; import static com.android.documentsui.Shared.TAG;
import static com.android.documentsui.State.ACTION_CREATE;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
@@ -107,8 +108,9 @@ public class RecentsCreateFragment extends Fragment {
mAdapter.update(data); mAdapter.update(data);
// When launched into empty recents, show drawer // When launched into empty recents, show drawer
if (mAdapter.isEmpty() && !state.hasLocationChanged() && if (mAdapter.isEmpty() && !state.hasLocationChanged()
context instanceof DocumentsActivity) { && state.action != ACTION_CREATE
&& context instanceof DocumentsActivity) {
((DocumentsActivity) context).setRootsDrawerOpen(true); ((DocumentsActivity) context).setRootsDrawerOpen(true);
} }
} }

View File

@@ -90,6 +90,10 @@ public abstract class FragmentTuner {
*/ */
private static final class DocumentsTuner extends FragmentTuner { private static final class DocumentsTuner extends FragmentTuner {
// We use this to keep track of whether a model has been previously loaded or not so we can
// open the drawer on empty directories on first launch
private boolean mModelPreviousLoaded;
public DocumentsTuner(Context context, State state) { public DocumentsTuner(Context context, State state) {
super(context, state); super(context, state);
} }
@@ -178,10 +182,12 @@ public abstract class FragmentTuner {
showDrawer = true; showDrawer = true;
} }
if (showDrawer && !mState.hasInitialLocationChanged() && !isSearch) { if (showDrawer && !mState.hasInitialLocationChanged() && !isSearch
&& !mModelPreviousLoaded) {
// This noops on layouts without drawer, so no need to guard. // This noops on layouts without drawer, so no need to guard.
((BaseActivity) mContext).setRootsDrawerOpen(true); ((BaseActivity) mContext).setRootsDrawerOpen(true);
} }
mModelPreviousLoaded = true;
} }
@Override @Override