From 7eeb67f8739a318b4af37e24a752f570bf60bf02 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 30 Jan 2025 08:35:28 +0100 Subject: [PATCH] Added info button / expression conditions --- .../java/eu/faircode/email/FragmentRule.java | 9 +++++++++ .../main/java/eu/faircode/email/Helper.java | 13 +++++++++---- app/src/main/res/layout/fragment_rule.xml | 19 ++++++++++++++++--- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index de5c0f9cb8..80f1431378 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -135,6 +135,7 @@ public class FragmentRule extends FragmentBase { private CheckBox cbEveryDay; private EditText etYounger; + private ImageButton ibExpression; private EditText etExpression; private Spinner spAction; @@ -343,6 +344,7 @@ public class FragmentRule extends FragmentBase { cbEveryDay = view.findViewById(R.id.cbEveryDay); etYounger = view.findViewById(R.id.etYounger); + ibExpression = view.findViewById(R.id.ibExpression); etExpression = view.findViewById(R.id.etExpression); spAction = view.findViewById(R.id.spAction); @@ -683,6 +685,13 @@ public class FragmentRule extends FragmentBase { } }); + ibExpression.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Helper.viewFAQ(v.getContext(), "expression_conditions"); + } + }); + List actions = new ArrayList<>(); actions.add(new Action(EntityRule.TYPE_NOOP, getString(R.string.title_rule_noop), R.drawable.twotone_remove_circle_outline_24)); actions.add(new Action(EntityRule.TYPE_SEEN, getString(R.string.title_rule_seen), R.drawable.twotone_drafts_24)); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 7b0dc36ce0..5f5678e180 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -1386,7 +1386,15 @@ public class Helper { viewFAQ(context, question, true /* Google translate */); } + static void viewFAQ(Context context, String fragment) { + viewFAQ(context, fragment, true); + } + private static void viewFAQ(Context context, int question, boolean english) { + viewFAQ(context, question == 0 ? "top" : "faq" + question, english); + } + + private static void viewFAQ(Context context, String fragment, boolean english) { // Redirection is done to prevent text editors from opening the link // https://email.faircode.eu/faq -> https://github.com/M66B/FairEmail/blob/master/FAQ.md // https://email.faircode.eu/docs -> https://github.com/M66B/FairEmail/tree/master/docs @@ -1400,10 +1408,7 @@ public class Helper { else base = "https://email.faircode.eu/docs/FAQ-" + locale + ".md"; - if (question == 0) - view(context, Uri.parse(base + "#top"), "text/html", false, false); - else - view(context, Uri.parse(base + "#faq" + question), "text/html", false, false); + view(context, Uri.parse(base + "#" + fragment), "text/html", false, false); } static Uri getPrivacyUri(Context context) { diff --git a/app/src/main/res/layout/fragment_rule.xml b/app/src/main/res/layout/fragment_rule.xml index d88bb98a97..6053b3fe2e 100644 --- a/app/src/main/res/layout/fragment_rule.xml +++ b/app/src/main/res/layout/fragment_rule.xml @@ -857,12 +857,25 @@ android:id="@+id/tvExpression" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="12dp" android:text="@string/title_rule_expression" android:textAppearance="@style/TextAppearance.AppCompat.Small" + app:layout_constraintBottom_toBottomOf="@+id/ibExpression" + app:layout_constraintEnd_toStartOf="@id/ibExpression" + app:layout_constraintStart_toStartOf="parent" /> + + + app:layout_constraintStart_toEndOf="@id/tvExpression" + app:layout_constraintTop_toBottomOf="@+id/vSeparatorExpression" + app:srcCompat="@drawable/twotone_info_24" />