Loading src/com/android/documentsui/AbstractActionHandler.java +11 −17 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final State mState; protected final RootsAccess mRoots; protected final DocumentsAccess mDocs; protected final ProviderAccess mProviders; protected final SelectionManager mSelectionMgr; protected final SearchViewManager mSearchMgr; protected final Lookup<String, Executor> mExecutors; Loading @@ -72,7 +71,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> State state, RootsAccess roots, DocumentsAccess docs, ProviderAccess providers, SelectionManager selectionMgr, SearchViewManager searchMgr, Lookup<String, Executor> executors) { Loading @@ -80,7 +78,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(activity != null); assert(state != null); assert(roots != null); assert(providers != null); assert(selectionMgr != null); assert(searchMgr != null); assert(docs != null); Loading @@ -89,7 +86,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mState = state; mRoots = roots; mDocs = docs; mProviders = providers; mSelectionMgr = selectionMgr; mSearchMgr = searchMgr; mExecutors = executors; Loading Loading @@ -181,33 +177,33 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> private void openFolderInSearchResult(@Nullable DocumentStack stack, DocumentInfo doc) { if (stack == null) { mState.popDocumentsToRoot(); mState.stack.popToRootDocument(); // Update navigator to give horizontal breadcrumb a chance to update documents. It // doesn't update its content if the size of document stack doesn't change. // TODO: update breadcrumb to take range update. mActivity.updateNavigator(); mState.pushDocument(doc); mState.stack.push(doc); } else { if (!Objects.equals(mState.stack.root, stack.root)) { Log.w(TAG, "Provider returns " + stack.root + " rather than expected " + mState.stack.root); if (!Objects.equals(mState.stack.getRoot(), stack.getRoot())) { Log.w(TAG, "Provider returns " + stack.getRoot() + " rather than expected " + mState.stack.getRoot()); } mState.stack.clear(); mState.stack.reset(); // Update navigator to give horizontal breadcrumb a chance to update documents. It // doesn't update its content if the size of document stack doesn't change. // TODO: update breadcrumb to take range update. mActivity.updateNavigator(); mState.setStack(stack); mState.stack.reset(stack); } // Show an opening animation only if pressing "back" would get us back to the // previous directory. Especially after opening a root document, pressing // back, wouldn't go to the previous root, but close the activity. final int anim = (mState.hasLocationChanged() && mState.stack.size() > 1) final int anim = (mState.stack.hasLocationChanged() && mState.stack.size() > 1) ? AnimationView.ANIM_ENTER : AnimationView.ANIM_NONE; mActivity.refreshCurrentRootAndDirectory(anim); } Loading @@ -226,11 +222,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(currentDoc != null); mActivity.notifyDirectoryNavigated(currentDoc.derivedUri); mState.pushDocument(currentDoc); mState.stack.push(currentDoc); // Show an opening animation only if pressing "back" would get us back to the // previous directory. Especially after opening a root document, pressing // back, wouldn't go to the previous root, but close the activity. final int anim = (mState.hasLocationChanged() && mState.stack.size() > 1) final int anim = (mState.stack.hasLocationChanged() && mState.stack.size() > 1) ? AnimationView.ANIM_ENTER : AnimationView.ANIM_NONE; mActivity.refreshCurrentRootAndDirectory(anim); } Loading @@ -248,12 +244,10 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final void loadDocument(Uri uri, LoadDocStackCallback callback) { new LoadDocStackTask( mActivity, uri, mRoots, mDocs, mProviders, callback ).executeOnExecutor(mExecutors.lookup(uri.getAuthority())); ).executeOnExecutor(mExecutors.lookup(uri.getAuthority()), uri); } @Override Loading src/com/android/documentsui/BaseActivity.java +4 −3 Original line number Diff line number Diff line Loading @@ -335,7 +335,7 @@ public abstract class BaseActivity<T extends ActionHandler> root.isRecents() || root.isDownloads() ? View.VISIBLE : View.INVISIBLE); // Clear entire backstack and start in new root mState.onRootChanged(root); mState.stack.changeRoot(root); // Recents is always in memory, so we just load it directly. // Otherwise we delegate loading data from disk to a task Loading Loading @@ -564,8 +564,9 @@ public abstract class BaseActivity<T extends ActionHandler> @Override public RootInfo getCurrentRoot() { if (mState.stack.root != null) { return mState.stack.root; RootInfo root = mState.stack.getRoot(); if (root != null) { return root; } else { return mRoots.getRecentsRoot(); } Loading src/com/android/documentsui/DocumentsAccess.java +26 −10 Original line number Diff line number Diff line Loading @@ -18,11 +18,13 @@ package com.android.documentsui; import android.annotation.Nullable; import android.content.ContentProviderClient; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.RemoteException; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Path; import android.util.Log; import com.android.documentsui.archives.ArchivesProvider; Loading @@ -34,7 +36,8 @@ import java.util.ArrayList; import java.util.List; /** * Provides synchronous access to {@link DocumentInfo} instances given some identifying information. * Provides synchronous access to {@link DocumentInfo} instances given some identifying information * and some documents API. */ public interface DocumentsAccess { Loading @@ -42,7 +45,10 @@ public interface DocumentsAccess { @Nullable DocumentInfo getDocument(Uri uri); @Nullable DocumentInfo getArchiveDocument(Uri uri); @Nullable List<DocumentInfo> getDocuments(String authority, List<String> docIds); boolean isDocumentUri(Uri uri); @Nullable Path findPath(Uri uri) throws RemoteException; List<DocumentInfo> getDocuments(String authority, List<String> docIds) throws RemoteException; public static DocumentsAccess create(Context context) { return new RuntimeDocumentAccess(context); Loading Loading @@ -76,7 +82,9 @@ public interface DocumentsAccess { } @Override public @Nullable List<DocumentInfo> getDocuments(String authority, List<String> docIds) { public List<DocumentInfo> getDocuments(String authority, List<String> docIds) throws RemoteException { try(final ContentProviderClient client = DocumentsApplication .acquireUnstableProviderOrThrow(mContext.getContentResolver(), authority)) { Loading @@ -86,20 +94,14 @@ public interface DocumentsAccess { try (final Cursor cursor = client.query(uri, null, null, null, null)) { if (!cursor.moveToNext()) { Log.e(TAG, "Couldn't create DocumentInfo for Uri: " + uri); return null; throw new RemoteException("Failed to move cursor."); } result.add(DocumentInfo.fromCursor(cursor, authority)); } catch (Exception e) { Log.e(TAG, "Couldn't create DocumentInfo for Uri: " + uri); return null; } } return result; } catch (RemoteException e) { Log.w(TAG, "Couldn't get a content provider client." ,e); return null; } } Loading @@ -107,5 +109,19 @@ public interface DocumentsAccess { public DocumentInfo getArchiveDocument(Uri uri) { return getDocument(ArchivesProvider.buildUriForArchive(uri)); } @Override public boolean isDocumentUri(Uri uri) { return DocumentsContract.isDocumentUri(mContext, uri); } @Override public Path findPath(Uri docUri) throws RemoteException { final ContentResolver resolver = mContext.getContentResolver(); try (final ContentProviderClient client = DocumentsApplication .acquireUnstableProviderOrThrow(resolver, docUri.getAuthority())) { return DocumentsContract.findPath(client, docUri); } } } } src/com/android/documentsui/DocumentsApplication.java +0 −10 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.net.Uri; import android.os.RemoteException; import android.text.format.DateUtils; import com.android.documentsui.ProviderAccess.RuntimeProviderAccess; import com.android.documentsui.clipping.ClipStorage; import com.android.documentsui.clipping.ClipStore; import com.android.documentsui.clipping.DocumentClipper; Loading @@ -43,8 +42,6 @@ public class DocumentsApplication extends Application { private ClipStorage mClipStore; private DocumentClipper mClipper; private ProviderAccess mProviderAccess; public static RootsCache getRootsCache(Context context) { return ((DocumentsApplication) context.getApplicationContext()).mRoots; } Loading @@ -54,11 +51,6 @@ public class DocumentsApplication extends Application { return app.mThumbnailCache; } public static ProviderAccess getProviderAccess(Context context) { final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext(); return app.mProviderAccess; } public static ContentProviderClient acquireUnstableProviderOrThrow( ContentResolver resolver, String authority) throws RemoteException { final ContentProviderClient client = resolver.acquireUnstableContentProviderClient( Loading Loading @@ -95,8 +87,6 @@ public class DocumentsApplication extends Application { getSharedPreferences(ClipStorage.PREF_NAME, 0)); mClipper = new DocumentClipper(this, mClipStore); mProviderAccess = new RuntimeProviderAccess(getContentResolver()); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); Loading src/com/android/documentsui/DropdownBreadcrumb.java +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public final class DropdownBreadcrumb extends Spinner implements Breadcrumb { @Override public DocumentInfo getItem(int position) { return mState.stack.get(mState.stack.size() - position - 1); return mState.stack.get(position); } @Override Loading Loading
src/com/android/documentsui/AbstractActionHandler.java +11 −17 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final State mState; protected final RootsAccess mRoots; protected final DocumentsAccess mDocs; protected final ProviderAccess mProviders; protected final SelectionManager mSelectionMgr; protected final SearchViewManager mSearchMgr; protected final Lookup<String, Executor> mExecutors; Loading @@ -72,7 +71,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> State state, RootsAccess roots, DocumentsAccess docs, ProviderAccess providers, SelectionManager selectionMgr, SearchViewManager searchMgr, Lookup<String, Executor> executors) { Loading @@ -80,7 +78,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(activity != null); assert(state != null); assert(roots != null); assert(providers != null); assert(selectionMgr != null); assert(searchMgr != null); assert(docs != null); Loading @@ -89,7 +86,6 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> mState = state; mRoots = roots; mDocs = docs; mProviders = providers; mSelectionMgr = selectionMgr; mSearchMgr = searchMgr; mExecutors = executors; Loading Loading @@ -181,33 +177,33 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> private void openFolderInSearchResult(@Nullable DocumentStack stack, DocumentInfo doc) { if (stack == null) { mState.popDocumentsToRoot(); mState.stack.popToRootDocument(); // Update navigator to give horizontal breadcrumb a chance to update documents. It // doesn't update its content if the size of document stack doesn't change. // TODO: update breadcrumb to take range update. mActivity.updateNavigator(); mState.pushDocument(doc); mState.stack.push(doc); } else { if (!Objects.equals(mState.stack.root, stack.root)) { Log.w(TAG, "Provider returns " + stack.root + " rather than expected " + mState.stack.root); if (!Objects.equals(mState.stack.getRoot(), stack.getRoot())) { Log.w(TAG, "Provider returns " + stack.getRoot() + " rather than expected " + mState.stack.getRoot()); } mState.stack.clear(); mState.stack.reset(); // Update navigator to give horizontal breadcrumb a chance to update documents. It // doesn't update its content if the size of document stack doesn't change. // TODO: update breadcrumb to take range update. mActivity.updateNavigator(); mState.setStack(stack); mState.stack.reset(stack); } // Show an opening animation only if pressing "back" would get us back to the // previous directory. Especially after opening a root document, pressing // back, wouldn't go to the previous root, but close the activity. final int anim = (mState.hasLocationChanged() && mState.stack.size() > 1) final int anim = (mState.stack.hasLocationChanged() && mState.stack.size() > 1) ? AnimationView.ANIM_ENTER : AnimationView.ANIM_NONE; mActivity.refreshCurrentRootAndDirectory(anim); } Loading @@ -226,11 +222,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> assert(currentDoc != null); mActivity.notifyDirectoryNavigated(currentDoc.derivedUri); mState.pushDocument(currentDoc); mState.stack.push(currentDoc); // Show an opening animation only if pressing "back" would get us back to the // previous directory. Especially after opening a root document, pressing // back, wouldn't go to the previous root, but close the activity. final int anim = (mState.hasLocationChanged() && mState.stack.size() > 1) final int anim = (mState.stack.hasLocationChanged() && mState.stack.size() > 1) ? AnimationView.ANIM_ENTER : AnimationView.ANIM_NONE; mActivity.refreshCurrentRootAndDirectory(anim); } Loading @@ -248,12 +244,10 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> protected final void loadDocument(Uri uri, LoadDocStackCallback callback) { new LoadDocStackTask( mActivity, uri, mRoots, mDocs, mProviders, callback ).executeOnExecutor(mExecutors.lookup(uri.getAuthority())); ).executeOnExecutor(mExecutors.lookup(uri.getAuthority()), uri); } @Override Loading
src/com/android/documentsui/BaseActivity.java +4 −3 Original line number Diff line number Diff line Loading @@ -335,7 +335,7 @@ public abstract class BaseActivity<T extends ActionHandler> root.isRecents() || root.isDownloads() ? View.VISIBLE : View.INVISIBLE); // Clear entire backstack and start in new root mState.onRootChanged(root); mState.stack.changeRoot(root); // Recents is always in memory, so we just load it directly. // Otherwise we delegate loading data from disk to a task Loading Loading @@ -564,8 +564,9 @@ public abstract class BaseActivity<T extends ActionHandler> @Override public RootInfo getCurrentRoot() { if (mState.stack.root != null) { return mState.stack.root; RootInfo root = mState.stack.getRoot(); if (root != null) { return root; } else { return mRoots.getRecentsRoot(); } Loading
src/com/android/documentsui/DocumentsAccess.java +26 −10 Original line number Diff line number Diff line Loading @@ -18,11 +18,13 @@ package com.android.documentsui; import android.annotation.Nullable; import android.content.ContentProviderClient; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.RemoteException; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Path; import android.util.Log; import com.android.documentsui.archives.ArchivesProvider; Loading @@ -34,7 +36,8 @@ import java.util.ArrayList; import java.util.List; /** * Provides synchronous access to {@link DocumentInfo} instances given some identifying information. * Provides synchronous access to {@link DocumentInfo} instances given some identifying information * and some documents API. */ public interface DocumentsAccess { Loading @@ -42,7 +45,10 @@ public interface DocumentsAccess { @Nullable DocumentInfo getDocument(Uri uri); @Nullable DocumentInfo getArchiveDocument(Uri uri); @Nullable List<DocumentInfo> getDocuments(String authority, List<String> docIds); boolean isDocumentUri(Uri uri); @Nullable Path findPath(Uri uri) throws RemoteException; List<DocumentInfo> getDocuments(String authority, List<String> docIds) throws RemoteException; public static DocumentsAccess create(Context context) { return new RuntimeDocumentAccess(context); Loading Loading @@ -76,7 +82,9 @@ public interface DocumentsAccess { } @Override public @Nullable List<DocumentInfo> getDocuments(String authority, List<String> docIds) { public List<DocumentInfo> getDocuments(String authority, List<String> docIds) throws RemoteException { try(final ContentProviderClient client = DocumentsApplication .acquireUnstableProviderOrThrow(mContext.getContentResolver(), authority)) { Loading @@ -86,20 +94,14 @@ public interface DocumentsAccess { try (final Cursor cursor = client.query(uri, null, null, null, null)) { if (!cursor.moveToNext()) { Log.e(TAG, "Couldn't create DocumentInfo for Uri: " + uri); return null; throw new RemoteException("Failed to move cursor."); } result.add(DocumentInfo.fromCursor(cursor, authority)); } catch (Exception e) { Log.e(TAG, "Couldn't create DocumentInfo for Uri: " + uri); return null; } } return result; } catch (RemoteException e) { Log.w(TAG, "Couldn't get a content provider client." ,e); return null; } } Loading @@ -107,5 +109,19 @@ public interface DocumentsAccess { public DocumentInfo getArchiveDocument(Uri uri) { return getDocument(ArchivesProvider.buildUriForArchive(uri)); } @Override public boolean isDocumentUri(Uri uri) { return DocumentsContract.isDocumentUri(mContext, uri); } @Override public Path findPath(Uri docUri) throws RemoteException { final ContentResolver resolver = mContext.getContentResolver(); try (final ContentProviderClient client = DocumentsApplication .acquireUnstableProviderOrThrow(resolver, docUri.getAuthority())) { return DocumentsContract.findPath(client, docUri); } } } }
src/com/android/documentsui/DocumentsApplication.java +0 −10 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.net.Uri; import android.os.RemoteException; import android.text.format.DateUtils; import com.android.documentsui.ProviderAccess.RuntimeProviderAccess; import com.android.documentsui.clipping.ClipStorage; import com.android.documentsui.clipping.ClipStore; import com.android.documentsui.clipping.DocumentClipper; Loading @@ -43,8 +42,6 @@ public class DocumentsApplication extends Application { private ClipStorage mClipStore; private DocumentClipper mClipper; private ProviderAccess mProviderAccess; public static RootsCache getRootsCache(Context context) { return ((DocumentsApplication) context.getApplicationContext()).mRoots; } Loading @@ -54,11 +51,6 @@ public class DocumentsApplication extends Application { return app.mThumbnailCache; } public static ProviderAccess getProviderAccess(Context context) { final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext(); return app.mProviderAccess; } public static ContentProviderClient acquireUnstableProviderOrThrow( ContentResolver resolver, String authority) throws RemoteException { final ContentProviderClient client = resolver.acquireUnstableContentProviderClient( Loading Loading @@ -95,8 +87,6 @@ public class DocumentsApplication extends Application { getSharedPreferences(ClipStorage.PREF_NAME, 0)); mClipper = new DocumentClipper(this, mClipStore); mProviderAccess = new RuntimeProviderAccess(getContentResolver()); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); Loading
src/com/android/documentsui/DropdownBreadcrumb.java +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public final class DropdownBreadcrumb extends Spinner implements Breadcrumb { @Override public DocumentInfo getItem(int position) { return mState.stack.get(mState.stack.size() - position - 1); return mState.stack.get(position); } @Override Loading