Merge "Rechristen Downloads > Files." into nyc-andromeda-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 65c7cdc..286871b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -44,7 +44,7 @@
 
         <activity
             android:name=".files.LauncherActivity"
-            android:label="@string/downloads_label"
+            android:label="@string/app_label"
             android:icon="@drawable/files_icon"
             android:theme="@android:style/Theme.NoDisplay">
         </activity>
@@ -53,7 +53,7 @@
         <activity-alias
             android:name=".Launcher"
             android:targetActivity=".files.LauncherActivity"
-            android:label="@string/downloads_label"
+            android:label="@string/app_label"
             android:icon="@drawable/files_icon" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -63,7 +63,7 @@
 
         <activity
             android:name=".files.FilesActivity"
-            android:label="@string/downloads_label"
+            android:label="@string/app_label"
             android:icon="@drawable/files_icon"
             android:documentLaunchMode="intoExisting"
             android:theme="@style/DocumentsTheme">
diff --git a/res/values/config.xml b/res/values/config.xml
index ec8c544..17b9574 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -15,16 +15,13 @@
 -->
 
 <resources>
-    <!-- Allow Advanced Devices default value to be customised -->
-    <bool name="config_defaultAdvancedDevices">false</bool>
-
     <!-- Intentionally unset. Vendors should set this in an overlay. -->
     <string name="trusted_quick_viewer_package" translatable="false"></string>
 
-    <!-- Flags setup as productivity oriented in which case Downloads app will be presented
-             as Files app. Including showing of the Documents and "advanced" roots. -->
-    <bool name="productivity_device">false</bool>
+    <!-- Enable productivity oriented features like "Documents" root, and new window view. -->
+    <bool name="productivity_device">true</bool>
 
-    <!-- Indicates if search view is taking the whole toolbar space -->
+    <!-- Indicates if search view is taking the whole toolbar space. On larger
+         layouts we reduce this to an input-box adjacent to menu actions. -->
     <bool name="full_bar_search_view">true</bool>
 </resources>
diff --git a/res/values/drawables.xml b/res/values/drawables.xml
index 3cb6c76..2d2acbb 100644
--- a/res/values/drawables.xml
+++ b/res/values/drawables.xml
@@ -16,6 +16,6 @@
 
 <resources>
     <item name="app_icon" type="drawable">@mipmap/ic_app_icon</item>
-    <item name="files_icon" type="drawable">@mipmap/ic_launcher_downloads</item>
+    <item name="files_icon" type="drawable">@mipmap/ic_app_icon</item>
     <item name="picker_icon" type="drawable">@drawable/ic_doc_text</item>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1fbf564..ebb92f3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -18,9 +18,6 @@
     <!-- Title of the documents application [CHAR LIMIT=32] -->
     <string name="app_label">Files</string>
 
-    <!-- Title of the standalone downloads activity. [CHAR LIMIT=32] -->
-    <string name="downloads_label">Downloads</string>
-
     <!-- Action bar title prompting user to choose a location to open a document from [CHAR LIMIT=32] -->
     <string name="title_open">Open from</string>
     <!-- Action bar title prompting user to choose a location to save a document to [CHAR LIMIT=32] -->
diff --git a/src/com/android/documentsui/MenuManager.java b/src/com/android/documentsui/MenuManager.java
index 55d2b0e..0489123 100644
--- a/src/com/android/documentsui/MenuManager.java
+++ b/src/com/android/documentsui/MenuManager.java
@@ -303,8 +303,10 @@
             mActivity = activity;
         }
 
-        public boolean shouldShowFancyFeatures() {
-            return Shared.shouldShowFancyFeatures(mActivity);
+        // TODO: Inject necessary deps directly into MenuManager, rather than
+        // getting this info indirectly via DirectoryDetails.
+        public boolean isProductivityModeEnabled() {
+            return Shared.isProductivityMode(mActivity);
         }
 
         public boolean hasRootSettings() {
diff --git a/src/com/android/documentsui/base/Shared.java b/src/com/android/documentsui/base/Shared.java
index c580cee..d8374a0 100644
--- a/src/com/android/documentsui/base/Shared.java
+++ b/src/com/android/documentsui/base/Shared.java
@@ -55,13 +55,6 @@
             "com.android.documentsui.PICK_COPY_DESTINATION";
 
     /**
-     * Extra flag allowing app to be opened in productivity mode (less downloadsy).
-     * Useful developers and the likes. When set to true overrides the default
-     * config value of productivity_device.
-     */
-    public static final String EXTRA_PRODUCTIVITY_MODE = "com.android.documentsui.PRODUCTIVITY";
-
-    /**
      * Extra boolean flag for {@link #ACTION_PICK_COPY_DESTINATION}, which
      * specifies if the destination directory needs to create new directory or not.
      */
@@ -221,7 +214,7 @@
      * Method can be overridden if the change of the behavior of the the child activity is needed.
      */
     public static Uri getDefaultRootUri(Activity activity) {
-        return shouldShowDocumentsRoot(activity, activity.getIntent())
+        return shouldShowDocumentsRoot(activity)
                 ? DocumentsContract.buildHomeUri()
                 : DocumentsContract.buildRootUri(
                         "com.android.providers.downloads.documents", "downloads");
@@ -240,17 +233,15 @@
     /*
      * Returns true if app is running in "productivity mode".
      */
-    private static boolean isProductivityMode(Context context, Intent intent) {
-        return intent.getBooleanExtra(
-                Shared.EXTRA_PRODUCTIVITY_MODE,
-                context.getResources().getBoolean(R.bool.productivity_device));
+    public static boolean isProductivityMode(Context context) {
+        return context.getResources().getBoolean(R.bool.productivity_device);
     }
 
     /*
      * Returns true if "Documents" root should be shown.
      */
-    public static boolean shouldShowDocumentsRoot(Context context, Intent intent) {
-        return isProductivityMode(context, intent);
+    public static boolean shouldShowDocumentsRoot(Context context) {
+        return isProductivityMode(context);
     }
 
     /*
@@ -261,15 +252,6 @@
         return intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
     }
 
-    /**
-     * Returns true if device root should be shown.
-     */
-    public static boolean shouldShowFancyFeatures(Activity activity) {
-        Intent intent = activity.getIntent();
-        return isProductivityMode(activity, intent)
-                || intent.getBooleanExtra(DocumentsContract.EXTRA_FANCY_FEATURES, false);
-    }
-
     public static void checkMainLoop() {
         if (Looper.getMainLooper() != Looper.myLooper()) {
             Log.e(TAG, "Calling from non-UI thread!");
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index cc6a548..59b58f1 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -737,14 +737,6 @@
                 .withSrcs(srcs)
                 .build();
 
-        // Relay any config overrides bits present in the original intent.
-        Intent original = getActivity().getIntent();
-        if (original != null && original.hasExtra(Shared.EXTRA_PRODUCTIVITY_MODE)) {
-            intent.putExtra(
-                    Shared.EXTRA_PRODUCTIVITY_MODE,
-                    original.getBooleanExtra(Shared.EXTRA_PRODUCTIVITY_MODE, false));
-        }
-
         // Set an appropriate title on the drawer when it is shown in the picker.
         // Coupled with the fact that we auto-open the drawer for copy/move operations
         // it should basically be the thing people see first.
diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java
index a62e6af..0c67b20 100644
--- a/src/com/android/documentsui/files/FilesActivity.java
+++ b/src/com/android/documentsui/files/FilesActivity.java
@@ -217,7 +217,7 @@
         Intent intent = getIntent();
         return (intent != null && intent.hasExtra(Intent.EXTRA_TITLE))
                 ? intent.getStringExtra(Intent.EXTRA_TITLE)
-                : getString(R.string.downloads_label);
+                : getString(R.string.app_label);
     }
 
     @Override
diff --git a/src/com/android/documentsui/files/LauncherActivity.java b/src/com/android/documentsui/files/LauncherActivity.java
index e76728f..a73d439 100644
--- a/src/com/android/documentsui/files/LauncherActivity.java
+++ b/src/com/android/documentsui/files/LauncherActivity.java
@@ -29,8 +29,6 @@
 import android.support.annotation.Nullable;
 import android.util.Log;
 
-import com.android.documentsui.base.Shared;
-
 import java.util.List;
 
 /**
@@ -50,9 +48,7 @@
     // Array of boolean extras that should be copied when creating new launch intents.
     // Missing intents will be ignored.
     private static final String[] PERSISTENT_BOOLEAN_EXTRAS = {
-        DocumentsContract.EXTRA_SHOW_ADVANCED,
-        DocumentsContract.EXTRA_FANCY_FEATURES,
-        Shared.EXTRA_PRODUCTIVITY_MODE
+        DocumentsContract.EXTRA_SHOW_ADVANCED
     };
 
     @Override
diff --git a/src/com/android/documentsui/files/MenuManager.java b/src/com/android/documentsui/files/MenuManager.java
index 839c245..e2ca4d7 100644
--- a/src/com/android/documentsui/files/MenuManager.java
+++ b/src/com/android/documentsui/files/MenuManager.java
@@ -135,7 +135,7 @@
 
     @Override
     protected void updateNewWindow(MenuItem newWindow) {
-        newWindow.setVisible(mDirDetails.shouldShowFancyFeatures());
+        newWindow.setVisible(mDirDetails.isProductivityModeEnabled());
     }
 
     @Override
diff --git a/src/com/android/documentsui/sidebar/RootsFragment.java b/src/com/android/documentsui/sidebar/RootsFragment.java
index 4e9287e..88c98a4 100644
--- a/src/com/android/documentsui/sidebar/RootsFragment.java
+++ b/src/com/android/documentsui/sidebar/RootsFragment.java
@@ -259,7 +259,7 @@
             final RootItem item = new RootItem(root, mActionHandler);
 
             Activity activity = getActivity();
-            if (root.isHome() && !Shared.shouldShowDocumentsRoot(activity, activity.getIntent())) {
+            if (root.isHome() && !Shared.shouldShowDocumentsRoot(activity)) {
                 continue;
             } else if (root.isLibrary()) {
                 libraries.add(item);
diff --git a/tests/common/com/android/documentsui/testing/TestDirectoryDetails.java b/tests/common/com/android/documentsui/testing/TestDirectoryDetails.java
index 82bd047..a8a7645 100644
--- a/tests/common/com/android/documentsui/testing/TestDirectoryDetails.java
+++ b/tests/common/com/android/documentsui/testing/TestDirectoryDetails.java
@@ -35,7 +35,7 @@
     }
 
     @Override
-    public boolean shouldShowFancyFeatures() {
+    public boolean isProductivityModeEnabled() {
         return shouldShowFancyFeatures;
     }
 
diff --git a/tests/functional/com/android/documentsui/FilesActivityDefaultsUiTest.java b/tests/functional/com/android/documentsui/FilesActivityDefaultsUiTest.java
index ff86a7f..aaace3e 100644
--- a/tests/functional/com/android/documentsui/FilesActivityDefaultsUiTest.java
+++ b/tests/functional/com/android/documentsui/FilesActivityDefaultsUiTest.java
@@ -72,6 +72,6 @@
     }
 
     private boolean docsRootEnabled() {
-        return Shared.shouldShowDocumentsRoot(context, new Intent(DocumentsContract.ACTION_BROWSE));
+        return Shared.shouldShowDocumentsRoot(context);
     }
 }