Loading src/com/android/documentsui/AbstractActionHandler.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -155,6 +155,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> throw new UnsupportedOperationException("Delete not supported!"); throw new UnsupportedOperationException("Delete not supported!"); } } @Override public void shareSelectedDocuments() { throw new UnsupportedOperationException("Share not supported!"); } @Override @Override public final void loadDocument(Uri uri) { public final void loadDocument(Uri uri) { new OpenUriForViewTask<>(mActivity, mState, mRoots, mDocs, uri) new OpenUriForViewTask<>(mActivity, mState, mRoots, mDocs, uri) Loading src/com/android/documentsui/ActionHandler.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -67,6 +67,8 @@ public interface ActionHandler { void deleteSelectedDocuments(); void deleteSelectedDocuments(); void shareSelectedDocuments(); /** /** * Called when initial activity setup is complete. Implementations * Called when initial activity setup is complete. Implementations * should override this method to set the initial location of the * should override this method to set the initial location of the Loading src/com/android/documentsui/base/FilteringCursorWrapper.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -55,13 +55,13 @@ public class FilteringCursorWrapper extends AbstractCursor { while (cursor.moveToNext() && mCount < count) { while (cursor.moveToNext() && mCount < count) { final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED); final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED); if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) { if (rejectMimes != null && MimeTypes.mimeMatches(rejectMimes, mimeType)) { continue; continue; } } if (lastModified < rejectBefore) { if (lastModified < rejectBefore) { continue; continue; } } if (MimePredicate.mimeMatches(acceptMimes, mimeType)) { if (MimeTypes.mimeMatches(acceptMimes, mimeType)) { mPosition[mCount++] = cursor.getPosition(); mPosition[mCount++] = cursor.getPosition(); } } } } Loading src/com/android/documentsui/base/MimePredicate.java→src/com/android/documentsui/base/MimeTypes.java +25 −16 Original line number Original line 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"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ package com.android.documentsui.base; package com.android.documentsui.base; import android.annotation.Nullable; import android.annotation.Nullable; import android.provider.DocumentsContract.Document; 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 MimeTypes() {} private final String[] mFilters; private static final String APK_TYPE = "application/vnd.android.package-archive"; private static final String APK_TYPE = "application/vnd.android.package-archive"; /** /** Loading @@ -31,19 +31,28 @@ public class MimePredicate implements Predicate<DocumentInfo> { */ */ public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" }; public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" }; public MimePredicate(String[] filters) { public static String findCommonMimeType(List<String> mimeTypes) { mFilters = filters; String[] commonType = mimeTypes.get(0).split("/"); if (commonType.length != 2) { return "*/*"; } } @Override for (int i = 1; i < mimeTypes.size(); i++) { public boolean apply(DocumentInfo doc) { String[] type = mimeTypes.get(i).split("/"); if (doc.isDirectory()) { if (type.length != 2) continue; return true; 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) { public static boolean mimeMatches(String[] filters, String[] tests) { Loading src/com/android/documentsui/dirlist/DirectoryFragment.java +228 −278 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/com/android/documentsui/AbstractActionHandler.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -155,6 +155,11 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> throw new UnsupportedOperationException("Delete not supported!"); throw new UnsupportedOperationException("Delete not supported!"); } } @Override public void shareSelectedDocuments() { throw new UnsupportedOperationException("Share not supported!"); } @Override @Override public final void loadDocument(Uri uri) { public final void loadDocument(Uri uri) { new OpenUriForViewTask<>(mActivity, mState, mRoots, mDocs, uri) new OpenUriForViewTask<>(mActivity, mState, mRoots, mDocs, uri) Loading
src/com/android/documentsui/ActionHandler.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -67,6 +67,8 @@ public interface ActionHandler { void deleteSelectedDocuments(); void deleteSelectedDocuments(); void shareSelectedDocuments(); /** /** * Called when initial activity setup is complete. Implementations * Called when initial activity setup is complete. Implementations * should override this method to set the initial location of the * should override this method to set the initial location of the Loading
src/com/android/documentsui/base/FilteringCursorWrapper.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -55,13 +55,13 @@ public class FilteringCursorWrapper extends AbstractCursor { while (cursor.moveToNext() && mCount < count) { while (cursor.moveToNext() && mCount < count) { final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED); final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED); if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) { if (rejectMimes != null && MimeTypes.mimeMatches(rejectMimes, mimeType)) { continue; continue; } } if (lastModified < rejectBefore) { if (lastModified < rejectBefore) { continue; continue; } } if (MimePredicate.mimeMatches(acceptMimes, mimeType)) { if (MimeTypes.mimeMatches(acceptMimes, mimeType)) { mPosition[mCount++] = cursor.getPosition(); mPosition[mCount++] = cursor.getPosition(); } } } } Loading
src/com/android/documentsui/base/MimePredicate.java→src/com/android/documentsui/base/MimeTypes.java +25 −16 Original line number Original line 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"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ package com.android.documentsui.base; package com.android.documentsui.base; import android.annotation.Nullable; import android.annotation.Nullable; import android.provider.DocumentsContract.Document; 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 MimeTypes() {} private final String[] mFilters; private static final String APK_TYPE = "application/vnd.android.package-archive"; private static final String APK_TYPE = "application/vnd.android.package-archive"; /** /** Loading @@ -31,19 +31,28 @@ public class MimePredicate implements Predicate<DocumentInfo> { */ */ public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" }; public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" }; public MimePredicate(String[] filters) { public static String findCommonMimeType(List<String> mimeTypes) { mFilters = filters; String[] commonType = mimeTypes.get(0).split("/"); if (commonType.length != 2) { return "*/*"; } } @Override for (int i = 1; i < mimeTypes.size(); i++) { public boolean apply(DocumentInfo doc) { String[] type = mimeTypes.get(i).split("/"); if (doc.isDirectory()) { if (type.length != 2) continue; return true; 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) { public static boolean mimeMatches(String[] filters, String[] tests) { Loading
src/com/android/documentsui/dirlist/DirectoryFragment.java +228 −278 File changed.Preview size limit exceeded, changes collapsed. Show changes