From b29eb3b2ad28f3eb7b9c6f00141d039d4940da30 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 23 May 2024 08:44:57 +0200 Subject: [PATCH] Added sub option to open links by default --- .../faircode/email/FragmentDialogOpenLink.java | 17 +++++++++++++++-- app/src/main/res/layout/dialog_open_link.xml | 12 +++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java index 35d6a73920..60a8a19aab 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java @@ -184,6 +184,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { final CheckBox cbSecure = dview.findViewById(R.id.cbSecure); final CheckBox cbSanitize = dview.findViewById(R.id.cbSanitize); final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); + final CheckBox cbNeverAgain = dview.findViewById(R.id.cbNeverAgain); final Spinner spOpenWith = dview.findViewById(R.id.spOpenWith); ibMore = dview.findViewById(R.id.ibMore); @@ -350,6 +351,13 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { } }); + cbNeverAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + cbNotAgain.setEnabled(!isChecked); + } + }); + spOpenWith.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { @@ -608,6 +616,8 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, chost)); cbNotAgain.setVisibility(!always_confirm && !sanitize_links && chost != null ? View.VISIBLE : View.GONE); + cbNeverAgain.setVisibility(!always_confirm && !sanitize_links ? View.VISIBLE : View.GONE); + setMore(false); if (UriHelper.isHyperLink(uri)) { @@ -782,13 +792,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (chost != null && - cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked()) + if (cbNeverAgain.getVisibility() == View.VISIBLE && cbNeverAgain.isChecked()) + prefs.edit().putBoolean("confirm_links", false).apply(); + else if (chost != null && + 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()); Package pkg = (Package) spOpenWith.getSelectedItem(); diff --git a/app/src/main/res/layout/dialog_open_link.xml b/app/src/main/res/layout/dialog_open_link.xml index 6b8cb02a76..72f9b9929a 100644 --- a/app/src/main/res/layout/dialog_open_link.xml +++ b/app/src/main/res/layout/dialog_open_link.xml @@ -204,6 +204,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbSanitize" /> + + + app:layout_constraintTop_toBottomOf="@id/cbNeverAgain" />