mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
Persist view state open link
This commit is contained in:
parent
bc7ebeb79b
commit
1076a99c53
3 changed files with 38 additions and 7 deletions
|
@ -30,6 +30,7 @@ import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.RemoteAction;
|
import android.app.RemoteAction;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
@ -6125,15 +6126,30 @@ 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);
|
boolean link_view = prefs.getBoolean(chost + ".link_view", false);
|
||||||
if (sanitize && UriHelper.isHyperLink(uri)) {
|
boolean link_sanitize = prefs.getBoolean(chost + ".link_sanitize", false);
|
||||||
|
|
||||||
|
if (link_sanitize && UriHelper.isHyperLink(uri)) {
|
||||||
Uri sanitized = UriHelper.sanitize(uri);
|
Uri sanitized = UriHelper.sanitize(uri);
|
||||||
if (sanitized != null)
|
if (sanitized != null)
|
||||||
uri = sanitized;
|
uri = sanitized;
|
||||||
Log.i("Open sanitized=" + uri);
|
Log.i("Open sanitized=" + uri);
|
||||||
}
|
}
|
||||||
boolean tabs = prefs.getBoolean("open_with_tabs", true);
|
|
||||||
Helper.view(context, UriHelper.guessScheme(uri), !tabs, !tabs);
|
if (link_view) {
|
||||||
|
Log.i("Open view=" + uri);
|
||||||
|
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(uri));
|
||||||
|
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
|
||||||
|
try {
|
||||||
|
context.startActivity(chooser);
|
||||||
|
} catch (ActivityNotFoundException ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
Helper.view(context, uri, true, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
boolean tabs = prefs.getBoolean("open_with_tabs", true);
|
||||||
|
Helper.view(context, UriHelper.guessScheme(uri), !tabs, !tabs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -753,8 +753,13 @@ 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) {
|
||||||
if (UriHelper.isHyperLink(uri))
|
if (chost != null &&
|
||||||
prefs.edit().putBoolean(chost + ".sanitize", cbNotAgain.isChecked()).apply();
|
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked())
|
||||||
|
prefs.edit()
|
||||||
|
.putBoolean(chost + ".link_view", false)
|
||||||
|
.putBoolean(chost + ".link_sanitize",
|
||||||
|
cbSanitize.getVisibility() == View.VISIBLE && cbSanitize.isChecked())
|
||||||
|
.apply();
|
||||||
|
|
||||||
Uri theUri = Uri.parse(etLink.getText().toString());
|
Uri theUri = Uri.parse(etLink.getText().toString());
|
||||||
Package pkg = (Package) spOpenWith.getSelectedItem();
|
Package pkg = (Package) spOpenWith.getSelectedItem();
|
||||||
|
@ -772,6 +777,14 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
||||||
.setNeutralButton(R.string.title_browse, new DialogInterface.OnClickListener() {
|
.setNeutralButton(R.string.title_browse, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (chost != null &&
|
||||||
|
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked())
|
||||||
|
prefs.edit()
|
||||||
|
.putBoolean(chost + ".link_view", true)
|
||||||
|
.putBoolean(chost + ".link_sanitize",
|
||||||
|
cbSanitize.getVisibility() == View.VISIBLE && cbSanitize.isChecked())
|
||||||
|
.apply();
|
||||||
|
|
||||||
// https://developer.android.com/training/basics/intents/sending#AppChooser
|
// https://developer.android.com/training/basics/intents/sending#AppChooser
|
||||||
Uri theUri = Uri.parse(etLink.getText().toString());
|
Uri theUri = Uri.parse(etLink.getText().toString());
|
||||||
Log.i("Open link with uri=" + theUri);
|
Log.i("Open link with uri=" + theUri);
|
||||||
|
|
|
@ -2256,7 +2256,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
(key.startsWith("announcement.") && cbGeneral.isChecked()) ||
|
(key.startsWith("announcement.") && cbGeneral.isChecked()) ||
|
||||||
(key.endsWith(".show_full") && cbFull.isChecked()) ||
|
(key.endsWith(".show_full") && cbFull.isChecked()) ||
|
||||||
(key.endsWith(".show_images") && cbImages.isChecked()) ||
|
(key.endsWith(".show_images") && cbImages.isChecked()) ||
|
||||||
(key.endsWith(".confirm_link") && cbLinks.isChecked())) {
|
(key.endsWith(".confirm_link") && cbLinks.isChecked())||
|
||||||
|
(key.endsWith(".link_view") && cbLinks.isChecked())||
|
||||||
|
(key.endsWith(".link_sanitize") && cbLinks.isChecked())) {
|
||||||
Log.i("Removing option=" + key);
|
Log.i("Removing option=" + key);
|
||||||
editor.remove(key);
|
editor.remove(key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue