1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 17:27:00 +00:00

Persist sanitized state open link

This commit is contained in:
M66B 2023-03-30 08:29:23 +02:00
parent 6b31b76479
commit 5674fec271
2 changed files with 17 additions and 8 deletions

View file

@ -6111,7 +6111,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false;
boolean confirm_links = prefs.getBoolean("confirm_links", true);
Uri guri = UriHelper.guessScheme(uri);
String chost = FragmentDialogOpenLink.getConfirmHost(uri);
boolean sanitize_links = prefs.getBoolean("sanitize_links", false);
@ -6126,6 +6125,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
fragment.setArguments(args);
fragment.show(parentFragment.getParentFragmentManager(), "open:link");
} else {
boolean sanitize = prefs.getBoolean(chost + ".sanitize", false);
if (sanitize && UriHelper.isHyperLink(uri)) {
Uri sanitized = UriHelper.sanitize(uri);
if (sanitized != null)
uri = sanitized;
Log.i("Open sanitized=" + uri);
}
boolean tabs = prefs.getBoolean("open_with_tabs", true);
Helper.view(context, UriHelper.guessScheme(uri), !tabs, !tabs);
}

View file

@ -753,11 +753,14 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse(etLink.getText().toString());
if (UriHelper.isHyperLink(uri))
prefs.edit().putBoolean(chost + ".sanitize", cbNotAgain.isChecked()).apply();
Uri theUri = Uri.parse(etLink.getText().toString());
Package pkg = (Package) spOpenWith.getSelectedItem();
Log.i("Open link uri=" + uri + " with=" + pkg);
Log.i("Open link uri=" + theUri + " with=" + pkg);
boolean tabs = (pkg != null && pkg.tabs);
Helper.view(context, uri, !tabs, !tabs);
Helper.view(context, theUri, !tabs, !tabs);
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@ -770,15 +773,15 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
@Override
public void onClick(DialogInterface dialog, int which) {
// https://developer.android.com/training/basics/intents/sending#AppChooser
Uri uri = Uri.parse(etLink.getText().toString());
Log.i("Open link with uri=" + uri);
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(uri));
Uri theUri = Uri.parse(etLink.getText().toString());
Log.i("Open link with uri=" + theUri);
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(theUri));
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
try {
startActivity(chooser);
} catch (ActivityNotFoundException ex) {
Log.w(ex);
Helper.view(context, uri, true, true);
Helper.view(context, theUri, true, true);
}
}
})