use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.
the class AppsProvider method includeAppFromService.
private void includeAppFromService(MatrixCursor result, String docId, RunningServiceInfo processInfo, String query) {
String process = processInfo.process;
final String packageName = processInfo.process;
process = process.substring(process.lastIndexOf(".") + 1, process.length());
String summary = "";
String displayName = "";
ApplicationInfo appInfo = null;
try {
appInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES).applicationInfo;
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;
}
int importance = processInfo.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
summary = processTypeCache.get(importance);
final long size = getProcessSize(processInfo.pid);
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, processInfo.lastActivityTime);
row.add(Document.COLUMN_PATH, path);
row.add(Document.COLUMN_FLAGS, flags);
}
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, AndroidAppProcess processInfo, String query) {
String process = processInfo.name;
final String packageName = processInfo.getPackageName();
process = process.substring(process.lastIndexOf(".") + 1, process.length());
String summary = "";
String displayName = "";
ApplicationInfo appInfo = null;
try {
appInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES).applicationInfo;
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;
}
int importance = processInfo.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
summary = processTypeCache.get(importance);
final long size = getProcessSize(processInfo.pid);
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);
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder 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;
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.
the class AppsProvider method includeDefaultDocument.
private void includeDefaultDocument(MatrixCursor result, String docId) {
final RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, docId);
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_SUPPORTS_DELETE);
}
use of dev.dworks.apps.anexplorer.cursor.MatrixCursor.RowBuilder in project AnExplorer by 1hakr.
the class DownloadStorageProvider method includeDownloadFromCursor.
@SuppressLint("InlinedApi")
private void includeDownloadFromCursor(MatrixCursor result, Cursor cursor) {
final long id = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID));
final String docId = String.valueOf(id);
final String displayName = cursor.getString(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TITLE));
String summary = cursor.getString(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_DESCRIPTION));
String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE));
if (mimeType == null) {
// Provide fake MIME type so it's openable
mimeType = "vnd.android.document/file";
}
Long size = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES));
if (size == -1) {
size = null;
}
final int status = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS));
switch(status) {
case DownloadManager.STATUS_SUCCESSFUL:
break;
case DownloadManager.STATUS_PAUSED:
summary = getContext().getString(R.string.download_queued);
break;
case DownloadManager.STATUS_PENDING:
summary = getContext().getString(R.string.download_queued);
break;
case DownloadManager.STATUS_RUNNING:
final long progress = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
if (size != null) {
final long percent = progress * 100 / size;
summary = getContext().getString(R.string.download_running_percent, percent);
} else {
summary = getContext().getString(R.string.download_running);
}
break;
case DownloadManager.STATUS_FAILED:
default:
summary = getContext().getString(R.string.download_error);
break;
}
int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE;
if (mimeType != null && mimeType.startsWith("image/")) {
flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
}
final long lastModified = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP));
final RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, docId);
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_FLAGS, flags);
}
Aggregations