From cc1c62ba8cb023574ac1a592ae1e1d923519dc26 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 29 May 2024 10:08:30 +0200 Subject: [PATCH] Added do not show again option for changelog --- .../java/eu/faircode/email/ActivityView.java | 1 + .../email/FragmentDialogMarkdown.java | 36 +++++++++++++++---- app/src/main/res/layout/dialog_markdown.xml | 24 ++++++++++--- app/src/main/res/values/strings.xml | 1 + 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index af145359f4..cf9d798d8a 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -1531,6 +1531,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB Bundle args = new Bundle(); args.putString("name", "CHANGELOG.md"); + args.putString("option", "show_changelog"); FragmentDialogMarkdown fragment = new FragmentDialogMarkdown(); fragment.setArguments(args); fragment.show(getSupportFragmentManager(), "changelog"); diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogMarkdown.java b/app/src/main/java/eu/faircode/email/FragmentDialogMarkdown.java index 9e0c039d10..0ef80e558e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogMarkdown.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogMarkdown.java @@ -21,11 +21,16 @@ package eu.faircode.email; import android.app.Dialog; import android.content.Context; +import android.content.SharedPreferences; import android.os.Bundle; import android.text.Spanned; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.ImageButton; import android.widget.TextView; @@ -33,6 +38,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; import androidx.core.text.method.LinkMovementMethodCompat; +import androidx.preference.PreferenceManager; import java.io.InputStream; @@ -43,14 +49,27 @@ public class FragmentDialogMarkdown extends FragmentDialogBase { @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { - final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_markdown, null); + final Context context = getContext(); + + String option = getArguments().getString("option"); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_markdown, null); final TextView tvMarkdown = dview.findViewById(R.id.tvMarkdown); + final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); final ImageButton ibCancel = dview.findViewById(R.id.ibCancel); final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait); final Group grpReady = dview.findViewById(R.id.grpReady); tvMarkdown.setText(null); + cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean checked) { + prefs.edit().putBoolean(option, !checked).apply(); + } + }); + ibCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -58,23 +77,22 @@ public class FragmentDialogMarkdown extends FragmentDialogBase { } }); - Dialog dialog = new Dialog(getContext()); + Dialog dialog = new Dialog(context); //dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(dview); - dialog.getWindow().setLayout( - WindowManager.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.WRAP_CONTENT); new SimpleTask() { @Override protected void onPreExecute(Bundle args) { grpReady.setVisibility(View.GONE); + cbNotAgain.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); } @Override protected void onPostExecute(Bundle args) { grpReady.setVisibility(View.VISIBLE); + cbNotAgain.setVisibility(TextUtils.isEmpty(option) ? View.GONE : View.VISIBLE); pbWait.setVisibility(View.GONE); } @@ -121,4 +139,10 @@ public class FragmentDialogMarkdown extends FragmentDialogBase { return dialog; } -} + + @Override + public void onStart() { + super.onStart(); + getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_markdown.xml b/app/src/main/res/layout/dialog_markdown.xml index 70f4548acc..1c998467d5 100644 --- a/app/src/main/res/layout/dialog_markdown.xml +++ b/app/src/main/res/layout/dialog_markdown.xml @@ -3,17 +3,19 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" + android:padding="24dp" tools:context="eu.faircode.email.ActivityView"> @@ -34,13 +36,25 @@ + + Ask what to do Do not ask this again Do not ask this again for %1$s + Do not show this again This can be undone in the privacy-settings tab page No message text found This message is very large and this may cause problems!