Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8a5e081 authored by Ben Kwa's avatar Ben Kwa
Browse files

Re-enable sorting in the DirectoryFragment.

- Move sorting from the back-end (using SortingCursorWrapper) to the the
  front-end (in DocumentsAdapter).  This makes it such that re-sorting
  the directory contents doesn't necessitate a reload.
- Update DirectoryLoaders to just return unsorted results, and rely on
  the UI to sort them.
- Remove the (now-unused) SortingCursorWrapper.
- Update Model tests to test sorting.

BUG=26024369

Change-Id: I871cc0e496267d381ae546e0309125d04649415a
parent da858bfc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public abstract class BaseActivity extends Activity {
    private int mLayoutId;
    private DirectoryContainerView mDirectoryContainer;

    public abstract void onDocumentPicked(DocumentInfo doc, @Nullable DocumentContext siblings);
    public abstract void onDocumentPicked(DocumentInfo doc, @Nullable SiblingProvider siblings);
    public abstract void onDocumentsPicked(List<DocumentInfo> docs);

    abstract void onTaskFinished(Uri... uris);
@@ -826,7 +826,7 @@ public abstract class BaseActivity extends Activity {
     * Interface providing access to current view of documents
     * even when all documents are not homed to the same parent.
     */
    public interface DocumentContext {
    public interface SiblingProvider {
        /**
         * Returns the cursor for the selected document. The cursor can be used to retrieve
         * details about a document and its siblings.
+0 −3
Original line number Diff line number Diff line
@@ -156,9 +156,6 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
            if (mType == DirectoryFragment.TYPE_SEARCH) {
                // Filter directories out of search results, for now
                cursor = new FilteringCursorWrapper(cursor, null, SEARCH_REJECT_MIMES);
            } else {
                // Normal directories should have sorting applied
                cursor = new SortingCursorWrapper(cursor, result.sortOrder);
            }

            result.client = client;
+2 −3
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.documentsui;
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_PICK_COPY_DESTINATION;
import static com.android.documentsui.State.ACTION_OPEN_TREE;
import static com.android.documentsui.State.ACTION_PICK_COPY_DESTINATION;
import static com.android.documentsui.dirlist.DirectoryFragment.ANIM_NONE;

import android.app.Activity;
@@ -31,7 +31,6 @@ import android.content.ComponentName;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -419,7 +418,7 @@ public class DocumentsActivity extends BaseActivity {
    }

    @Override
    public void onDocumentPicked(DocumentInfo doc, DocumentContext context) {
    public void onDocumentPicked(DocumentInfo doc, SiblingProvider siblings) {
        final FragmentManager fm = getFragmentManager();
        if (doc.isContainer()) {
            openContainerDocument(doc);
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ public class DownloadsActivity extends BaseActivity {
    }

    @Override
    public void onDocumentPicked(DocumentInfo doc, DocumentContext context) {
    public void onDocumentPicked(DocumentInfo doc, SiblingProvider siblings) {
        final FragmentManager fm = getFragmentManager();
        if (doc.isContainer()) {
            openContainerDocument(doc);
+2 −2
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ public class FilesActivity extends BaseActivity {
    }

    @Override
    public void onDocumentPicked(DocumentInfo doc, @Nullable DocumentContext siblings) {
    public void onDocumentPicked(DocumentInfo doc, @Nullable SiblingProvider siblings) {
        if (doc.isContainer()) {
            openContainerDocument(doc);
        } else {
@@ -334,7 +334,7 @@ public class FilesActivity extends BaseActivity {
    /**
     * Launches an intent to view the specified document.
     */
    private void openDocument(DocumentInfo doc, @Nullable DocumentContext siblings) {
    private void openDocument(DocumentInfo doc, @Nullable SiblingProvider siblings) {
        Intent intent = null;
        if (siblings != null) {
            QuickViewIntentBuilder builder = new QuickViewIntentBuilder(
Loading