summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml18
-rw-r--r--res/mipmap-hdpi/ic_launcher_downloads.png (renamed from res/mipmap-hdpi/ic_launcher_download.png)bin4473 -> 4473 bytes
-rw-r--r--res/mipmap-mdpi/ic_launcher_downloads.png (renamed from res/mipmap-mdpi/ic_launcher_download.png)bin2818 -> 2818 bytes
-rw-r--r--res/mipmap-xhdpi/ic_launcher_downloads.png (renamed from res/mipmap-xhdpi/ic_launcher_download.png)bin6351 -> 6351 bytes
-rw-r--r--res/mipmap-xxhdpi/ic_launcher_downloads.png (renamed from res/mipmap-xxhdpi/ic_launcher_download.png)bin10361 -> 10361 bytes
-rw-r--r--res/mipmap-xxxhdpi/ic_launcher_downloads.png (renamed from res/mipmap-xxxhdpi/ic_launcher_download.png)bin14962 -> 14962 bytes
-rw-r--r--res/values/config.xml14
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/documentsui/BaseActivity.java18
-rw-r--r--src/com/android/documentsui/DocumentsActivity.java4
-rw-r--r--src/com/android/documentsui/FilesActivity.java5
-rw-r--r--src/com/android/documentsui/LauncherActivity.java19
-rw-r--r--src/com/android/documentsui/RootsFragment.java5
-rw-r--r--src/com/android/documentsui/Shared.java49
-rw-r--r--tests/src/com/android/documentsui/FilesActivityUiTest.java9
15 files changed, 95 insertions, 49 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 14609b21d..69912ab12 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -43,9 +43,9 @@
<activity
android:name=".LauncherActivity"
- android:theme="@android:style/Theme.NoDisplay"
- android:icon="@mipmap/ic_launcher_download"
- android:label="@string/downloads_label">
+ android:label="@string/downloads_label"
+ android:icon="@mipmap/ic_launcher_downloads"
+ android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -54,21 +54,21 @@
<activity
android:name=".FilesActivity"
- android:theme="@style/DocumentsTheme"
- android:icon="@mipmap/ic_launcher_download"
android:label="@string/downloads_label"
- android:documentLaunchMode="intoExisting">
+ android:icon="@mipmap/ic_launcher_downloads"
+ android:documentLaunchMode="intoExisting"
+ android:theme="@style/DocumentsTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.VIEW_DOWNLOADS" />
+ <action android:name="android.provider.action.BROWSE" />
<category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="vnd.android.document/root" />
</intent-filter>
<intent-filter>
- <action android:name="android.provider.action.BROWSE" />
+ <action android:name="android.intent.action.VIEW_DOWNLOADS" />
<category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.document/root" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
diff --git a/res/mipmap-hdpi/ic_launcher_download.png b/res/mipmap-hdpi/ic_launcher_downloads.png
index f958bbd3c..f958bbd3c 100644
--- a/res/mipmap-hdpi/ic_launcher_download.png
+++ b/res/mipmap-hdpi/ic_launcher_downloads.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_download.png b/res/mipmap-mdpi/ic_launcher_downloads.png
index f2e937663..f2e937663 100644
--- a/res/mipmap-mdpi/ic_launcher_download.png
+++ b/res/mipmap-mdpi/ic_launcher_downloads.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_download.png b/res/mipmap-xhdpi/ic_launcher_downloads.png
index 4dc533638..4dc533638 100644
--- a/res/mipmap-xhdpi/ic_launcher_download.png
+++ b/res/mipmap-xhdpi/ic_launcher_downloads.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_download.png b/res/mipmap-xxhdpi/ic_launcher_downloads.png
index 871629096..871629096 100644
--- a/res/mipmap-xxhdpi/ic_launcher_download.png
+++ b/res/mipmap-xxhdpi/ic_launcher_downloads.png
Binary files differ
diff --git a/res/mipmap-xxxhdpi/ic_launcher_download.png b/res/mipmap-xxxhdpi/ic_launcher_downloads.png
index f5be21991..f5be21991 100644
--- a/res/mipmap-xxxhdpi/ic_launcher_download.png
+++ b/res/mipmap-xxxhdpi/ic_launcher_downloads.png
Binary files differ
diff --git a/res/values/config.xml b/res/values/config.xml
index 6590bbeda..f0cab0872 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -20,13 +20,15 @@
<!-- Intentionally unset. Vendors should set this in an overlay. -->
<string name="trusted_quick_viewer_package" translatable="false"></string>
+
+ <!-- overridden for RTL langs -->
<bool name="list_divider_inset_left">true</bool>
- <!-- Indicates if the home directory should be hidden in the roots list, that is presented
- in the drawer/left side panel ) -->
- <bool name="home_root_hidden">true</bool>
- <!-- Indicates if the advanced roots like internal storage should be shown in the roots list.
- When enabled there is no menu option to toggle internal storage visibility. -->
- <bool name="advanced_roots_shown">false</bool>
+
+ <!-- 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>
+
<!-- Indicates if search view is taking the whole toolbar space -->
<bool name="full_bar_search_view">true</bool>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fb557caf8..3754d59a9 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">Documents</string>
- <!-- Title of the standalone files activity. [CHAR LIMIT=32] -->
- <string name="files_label">Files</string>
-
<!-- Title of the standalone downloads activity. [CHAR LIMIT=32] -->
<string name="downloads_label">Downloads</string>
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index 87136ef35..938805854 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -19,10 +19,9 @@ package com.android.documentsui;
import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.State.ACTION_CREATE;
+import static com.android.documentsui.State.ACTION_GET_CONTENT;
import static com.android.documentsui.State.ACTION_OPEN;
import static com.android.documentsui.State.ACTION_OPEN_TREE;
-import static com.android.documentsui.State.ACTION_GET_CONTENT;
-import static com.android.documentsui.State.ACTION_PICK_COPY_DESTINATION;
import static com.android.documentsui.State.MODE_GRID;
import android.app.Activity;
@@ -37,14 +36,12 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
-import android.os.MessageQueue;
import android.os.MessageQueue.IdleHandler;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Root;
import android.support.annotation.CallSuper;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
@@ -228,8 +225,7 @@ public abstract class BaseActivity extends Activity
includeState(state);
// Advanced roots are shown by deafult without menu option if forced by config or intent.
- state.showAdvanced = getResources().getBoolean(R.bool.advanced_roots_shown)
- || intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
+ state.showAdvanced = Shared.shouldShowDeviceRoot(this, intent);
// Menu option is shown for whitelisted intents if advanced roots are not shown by default.
state.showAdvancedOption = !state.showAdvanced &&
(state.action == ACTION_OPEN ||
@@ -478,11 +474,11 @@ public abstract class BaseActivity extends Activity
* Method can be overridden if the change of the behavior of the the child activity is needed.
*/
public Uri getDefaultRoot() {
- return Shared.isHomeRootHidden(this)
- ? DocumentsContract.buildRootUri("com.android.providers.downloads.documents",
- "downloads")
- : DocumentsContract.buildHomeUri();
- }
+ return Shared.shouldShowDocumentsRoot(this, getIntent())
+ ? DocumentsContract.buildHomeUri()
+ : DocumentsContract.buildRootUri(
+ "com.android.providers.downloads.documents", "downloads");
+ }
void setDisplayAdvancedDevices(boolean display) {
mState.showAdvanced = display;
diff --git a/src/com/android/documentsui/DocumentsActivity.java b/src/com/android/documentsui/DocumentsActivity.java
index 5788420a0..40b54d34e 100644
--- a/src/com/android/documentsui/DocumentsActivity.java
+++ b/src/com/android/documentsui/DocumentsActivity.java
@@ -203,8 +203,8 @@ public class DocumentsActivity extends BaseActivity {
mState.action == ACTION_PICK_COPY_DESTINATION) {
title = getResources().getString(R.string.title_save);
} else {
- // If all else fails, just call it "Downloads".
- title = getResources().getString(R.string.downloads_label);
+ // If all else fails, just call it "Documents".
+ title = getResources().getString(R.string.app_label);
}
}
diff --git a/src/com/android/documentsui/FilesActivity.java b/src/com/android/documentsui/FilesActivity.java
index d4439d8b4..30680acff 100644
--- a/src/com/android/documentsui/FilesActivity.java
+++ b/src/com/android/documentsui/FilesActivity.java
@@ -180,7 +180,10 @@ public class FilesActivity extends BaseActivity {
@Override
public String getDrawerTitle() {
- return getResources().getString(R.string.downloads_label);
+ Intent intent = getIntent();
+ return (intent != null && intent.hasExtra(Intent.EXTRA_TITLE))
+ ? intent.getStringExtra(Intent.EXTRA_TITLE)
+ : getTitle().toString();
}
@Override
diff --git a/src/com/android/documentsui/LauncherActivity.java b/src/com/android/documentsui/LauncherActivity.java
index 7930c28fc..5cb6ca347 100644
--- a/src/com/android/documentsui/LauncherActivity.java
+++ b/src/com/android/documentsui/LauncherActivity.java
@@ -87,9 +87,24 @@ public class LauncherActivity extends Activity {
startActivity(intent);
}
- static final Intent createLaunchIntent(Context context) {
- Intent intent = new Intent(context, FilesActivity.class);
+ static final Intent createLaunchIntent(Activity activity) {
+ Intent intent = new Intent(activity, FilesActivity.class);
intent.setData(buildLaunchUri());
+
+ // Relay any config overrides bits present in the original intent.
+ Intent original = activity.getIntent();
+ if (original != null) {
+ if (original.hasExtra(Shared.EXTRA_PRODUCTIVITY_MODE)) {
+ intent.putExtra(
+ Shared.EXTRA_PRODUCTIVITY_MODE,
+ original.getBooleanExtra(Shared.EXTRA_PRODUCTIVITY_MODE, false));
+ }
+ if (original.hasExtra(Intent.EXTRA_TITLE)) {
+ intent.putExtra(
+ Intent.EXTRA_TITLE,
+ original.getStringExtra(Intent.EXTRA_TITLE));
+ }
+ }
return intent;
}
diff --git a/src/com/android/documentsui/RootsFragment.java b/src/com/android/documentsui/RootsFragment.java
index 5f665c0e4..8bbcc306a 100644
--- a/src/com/android/documentsui/RootsFragment.java
+++ b/src/com/android/documentsui/RootsFragment.java
@@ -17,8 +17,8 @@
package com.android.documentsui;
import static com.android.documentsui.Shared.DEBUG;
-import static com.android.documentsui.State.ACTION_OPEN_TREE;
+import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
@@ -319,7 +319,8 @@ public class RootsFragment extends Fragment {
for (final RootInfo root : roots) {
final RootItem item = new RootItem(root);
- if (root.isHome() && Shared.isHomeRootHidden(context)) {
+ if (root.isHome() &&
+ !Shared.shouldShowDocumentsRoot(context, ((Activity) context).getIntent())) {
continue;
} else if (root.isLibrary()) {
if (DEBUG) Log.d(TAG, "Adding " + root + " as library.");
diff --git a/src/com/android/documentsui/Shared.java b/src/com/android/documentsui/Shared.java
index 2c60d4a32..1ba836a7f 100644
--- a/src/com/android/documentsui/Shared.java
+++ b/src/com/android/documentsui/Shared.java
@@ -16,19 +16,16 @@
package com.android.documentsui;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
+import android.provider.DocumentsContract;
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;
import java.util.ArrayList;
import java.util.List;
@@ -45,10 +42,21 @@ public final class Shared {
"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.
*/
public static final String EXTRA_DIRECTORY_COPY = "com.android.documentsui.DIRECTORY_COPY";
+
+ /**
+ * Extra flag used to store the current stack so user opens in right spot.
+ */
public static final String EXTRA_STACK = "com.android.documentsui.STACK";
/**
@@ -175,10 +183,33 @@ public final class Shared {
}
/*
- * Indicates if the home directory should be hidden in the roots list.
+ * Returns true if app is running in "productivity mode".
*/
- public static boolean isHomeRootHidden(Context context) {
- return context.getResources().getBoolean(R.bool.home_root_hidden);
+ public static boolean productivityMode(Context context) {
+ return context.getResources().getBoolean(R.bool.productivity_device);
}
+ /*
+ * 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));
+ }
+
+ /*
+ * Returns true if "Documents" root should be shown.
+ */
+ public static boolean shouldShowDocumentsRoot(Context context, Intent intent) {
+ return isProductivityMode(context, intent);
+ }
+
+ /*
+ * Returns true if device root should be shown.
+ */
+ public static boolean shouldShowDeviceRoot(Context context, Intent intent) {
+ return isProductivityMode(context, intent)
+ || intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
+ }
}
diff --git a/tests/src/com/android/documentsui/FilesActivityUiTest.java b/tests/src/com/android/documentsui/FilesActivityUiTest.java
index f2949196f..69f0e677e 100644
--- a/tests/src/com/android/documentsui/FilesActivityUiTest.java
+++ b/tests/src/com/android/documentsui/FilesActivityUiTest.java
@@ -22,8 +22,10 @@ import static com.android.documentsui.StubProvider.ROOT_1_ID;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
import android.content.Context;
+import android.content.Intent;
import android.net.Uri;
import android.os.RemoteException;
+import android.provider.DocumentsContract;
import android.support.test.uiautomator.Configurator;
import android.support.test.uiautomator.UiObject;
import android.test.suitebuilder.annotation.LargeTest;
@@ -69,11 +71,10 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
ROOT_1_ID);
// Separate logic for "Documents" root, which presence depends on the config setting
- boolean homeRootHidden = context.getResources().getBoolean(R.bool.home_root_hidden);
- if (homeRootHidden) {
- bots.roots.assertRootsAbsent("Documents");
- } else {
+ if (Shared.shouldShowDocumentsRoot(context, new Intent(DocumentsContract.ACTION_BROWSE))) {
bots.roots.assertRootsPresent("Documents");
+ } else {
+ bots.roots.assertRootsAbsent("Documents");
}
}