use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onUncompressDocuments.
public boolean onUncompressDocuments(ArrayList<DocumentInfo> docs) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
boolean hadTrouble = false;
for (DocumentInfo doc : docs) {
if (!doc.isArchiveSupported()) {
Log.w(TAG, "Skipping " + doc);
hadTrouble = true;
continue;
}
try {
hadTrouble = !DocumentsContract.uncompressDocument(resolver, doc.derivedUri);
} catch (Exception e) {
Log.w(TAG, "Failed to Uncompress " + doc);
CrashReportingManager.logException(e);
hadTrouble = true;
}
}
return hadTrouble;
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onShareDocuments.
private void onShareDocuments(ArrayList<DocumentInfo> docs) {
Intent intent;
if (docs.size() == 1) {
final DocumentInfo doc = docs.get(0);
intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
if (!MimePredicate.mimeMatches(MimePredicate.SHARE_SKIP_MIMES, doc.mimeType)) {
intent.setType(doc.mimeType);
} else {
intent.setType(MimeTypes.ALL_MIME_TYPES);
}
intent.putExtra(Intent.EXTRA_STREAM, doc.derivedUri);
Bundle params = new Bundle();
String type = IconUtils.getTypeNameFromMimeType(doc.mimeType);
params.putString(FILE_TYPE, type);
params.putInt(FILE_COUNT, docs.size());
AnalyticsManager.logEvent("share" + "_" + type, params);
} else if (docs.size() > 1) {
intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
final ArrayList<String> mimeTypes = new ArrayList<>();
final ArrayList<Uri> uris = new ArrayList<>();
for (DocumentInfo doc : docs) {
mimeTypes.add(doc.mimeType);
uris.add(doc.derivedUri);
}
String mimeType = findCommonMimeType(mimeTypes);
if (!MimePredicate.mimeMatches(MimePredicate.SHARE_SKIP_MIMES, mimeType)) {
intent.setType(mimeType);
} else {
intent.setType(MimeTypes.ALL_MIME_TYPES);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
Bundle params = new Bundle();
params.putInt(FILE_COUNT, docs.size());
AnalyticsManager.logEvent("share", params);
} else {
return;
}
intent = Intent.createChooser(intent, getActivity().getText(R.string.share_via));
if (Utils.isIntentAvailable(getActivity(), intent)) {
startActivity(intent);
}
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method forceStopApps.
private void forceStopApps(ArrayList<DocumentInfo> docs) {
ArrayList<String> packageList = new ArrayList<>();
for (DocumentInfo documentInfo : docs) {
packageList.add(AppsProvider.getPackageForDocId(documentInfo.documentId));
}
Intent intent = new Intent(ACTION_FORCE_STOP_REQUEST);
intent.putExtra(EXTRA_PACKAGE_NAMES, packageList);
getActivity().sendBroadcast(intent);
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class CreateFileFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
Utils.tintWidget(text1);
String title = getArguments().getString(EXTRA_DISPLAY_NAME);
if (!TextUtils.isEmpty(title)) {
text1.setText(title);
text1.setSelection(title.length());
}
builder.setTitle(R.string.menu_create_file);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String displayName = text1.getText().toString();
final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
String extension = FileUtils.getExtFromFilename(displayName);
final DocumentsActivity activity = (DocumentsActivity) getActivity();
final DocumentInfo cwd = activity.getCurrentDirectory();
new CreateFileTask(activity, cwd, TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(ProviderExecutor.forAuthority(cwd.authority));
}
});
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class FileUtils method updateMediaStore.
public static void updateMediaStore(Context context, ArrayList<DocumentInfo> docs, String parentPath) {
try {
if (Utils.hasKitKat()) {
ArrayList<String> paths = new ArrayList<>();
for (DocumentInfo doc : docs) {
paths.add(parentPath + File.separator + doc.displayName);
}
String[] pathsArray = paths.toArray(new String[paths.size()]);
FileUtils.updateMediaStore(context, pathsArray);
} else {
Uri contentUri = Uri.fromFile(new File(parentPath).getParentFile());
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, contentUri);
context.sendBroadcast(mediaScanIntent);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations