mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
Persist sanitized state open link
This commit is contained in:
parent
6b31b76479
commit
5674fec271
2 changed files with 17 additions and 8 deletions
|
@ -6111,7 +6111,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean confirm_links = prefs.getBoolean("confirm_links", true);
|
boolean confirm_links = prefs.getBoolean("confirm_links", true);
|
||||||
Uri guri = UriHelper.guessScheme(uri);
|
|
||||||
|
|
||||||
String chost = FragmentDialogOpenLink.getConfirmHost(uri);
|
String chost = FragmentDialogOpenLink.getConfirmHost(uri);
|
||||||
boolean sanitize_links = prefs.getBoolean("sanitize_links", false);
|
boolean sanitize_links = prefs.getBoolean("sanitize_links", false);
|
||||||
|
@ -6126,6 +6125,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.show(parentFragment.getParentFragmentManager(), "open:link");
|
fragment.show(parentFragment.getParentFragmentManager(), "open:link");
|
||||||
} else {
|
} 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);
|
boolean tabs = prefs.getBoolean("open_with_tabs", true);
|
||||||
Helper.view(context, UriHelper.guessScheme(uri), !tabs, !tabs);
|
Helper.view(context, UriHelper.guessScheme(uri), !tabs, !tabs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -753,11 +753,14 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
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();
|
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);
|
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() {
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@ -770,15 +773,15 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// https://developer.android.com/training/basics/intents/sending#AppChooser
|
// https://developer.android.com/training/basics/intents/sending#AppChooser
|
||||||
Uri uri = Uri.parse(etLink.getText().toString());
|
Uri theUri = Uri.parse(etLink.getText().toString());
|
||||||
Log.i("Open link with uri=" + uri);
|
Log.i("Open link with uri=" + theUri);
|
||||||
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(uri));
|
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(theUri));
|
||||||
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
|
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
|
||||||
try {
|
try {
|
||||||
startActivity(chooser);
|
startActivity(chooser);
|
||||||
} catch (ActivityNotFoundException ex) {
|
} catch (ActivityNotFoundException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
Helper.view(context, uri, true, true);
|
Helper.view(context, theUri, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue