Search in sources :

Example 6 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class DownloadStorageProvider method includeDefaultDocument.

/*    @Override
    public AssetFileDescriptor openDocumentThumbnail(
            String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
        // TODO: extend ExifInterface to support fds
        final ParcelFileDescriptor pfd = openDocument(docId, "r", signal);
        return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
    }*/
private void includeDefaultDocument(MatrixCursor result) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_DIR_SUPPORTS_CREATE);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 7 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class ExternalStorageProvider method includeFile.

private void includeFile(MatrixCursor result, String docId, File file) throws FileNotFoundException {
    if (docId == null) {
        docId = getDocIdForFile(file);
    } else {
        file = getFileForDocId(docId);
    }
    DocumentFile documentFile = getDocumentFile(docId, file);
    int flags = 0;
    if (documentFile.canWrite()) {
        if (file.isDirectory()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
        } else {
            flags |= Document.FLAG_SUPPORTS_WRITE;
        }
        flags |= Document.FLAG_SUPPORTS_DELETE;
        flags |= Document.FLAG_SUPPORTS_RENAME;
        flags |= Document.FLAG_SUPPORTS_MOVE;
        flags |= Document.FLAG_SUPPORTS_COPY;
        flags |= Document.FLAG_SUPPORTS_ARCHIVE;
        flags |= Document.FLAG_SUPPORTS_BOOKMARK;
        flags |= Document.FLAG_SUPPORTS_EDIT;
        if (isTelevision()) {
            flags |= Document.FLAG_DIR_PREFERS_GRID;
        }
    }
    final String mimeType = getTypeForFile(file);
    if (DocumentArchiveHelper.isSupportedArchiveType(mimeType)) {
        flags |= Document.FLAG_ARCHIVE;
    }
    final String displayName = file.getName();
    if (!showFilesHidden && !TextUtils.isEmpty(displayName)) {
        if (displayName.charAt(0) == '.') {
            return;
        }
    }
    if (MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType)) {
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    }
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, displayName);
    row.add(Document.COLUMN_SIZE, file.length());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_PATH, file.getAbsolutePath());
    row.add(Document.COLUMN_FLAGS, flags);
    if (file.isDirectory() && null != file.list()) {
        row.add(Document.COLUMN_SUMMARY, FileUtils.formatFileCount(file.list().length));
    }
    // Only publish dates reasonably after epoch
    long lastModified = file.lastModified();
    if (lastModified > 31536000000L) {
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
    }
}
Also used : DocumentFile(android.support.provider.DocumentFile) DocumentInfo.getCursorString(dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString) RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 8 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeAlbum.

private void includeAlbum(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(AlbumQuery._ID);
    final String docId = getDocIdForIdent(TYPE_ALBUM, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cleanUpMediaDisplayName(cursor.getString(AlbumQuery.ALBUM)));
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID | Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_SUPPORTS_DELETE);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 9 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeArtist.

private void includeArtist(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(ArtistQuery._ID);
    final String docId = getDocIdForIdent(TYPE_ARTIST, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cleanUpMediaDisplayName(cursor.getString(ArtistQuery.ARTIST)));
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Example 10 with RowBuilder

use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.

the class MediaDocumentsProvider method includeAudio.

private void includeAudio(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(SongQuery._ID);
    final String docId = getDocIdForIdent(TYPE_AUDIO, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(SongQuery.TITLE));
    row.add(Document.COLUMN_SIZE, cursor.getLong(SongQuery.SIZE));
    row.add(Document.COLUMN_MIME_TYPE, cursor.getString(SongQuery.MIME_TYPE));
    row.add(Document.COLUMN_PATH, cursor.getString(SongQuery.DATA));
    row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(SongQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_SUPPORTS_DELETE);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)

Aggregations

RowBuilder (dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)34 Point (android.graphics.Point)11 SuppressLint (android.annotation.SuppressLint)7 MatrixCursor (dev.dworks.apps.anexplorer.cursor.MatrixCursor)7 ApplicationInfo (android.content.pm.ApplicationInfo)4 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 DocumentFile (android.support.provider.DocumentFile)2 ArrayMap (android.support.v4.util.ArrayMap)1 FileUtils.getTypeForFile (dev.dworks.apps.anexplorer.misc.FileUtils.getTypeForFile)1 StorageUtils (dev.dworks.apps.anexplorer.misc.StorageUtils)1 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)1 NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)1 Map (java.util.Map)1