Search in sources :

Example 16 with RowBuilder

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

the class HeatMapProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, ROOT_ID_HEAT_MAP);
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED);
    row.add(Root.COLUMN_ICON, R.drawable.ic_root_usb);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_heat_map));
    row.add(Root.COLUMN_DOCUMENT_ID, ROOT_ID_HEAT_MAP);
    row.add(Root.COLUMN_AVAILABLE_BYTES, -1);
    row.add(Root.COLUMN_CAPACITY_BYTES, -1);
    return result;
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 17 with RowBuilder

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

the class NonMediaDocumentsProvider method includeFileRoot.

private void includeFileRoot(MatrixCursor result, String root_type, int name_id, String mime_types, boolean supports_recent) {
    int flags = Root.FLAG_LOCAL_ONLY;
    if (isEmpty(FILE_URI, root_type)) {
        flags |= Root.FLAG_EMPTY;
    }
    if (supports_recent) {
        flags |= Root.FLAG_SUPPORTS_RECENTS;
    }
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, root_type);
    row.add(Root.COLUMN_FLAGS, flags);
    row.add(Root.COLUMN_TITLE, getContext().getString(name_id));
    row.add(Root.COLUMN_DOCUMENT_ID, root_type);
    row.add(Root.COLUMN_MIME_TYPES, mime_types);
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) Point(android.graphics.Point)

Example 18 with RowBuilder

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

the class NonMediaDocumentsProvider method includeFile.

private void includeFile(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(FileQuery._ID);
    final String docId = getDocIdForIdent(TYPE_APK, id);
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(FileQuery.TITLE));
    row.add(Document.COLUMN_SIZE, cursor.getLong(FileQuery.SIZE));
    row.add(Document.COLUMN_MIME_TYPE, cursor.getString(FileQuery.MIME_TYPE));
    row.add(Document.COLUMN_PATH, cursor.getString(FileQuery.DATA));
    row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(FileQuery.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)

Example 19 with RowBuilder

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

the class RootedStorageProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    synchronized (mRootsLock) {
        for (RootInfo root : mRoots.values()) {
            final RowBuilder row = result.newRow();
            row.add(Root.COLUMN_ROOT_ID, root.rootId);
            row.add(Root.COLUMN_FLAGS, root.flags);
            row.add(Root.COLUMN_TITLE, root.title);
            row.add(Root.COLUMN_PATH, root.path);
            row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
        }
    }
    return result;
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 20 with RowBuilder

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

the class RootedStorageProvider method includeRootFile.

private void includeRootFile(MatrixCursor result, String docId, RootFile file) throws FileNotFoundException {
    if (docId == null) {
        if (!file.isValid()) {
            return;
        }
        docId = getDocIdForRootFile(file);
    } else {
        file = getRootFileForDocId(docId);
    }
    int flags = 0;
    if (!file.isValid()) {
        return;
    }
    if (file.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_EDIT;
        if (isTelevision()) {
            flags |= Document.FLAG_DIR_PREFERS_GRID;
        }
    }
    final String displayName = file.getName();
    final String mimeType = getTypeForFile(file);
    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);
    // Only publish dates reasonably after epoch
    long lastModified = file.getLastModified();
    if (lastModified > 31536000000L) {
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
    }
/*        if (file.isDirectory() && null != file.list()) {
            row.add(Document.COLUMN_SUMMARY, file.list().length + " files");
        }*/
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) Point(android.graphics.Point)

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