diff --git a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java index e6b22e6ed73f4..7ad4a094b3274 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java +++ b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java @@ -30,6 +30,7 @@ import android.net.Uri; import android.provider.DocumentsContract; import android.util.Log; +import com.android.documentsui.State.ActionType; import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.RootInfo; import com.android.documentsui.services.FileOperationService; @@ -502,7 +503,7 @@ public final class Metrics { * @param name The name of the histogram. * @param bucket The bucket to increment. */ - private static void logHistogram(Context context, String name, int bucket) { + private static void logHistogram(Context context, String name, @ActionType int bucket) { if (DEBUG) Log.d(TAG, name + ": " + bucket); MetricsLogger.histogram(context, name, bucket); } diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java index 35da8cc6357b8..8b4f40ef38bea 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java @@ -17,6 +17,7 @@ package com.android.documentsui; import static com.android.documentsui.Shared.DEBUG; +import static com.android.documentsui.State.ACTION_OPEN_TREE; import android.app.Fragment; import android.app.FragmentManager; @@ -117,7 +118,7 @@ public class RootsFragment extends Fragment { Intent handlerAppIntent = getArguments().getParcelable(EXTRA_INCLUDE_APPS); - mAdapter = new RootsAdapter(context, result, handlerAppIntent); + mAdapter = new RootsAdapter(context, result, handlerAppIntent, state); mList.setAdapter(mAdapter); onCurrentRootChanged(); @@ -308,8 +309,8 @@ public class RootsFragment extends Fragment { * @param handlerAppIntent When not null, apps capable of handling the original * intent will be included in list of roots (in special section at bottom). */ - public RootsAdapter( - Context context, Collection roots, @Nullable Intent handlerAppIntent) { + public RootsAdapter(Context context, Collection roots, + @Nullable Intent handlerAppIntent, State state) { super(context, 0); final List libraries = new ArrayList<>(); @@ -320,7 +321,8 @@ public class RootsFragment extends Fragment { if (root.isHome() && Shared.isHomeRootHidden(context)) { continue; - } else if (root.isAdvanced() && Shared.areAdvancedRootsHidden(context)) { + } else if (root.isAdvanced() + && Shared.areAdvancedRootsHidden(context, state)) { continue; } else if (root.isLibrary()) { if (DEBUG) Log.d(TAG, "Adding " + root + " as library."); diff --git a/packages/DocumentsUI/src/com/android/documentsui/Shared.java b/packages/DocumentsUI/src/com/android/documentsui/Shared.java index d21afee93434d..655359a70c241 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/Shared.java +++ b/packages/DocumentsUI/src/com/android/documentsui/Shared.java @@ -22,6 +22,11 @@ import android.text.TextUtils; import android.text.format.DateUtils; import android.text.format.Time; import android.view.WindowManager; + +import com.android.documentsui.State.ActionType; + +import static com.android.documentsui.State.ACTION_OPEN_TREE; + import android.app.AlertDialog; import java.text.Collator; @@ -179,8 +184,9 @@ public final class Shared { /* * Indicates if the advanced roots should be hidden. */ - public static boolean areAdvancedRootsHidden(Context context) { - return context.getResources().getBoolean(R.bool.advanced_roots_hidden); + public static boolean areAdvancedRootsHidden(Context context, State state) { + return context.getResources().getBoolean(R.bool.advanced_roots_hidden) + && state.action != ACTION_OPEN_TREE; } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/State.java b/packages/DocumentsUI/src/com/android/documentsui/State.java index 16b7660e8ba45..534a483474d30 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/State.java +++ b/packages/DocumentsUI/src/com/android/documentsui/State.java @@ -43,10 +43,19 @@ public class State implements android.os.Parcelable { private static final String TAG = "State"; + @IntDef(flag = true, value = { + ACTION_BROWSE, + ACTION_PICK_COPY_DESTINATION, + ACTION_OPEN, + ACTION_CREATE, + ACTION_GET_CONTENT, + ACTION_OPEN_TREE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface ActionType {} // File manager and related private picking activity. public static final int ACTION_BROWSE = 1; public static final int ACTION_PICK_COPY_DESTINATION = 2; - // All public picking activities public static final int ACTION_OPEN = 3; public static final int ACTION_CREATE = 4; @@ -69,7 +78,7 @@ public class State implements android.os.Parcelable { public static final int SORT_ORDER_LAST_MODIFIED = 2; public static final int SORT_ORDER_SIZE = 3; - public int action; + public @ActionType int action; public String[] acceptMimes; /** Derived from local preferences */