Search in sources :

Example 11 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by ResurrectionRemix.

the class BugreportStorageProvider 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, DOC_ID_ROOT);
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED);
    row.add(Root.COLUMN_ICON, android.R.mipmap.sym_def_app_icon);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.bugreport_storage_title));
    row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) MatrixCursor(android.database.MatrixCursor)

Example 12 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by ResurrectionRemix.

the class BugreportStorageProvider method addFileRow.

private void addFileRow(MatrixCursor result, File file) {
    String mimeType = getTypeForName(file.getName());
    int flags = Document.FLAG_SUPPORTS_DELETE;
    if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
        flags |= Document.FLAG_ARCHIVE;
    }
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForFile(file));
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    row.add(Document.COLUMN_FLAGS, flags);
    row.add(Document.COLUMN_SIZE, file.length());
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Example 13 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by ResurrectionRemix.

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);
    }
    int flags = 0;
    if (file.canWrite()) {
        if (file.isDirectory()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
            flags |= Document.FLAG_SUPPORTS_DELETE;
            flags |= Document.FLAG_SUPPORTS_RENAME;
            flags |= Document.FLAG_SUPPORTS_MOVE;
        } else {
            flags |= Document.FLAG_SUPPORTS_WRITE;
            flags |= Document.FLAG_SUPPORTS_DELETE;
            flags |= Document.FLAG_SUPPORTS_RENAME;
            flags |= Document.FLAG_SUPPORTS_MOVE;
        }
    }
    final String mimeType = getTypeForFile(file);
    if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
        flags |= Document.FLAG_ARCHIVE;
    }
    final String displayName = file.getName();
    if (mimeType.startsWith("image/")) {
        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_FLAGS, flags);
    row.add(DocumentArchiveHelper.COLUMN_LOCAL_FILE_PATH, file.getPath());
    // Only publish dates reasonably after epoch
    long lastModified = file.lastModified();
    if (lastModified > 31536000000L) {
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
    }
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) Point(android.graphics.Point)

Example 14 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by ResurrectionRemix.

the class ExternalStorageProvider 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_DOCUMENT_ID, root.docId);
            row.add(Root.COLUMN_AVAILABLE_BYTES, root.reportAvailableBytes ? root.path.getFreeSpace() : -1);
        }
    }
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) MatrixCursor(android.database.MatrixCursor)

Example 15 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

the class StubProvider method includeDocument.

private void includeDocument(MatrixCursor result, StubDocument document) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, document.documentId);
    row.add(Document.COLUMN_DISPLAY_NAME, document.file.getName());
    row.add(Document.COLUMN_SIZE, document.file.length());
    row.add(Document.COLUMN_MIME_TYPE, document.mimeType);
    row.add(Document.COLUMN_FLAGS, document.flags);
    row.add(Document.COLUMN_LAST_MODIFIED, document.file.lastModified());
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Aggregations

RowBuilder (android.database.MatrixCursor.RowBuilder)60 MatrixCursor (android.database.MatrixCursor)30 ContentValues (android.content.ContentValues)5 Cursor (android.database.Cursor)5 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)5 Point (android.graphics.Point)5 Uri (android.net.Uri)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5