From 338f6f5f6f7cd6905a01e25ec10d56a81fd50b0b Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 26 Oct 2023 15:15:29 +0200 Subject: [PATCH] Added option to skip storing tentative events --- .../eu/faircode/email/FragmentOptionsMisc.java | 13 ++++++++++++- .../main/java/eu/faircode/email/MessageHelper.java | 10 +++++++--- app/src/main/res/layout/fragment_options_misc.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 752ed6f3fb..82a52ccf3c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -114,6 +114,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swSortAnswers; private SwitchCompat swExternalAnswer; private SwitchCompat swShortcuts; + private SwitchCompat swICalTentative; private SwitchCompat swFts; private SwitchCompat swClassification; private TextView tvClassMinProbability; @@ -291,7 +292,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private static final long MIN_FILE_SIZE = 1024 * 1024L; private final static String[] RESET_OPTIONS = new String[]{ - "sort_answers", "shortcuts", "fts", + "sort_answers", "shortcuts", "ical_tentative", "fts", "classification", "class_min_probability", "class_min_difference", "show_filtered", "language", @@ -381,6 +382,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swSortAnswers = view.findViewById(R.id.swSortAnswers); swExternalAnswer = view.findViewById(R.id.swExternalAnswer); swShortcuts = view.findViewById(R.id.swShortcuts); + swICalTentative = view.findViewById(R.id.swICalTentative); swFts = view.findViewById(R.id.swFts); swClassification = view.findViewById(R.id.swClassification); ibClassification = view.findViewById(R.id.ibClassification); @@ -608,6 +610,14 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swICalTentative.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE); + swICalTentative.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("ical_tentative", checked).apply(); + } + }); + swFts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -2597,6 +2607,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swExternalSearch.setChecked(Helper.isComponentEnabled(getContext(), ActivitySearch.class)); swExternalAnswer.setChecked(Helper.isComponentEnabled(getContext(), ActivityAnswer.class)); swShortcuts.setChecked(prefs.getBoolean("shortcuts", true)); + swICalTentative.setChecked(prefs.getBoolean("ical_tentative", true)); swFts.setChecked(prefs.getBoolean("fts", false)); swClassification.setChecked(prefs.getBoolean("classification", false)); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 0d7bd0610e..eec121dc15 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -4416,6 +4416,9 @@ public class MessageHelper { private void decodeICalendar(Context context, EntityAttachment local) { DB db = DB.getInstance(context); try { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean ical_tentative = prefs.getBoolean("ical_tentative", true); + boolean permission = Helper.hasPermission(context, Manifest.permission.WRITE_CALENDAR); EntityMessage message = db.message().getMessage(local.message); @@ -4427,13 +4430,14 @@ public class MessageHelper { EntityFolder.SYSTEM.equals(folder.type) || EntityFolder.USER.equals(folder.type))); - if (!permission || !received || account == null || account.calendar == null) { + if (!permission || !received || account == null || account.calendar == null || !ical_tentative) { EntityLog.log(context, "Event not processed" + " permission=" + permission + " account=" + (account != null) + - " calendar=" + (account == null ? null : account.calendar) + " folder=" + (folder != null) + ":" + (folder == null ? null : folder.type) + - " received=" + received); + " received=" + received + + " calendar=" + (account == null ? null : account.calendar) + + " tentative=" + ical_tentative); return; } diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index eaa101f50b..5ac084ce9e 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -156,6 +156,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swShortcuts" /> + + Sort reply templates by frequency of use Provide reply templates to other apps Show frequently used contacts in Android share menu + Store received invitations as tentative Build search index %1$d / %2$d messages indexed (%3$s) Classify messages