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

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

Merge "Move share impl into files ActionHandler." into nyc-andromeda-dev

parents cd1d4b66 d071895e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -155,6 +155,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
        throw new UnsupportedOperationException("Delete not supported!");
    }

    @Override
    public void shareSelectedDocuments() {
        throw new UnsupportedOperationException("Share not supported!");
    }

    @Override
    public final void loadDocument(Uri uri) {
        new OpenUriForViewTask<>(mActivity, mState, mRoots, mDocs, uri)
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ public interface ActionHandler {

    void deleteSelectedDocuments();

    void shareSelectedDocuments();

    /**
     * Called when initial activity setup is complete. Implementations
     * should override this method to set the initial location of the
+2 −2
Original line number Diff line number Diff line
@@ -55,13 +55,13 @@ public class FilteringCursorWrapper extends AbstractCursor {
        while (cursor.moveToNext() && mCount < count) {
            final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
            final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
            if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
            if (rejectMimes != null && MimeTypes.mimeMatches(rejectMimes, mimeType)) {
                continue;
            }
            if (lastModified < rejectBefore) {
                continue;
            }
            if (MimePredicate.mimeMatches(acceptMimes, mimeType)) {
            if (MimeTypes.mimeMatches(acceptMimes, mimeType)) {
                mPosition[mCount++] = cursor.getPosition();
            }
        }
+25 −16
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source Project
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -13,16 +13,16 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui.base;

import android.annotation.Nullable;
import android.provider.DocumentsContract.Document;

import com.android.internal.util.Predicate;
import java.util.List;

public final class MimeTypes {

public class MimePredicate implements Predicate<DocumentInfo> {
    private final String[] mFilters;
    private MimeTypes() {}

    private static final String APK_TYPE = "application/vnd.android.package-archive";
    /**
@@ -31,19 +31,28 @@ public class MimePredicate implements Predicate<DocumentInfo> {
     */
    public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" };

    public MimePredicate(String[] filters) {
        mFilters = filters;
    public static String findCommonMimeType(List<String> mimeTypes) {
        String[] commonType = mimeTypes.get(0).split("/");
        if (commonType.length != 2) {
            return "*/*";
        }

    @Override
    public boolean apply(DocumentInfo doc) {
        if (doc.isDirectory()) {
            return true;
        for (int i = 1; i < mimeTypes.size(); i++) {
            String[] type = mimeTypes.get(i).split("/");
            if (type.length != 2) continue;

            if (!commonType[1].equals(type[1])) {
                commonType[1] = "*";
            }
        if (mimeMatches(mFilters, doc.mimeType)) {
            return true;

            if (!commonType[0].equals(type[0])) {
                commonType[0] = "*";
                commonType[1] = "*";
                break;
            }
        return false;
        }

        return commonType[0] + "/" + commonType[1];
    }

    public static boolean mimeMatches(String[] filters, String[] tests) {
Loading