Added chooser w/o task

This commit is contained in:
M66B
2022-07-14 08:23:17 +02:00
parent 969d48dab3
commit 62b7d4cc75
4 changed files with 46 additions and 18 deletions

View File

@@ -915,33 +915,44 @@ public class Helper {
open_with_tabs = false;
}
if (open_with_pkg != null && !isInstalled(context, open_with_pkg)) {
open_with_pkg = null;
open_with_tabs = false;
if (!"chooser".equals(open_with_pkg)) {
if (open_with_pkg != null && !isInstalled(context, open_with_pkg)) {
open_with_pkg = null;
open_with_tabs = false;
}
if (open_with_tabs && !hasCustomTabs(context, uri, open_with_pkg))
open_with_tabs = false;
}
if (open_with_tabs && !hasCustomTabs(context, uri, open_with_pkg))
open_with_tabs = false;
Intent view = new Intent(Intent.ACTION_VIEW);
if (mimeType == null)
view.setData(uri);
else
view.setDataAndType(uri, mimeType);
if (task)
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if ("chooser".equals(open_with_pkg)) {
Intent view = new Intent(Intent.ACTION_VIEW, uri);
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
try {
EntityLog.log(context, "Launching chooser uri=" + uri);
context.startActivity(chooser);
if (open_with_tabs) {
EntityLog.log(context, "Launching direct uri=" + uri +
" intent=" + view +
" extras=" + TextUtils.join(", ", Log.getExtras(view.getExtras())));
context.startActivity(view);
} else {
EntityLog.log(context, "Launching chooser uri=" + uri +
" intent=" + view +
" extras=" + TextUtils.join(", ", Log.getExtras(view.getExtras())));
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
context.startActivity(chooser);
}
} catch (ActivityNotFoundException ex) {
Log.w(ex);
reportNoViewer(context, uri, ex);
}
} else if (browse || !open_with_tabs) {
try {
Intent view = new Intent(Intent.ACTION_VIEW);
if (mimeType == null)
view.setData(uri);
else
view.setDataAndType(uri, mimeType);
if (task)
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
view.setPackage(open_with_pkg);
EntityLog.log(context, "Launching view uri=" + uri +
" intent=" + view +