Search in sources :

Example 21 with RowBuilder

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

the class AppsProvider method includeAppFromPackage.

private void includeAppFromPackage(MatrixCursor result, String docId, PackageInfo packageInfo, boolean showSystem, String query) {
    ApplicationInfo appInfo = packageInfo.applicationInfo;
    if (showSystem == isSystemApp(appInfo)) {
        String displayName = "";
        final String packageName = packageInfo.packageName;
        String summary = packageName;
        displayName = packageName;
        if (null != query && !displayName.toLowerCase().contains(query)) {
            return;
        }
        final String path = appInfo.sourceDir;
        final String mimeType = Document.MIME_TYPE_APK;
        int flags = Document.FLAG_SUPPORTS_COPY | Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_THUMBNAIL;
        if (isTelevision()) {
            flags |= Document.FLAG_DIR_PREFERS_GRID;
        }
        final long size = new File(appInfo.sourceDir).length();
        final long lastModified = packageInfo.lastUpdateTime;
        final RowBuilder row = result.newRow();
        row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForApp(docId, packageName));
        row.add(Document.COLUMN_DISPLAY_NAME, getAppName(displayName) + getAppVersion(packageInfo.versionName));
        row.add(Document.COLUMN_SUMMARY, summary);
        row.add(Document.COLUMN_SIZE, size);
        row.add(Document.COLUMN_MIME_TYPE, mimeType);
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
        row.add(Document.COLUMN_PATH, path);
        row.add(Document.COLUMN_FLAGS, flags);
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) File(java.io.File) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 22 with RowBuilder

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

the class AppsProvider method includeAppFromProcess.

private void includeAppFromProcess(MatrixCursor result, String docId, RunningAppProcessInfo processInfo, String query) {
    if (processInfo.importance != RunningAppProcessInfo.IMPORTANCE_EMPTY && processInfo.importance != RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE) {
        String process = processInfo.processName;
        process = process.substring(process.lastIndexOf(".") + 1, process.length());
        String summary = "";
        String displayName = "";
        ApplicationInfo appInfo = null;
        try {
            appInfo = packageManager.getPackageInfo(processInfo.processName, PackageManager.GET_ACTIVITIES).applicationInfo;
            // (String) (appInfo.loadLabel(packageManager) != null ? appInfo.loadLabel(packageManager) : appInfo.packageName);
            displayName = process;
        } catch (Exception e) {
        }
        if (TextUtils.isEmpty(displayName)) {
            displayName = process;
        }
        if (null != query && !displayName.toLowerCase().contains(query)) {
            return;
        }
        final String path = null != appInfo ? appInfo.sourceDir : "";
        final String mimeType = Document.MIME_TYPE_APK;
        int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_THUMBNAIL;
        if (isTelevision()) {
            flags |= Document.FLAG_DIR_PREFERS_GRID;
        }
        summary = processTypeCache.get(processInfo.importance);
        final long size = getProcessSize(processInfo.pid);
        final String packageName = processInfo.processName;
        final RowBuilder row = result.newRow();
        row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForApp(docId, packageName));
        row.add(Document.COLUMN_DISPLAY_NAME, displayName);
        row.add(Document.COLUMN_SUMMARY, summary);
        row.add(Document.COLUMN_SIZE, size);
        row.add(Document.COLUMN_MIME_TYPE, mimeType);
        // row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
        row.add(Document.COLUMN_PATH, path);
        row.add(Document.COLUMN_FLAGS, flags);
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) FileNotFoundException(java.io.FileNotFoundException) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 23 with RowBuilder

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

the class DownloadStorageProvider 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_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_root_download);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
    row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
    return result;
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 24 with RowBuilder

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

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_PATH, root.path);
            if (ROOT_ID_PRIMARY_EMULATED.equals(root.rootId) || root.rootId.startsWith(ROOT_ID_SECONDARY) || root.rootId.startsWith(ROOT_ID_PHONE)) {
                final File file = root.rootId.startsWith(ROOT_ID_PHONE) ? Environment.getRootDirectory() : root.path;
                row.add(Root.COLUMN_AVAILABLE_BYTES, file.getFreeSpace());
                row.add(Root.COLUMN_CAPACITY_BYTES, file.getTotalSpace());
            }
        }
    }
    return result;
}
Also used : RowBuilder(dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder) FileUtils.getTypeForFile(dev.dworks.apps.anexplorer.misc.FileUtils.getTypeForFile) DocumentFile(android.support.provider.DocumentFile) File(java.io.File) MatrixCursor(dev.dworks.apps.anexplorer.cursor.MatrixCursor)

Example 25 with RowBuilder

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

the class MediaDocumentsProvider method includeVideosRootDocument.

private void includeVideosRootDocument(MatrixCursor result) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, TYPE_VIDEOS_ROOT);
    row.add(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_videos));
    row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID | Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_SUPPORTS_DELETE);
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
}
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