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

Commit e2cd3cca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Relay extras from sorted cursor." into nyc-andromeda-dev

parents 8ee04b32 b324dfd8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.documentsui.base.DocumentInfo.getCursorString;

import android.database.AbstractCursor;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.DocumentsContract.Document;

import com.android.documentsui.base.Shared;
@@ -156,6 +157,11 @@ class SortingCursorWrapper extends AbstractCursor {
        return mCursor.isNull(column);
    }

    @Override
    public Bundle getExtras() {
        return mCursor.getExtras();
    }

    /**
     * @return Timestamp for the given document. Some docs (e.g. active downloads) have a null
     * timestamp - these will be replaced with MAX_LONG so that such files get sorted to the top
+1 −1
Original line number Diff line number Diff line
@@ -766,7 +766,7 @@ public class StubProvider extends DocumentsProvider {
            this.file = file;
            this.documentId = getDocumentIdForFile(file);
            this.mimeType = Document.MIME_TYPE_DIR;
            this.streamTypes = new ArrayList<String>();
            this.streamTypes = new ArrayList<>();
            this.flags = Document.FLAG_DIR_SUPPORTS_CREATE | Document.FLAG_SUPPORTS_RENAME;
            this.parentId = null;
            this.rootInfo = rootInfo;
+23 −1
Original line number Diff line number Diff line
@@ -17,13 +17,14 @@
package com.android.documentsui.sorting;

import static com.android.documentsui.base.DocumentInfo.getCursorString;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import android.database.Cursor;
import android.database.MatrixCursor;
import android.os.Bundle;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.support.test.runner.AndroidJUnit4;

@@ -366,6 +367,27 @@ public class SortingCursorWrapperTest {
        }
    }

    @Test
    public void testReturnsWrappedExtras() {
        MatrixCursor c = new MatrixCursor(COLUMNS);
        Bundle extras = new Bundle();
        extras.putBoolean(DocumentsContract.EXTRA_LOADING, true);
        extras.putString(DocumentsContract.EXTRA_INFO, "cheddar");
        extras.putString(DocumentsContract.EXTRA_ERROR, "flop");
        c.setExtras(extras);

        // set sorting to avoid an NPE.
        sortModel.sortByUser(
                SortModel.SORT_DIMENSION_ID_DATE,
                SortDimension.SORT_DIRECTION_DESCENDING);

        Bundle actual = createSortingCursorWrapper(c).getExtras();

        assertTrue(actual.getBoolean(DocumentsContract.EXTRA_LOADING, false));
        assertEquals("cheddar", actual.getString(DocumentsContract.EXTRA_INFO));
        assertEquals("flop", actual.getString(DocumentsContract.EXTRA_ERROR));
    }

    private Cursor createSortingCursorWrapper() {
        return createSortingCursorWrapper(cursor);
    }