summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI/src/com/android/documentsui
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-09-21 13:57:33 -0700
committerJeff Sharkey <jsharkey@android.com>2013-09-21 14:07:16 -0700
commit5545f56f7561810187545a1817b6001dd1f9931b (patch)
tree94cfb5e5a543575adaedbf75ec243a9bbbf765d7 /packages/DocumentsUI/src/com/android/documentsui
parent562ce888af21fc18d1610545ff6373ee2ecbbb13 (diff)
downloadframeworks_base-5545f56f7561810187545a1817b6001dd1f9931b.zip
frameworks_base-5545f56f7561810187545a1817b6001dd1f9931b.tar.gz
frameworks_base-5545f56f7561810187545a1817b6001dd1f9931b.tar.bz2
Create unique files, root ordering, UI bugs.
When a file already exists on disk, try adding a counter suffix to make a unique name. Move services near top of roots list, just below recents. Remove "Documents" root. Increase number of recents allowed from single provider, and add more logging to diagnose wedged loaders. When launching GET_CONTENT apps, wait for successful result before relaying result; canceled requests now return to DocumentsUI. Add CloseGuard to ContentProviderClients, since leaked instances can keep the remote process alive. Fix UI bug around trailing breadcrumbs. Fix bug that dropped Recents from roots list. Add up action to Settings activity. Give our activity a default icon while waiting for async roots to load. Bug: 10818683, 10819461, 10819461, 10819196, 10860199 Change-Id: I7b9e26b1cf8353dd3175458b23da2b4bda6c5831
Diffstat (limited to 'packages/DocumentsUI/src/com/android/documentsui')
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java23
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java8
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java5
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RootsCache.java2
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java22
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/SettingsActivity.java11
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java2
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java2
8 files changed, 55 insertions, 20 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
index 457bb19..6d2f9b9 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
@@ -87,8 +87,8 @@ import libcore.io.IoUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
public class DocumentsActivity extends Activity {
@@ -96,6 +96,8 @@ public class DocumentsActivity extends Activity {
private static final String EXTRA_STATE = "state";
+ private static final int CODE_FORWARD = 42;
+
private boolean mShowAsDialog;
private SearchView mSearchView;
@@ -843,11 +845,24 @@ public class DocumentsActivity extends Activity {
public void onAppPicked(ResolveInfo info) {
final Intent intent = new Intent(getIntent());
- intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+ intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
intent.setComponent(new ComponentName(
info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
- startActivity(intent);
- finish();
+ startActivityForResult(intent, CODE_FORWARD);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ Log.d(TAG, "onActivityResult() code=" + resultCode);
+
+ // Only relay back results when not canceled; otherwise stick around to
+ // let the user pick another app/backend.
+ if (requestCode == CODE_FORWARD && resultCode != RESULT_CANCELED) {
+ setResult(resultCode, data);
+ finish();
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
}
public void onDocumentPicked(DocumentInfo doc) {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
index 3659c6e..e390456 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
@@ -52,6 +52,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
+ private static final boolean LOGD = true;
public static final int MAX_OUTSTANDING_RECENTS = 2;
@@ -63,7 +64,7 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
/**
* Maximum documents from a single root.
*/
- public static final int MAX_DOCS_FROM_ROOT = 24;
+ public static final int MAX_DOCS_FROM_ROOT = 64;
private static final ExecutorService sExecutor = buildExecutor();
@@ -194,6 +195,11 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
}
}
+ if (LOGD) {
+ Log.d(TAG, "Found " + cursors.size() + " of " + mTasks.size() + " recent queries done");
+ Log.d(TAG, sExecutor.toString());
+ }
+
final DirectoryResult result = new DirectoryResult();
result.sortOrder = SORT_ORDER_LAST_MODIFIED;
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java
index 5076370..a396f79 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java
@@ -195,12 +195,9 @@ public class RecentsCreateFragment extends Fragment {
final SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(stack.root.title);
- appendDrawable(builder, crumb);
for (int i = stack.size() - 2; i >= 0; i--) {
+ appendDrawable(builder, crumb);
builder.append(stack.get(i).displayName);
- if (i > 0) {
- appendDrawable(builder, crumb);
- }
}
title.setText(builder);
title.setEllipsize(TruncateAt.MIDDLE);
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
index 52d6cc8..15af8aa 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
@@ -179,6 +179,8 @@ public class RootsCache {
final Multimap<String, RootInfo> roots = ArrayListMultimap.create();
final HashSet<String> stoppedAuthorities = Sets.newHashSet();
+ roots.put(mRecentsRoot.authority, mRecentsRoot);
+
final ContentResolver resolver = mContext.getContentResolver();
final PackageManager pm = mContext.getPackageManager();
final List<ProviderInfo> providers = pm.queryContentProviders(
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java
index df9bce1..d602622 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java
@@ -253,6 +253,7 @@ public class RootsFragment extends Fragment {
}
private static class SectionedRootsAdapter extends SectionedListAdapter {
+ private final RootsAdapter mRecent;
private final RootsAdapter mServices;
private final RootsAdapter mShortcuts;
private final RootsAdapter mDevices;
@@ -260,12 +261,18 @@ public class RootsFragment extends Fragment {
public SectionedRootsAdapter(
Context context, Collection<RootInfo> roots, Intent includeApps) {
+ mRecent = new RootsAdapter(context);
mServices = new RootsAdapter(context);
mShortcuts = new RootsAdapter(context);
mDevices = new RootsAdapter(context);
mApps = new AppsAdapter(context);
for (RootInfo root : roots) {
+ if (root.authority == null) {
+ mRecent.add(root);
+ continue;
+ }
+
switch (root.rootType) {
case Root.ROOT_TYPE_SERVICE:
mServices.add(root);
@@ -297,15 +304,18 @@ public class RootsFragment extends Fragment {
mShortcuts.sort(comp);
mDevices.sort(comp);
+ if (mRecent.getCount() > 0) {
+ addSection(mRecent);
+ }
+ if (mServices.getCount() > 0) {
+ addSection(mServices);
+ }
if (mShortcuts.getCount() > 0) {
addSection(mShortcuts);
}
if (mDevices.getCount() > 0) {
addSection(mDevices);
}
- if (mServices.getCount() > 0) {
- addSection(mServices);
- }
if (mApps.getCount() > 0) {
addSection(mApps);
}
@@ -315,12 +325,6 @@ public class RootsFragment extends Fragment {
public static class RootComparator implements Comparator<RootInfo> {
@Override
public int compare(RootInfo lhs, RootInfo rhs) {
- if (lhs.authority == null) {
- return -1;
- } else if (rhs.authority == null) {
- return 1;
- }
-
final int score = DocumentInfo.compareToIgnoreCaseNullable(lhs.title, rhs.title);
if (score != 0) {
return score;
diff --git a/packages/DocumentsUI/src/com/android/documentsui/SettingsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/SettingsActivity.java
index a85f6a9..d423e3f 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/SettingsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/SettingsActivity.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
+import android.view.MenuItem;
public class SettingsActivity extends Activity {
private static final String KEY_ADVANCED_DEVICES = "advancedDevices";
@@ -47,9 +48,19 @@ public class SettingsActivity extends Activity {
final ActionBar bar = getActionBar();
if (bar != null) {
bar.setDisplayShowHomeEnabled(false);
+ bar.setDisplayHomeAsUpEnabled(true);
}
}
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java b/packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java
index 681cc9b..08a8c13 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java
@@ -181,7 +181,7 @@ public class DocumentInfo implements Durable, Parcelable {
@Override
public String toString() {
- return "Document{name=" + displayName + ", docId=" + documentId + "}";
+ return "Document{docId=" + documentId + ", name=" + displayName + "}";
}
public boolean isCreateSupported() {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java
index a870c7b..014901a 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java
@@ -185,7 +185,7 @@ public class RootInfo implements Durable, Parcelable {
@Override
public String toString() {
- return "Root{title=" + title + ", rootId=" + rootId + "}";
+ return "Root{authority=" + authority + ", rootId=" + rootId + ", title=" + title + "}";
}
public Drawable loadIcon(Context context) {