Search in sources :

Example 1 with MatrixCursor

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

the class AppsProvider method queryDocument.

@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeDefaultDocument(result, docId);
    return result;
}
Also used : MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 2 with MatrixCursor

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

the class AppsProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    StorageUtils storageUtils = new StorageUtils(getContext());
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, ROOT_ID_USER_APP);
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPER_ADVANCED | Root.FLAG_SUPPORTS_SEARCH);
    row.add(Root.COLUMN_ICON, R.drawable.ic_root_apps);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_apps));
    row.add(Root.COLUMN_DOCUMENT_ID, ROOT_ID_USER_APP);
    row.add(Root.COLUMN_AVAILABLE_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_DATA, false));
    row.add(Root.COLUMN_CAPACITY_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_DATA, true));
    final RowBuilder row1 = result.newRow();
    row1.add(Root.COLUMN_ROOT_ID, ROOT_ID_SYSTEM_APP);
    row1.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPER_ADVANCED | Root.FLAG_SUPPORTS_SEARCH);
    row1.add(Root.COLUMN_ICON, R.drawable.ic_root_apps);
    row1.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_system_apps));
    row1.add(Root.COLUMN_DOCUMENT_ID, ROOT_ID_SYSTEM_APP);
    row1.add(Root.COLUMN_AVAILABLE_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_DATA, false));
    row1.add(Root.COLUMN_CAPACITY_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_DATA, true));
    final RowBuilder row2 = result.newRow();
    row2.add(Root.COLUMN_ROOT_ID, ROOT_ID_PROCESS);
    row2.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED | Root.FLAG_SUPER_ADVANCED | Root.FLAG_SUPPORTS_SEARCH);
    row2.add(Root.COLUMN_ICON, R.drawable.ic_root_process);
    row2.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_processes));
    row2.add(Root.COLUMN_DOCUMENT_ID, ROOT_ID_PROCESS);
    row2.add(Root.COLUMN_AVAILABLE_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_RAM, false));
    row2.add(Root.COLUMN_CAPACITY_BYTES, storageUtils.getPartionSize(StorageUtils.PARTITION_RAM, true));
    return result;
}
Also used : StorageUtils(dev.dworks.apps.anexplorer.misc.StorageUtils) RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 3 with MatrixCursor

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

the class DownloadStorageProvider method queryRecentDocuments.

@Override
public Cursor queryRecentDocuments(String rootId, String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        cursor = mDm.query(// .setOnlyIncludeVisibleInDownloadsUi(true)
        new DownloadManager.Query().setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
        // copyNotificationUri(result, cursor);
        while (cursor.moveToNext() && result.getCount() < 12) {
            final String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE));
            final String uri = cursor.getString(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIAPROVIDER_URI));
            // don't duplicate them in the recents list.
            if (mimeType == null || (mimeType.startsWith("image/") && !TextUtils.isEmpty(uri))) {
                continue;
            }
            includeDownloadFromCursor(result, cursor);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
Also used : MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor) Cursor(android.database.Cursor) DownloadManager(android.app.DownloadManager) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor) Query(android.app.DownloadManager.Query)

Example 4 with MatrixCursor

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

the class DownloadStorageProvider method queryDocument.

@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    if (DOC_ID_ROOT.equals(docId)) {
        includeDefaultDocument(result);
    } else {
        // Delegate to real provider
        final long token = Binder.clearCallingIdentity();
        Cursor cursor = null;
        try {
            cursor = mDm.query(new Query().setFilterById(Long.parseLong(docId)));
            // copyNotificationUri(result, cursor);
            if (cursor.moveToFirst()) {
                includeDownloadFromCursor(result, cursor);
            }
        } finally {
            IoUtils.closeQuietly(cursor);
            Binder.restoreCallingIdentity(token);
        }
    }
    return result;
}
Also used : Query(android.app.DownloadManager.Query) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor) Cursor(android.database.Cursor) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 5 with MatrixCursor

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

the class ExternalStorageProvider method queryDocument.

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
    if (mArchiveHelper.isArchivedDocument(documentId)) {
        return mArchiveHelper.queryDocument(documentId, projection);
    }
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    updateSettings();
    includeFile(result, documentId, null);
    return result;
}
Also used : MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Aggregations

MatrixCursor (dev.dworks.apps.anexplorer.cursor.MatrixCursor)37 Cursor (android.database.Cursor)10 RowBuilder (dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder)7 ContentResolver (android.content.ContentResolver)6 File (java.io.File)6 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)5 Query (android.app.DownloadManager.Query)4 DocumentFile (android.support.provider.DocumentFile)3 UsbFile (com.github.mjdev.libaums.fs.UsbFile)3 FileUtils.getTypeForFile (dev.dworks.apps.anexplorer.misc.FileUtils.getTypeForFile)3 ArrayMap (android.support.v4.util.ArrayMap)2 NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)2 RootFile (dev.dworks.apps.anexplorer.root.RootFile)2 BufferedReader (java.io.BufferedReader)2 Scanner (java.util.Scanner)2 ZipEntry (java.util.zip.ZipEntry)2 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)1 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)1 DownloadManager (android.app.DownloadManager)1