From 8816da11d8c30f343b026105590f2b678083c961 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 Oct 2021 09:27:02 +0200 Subject: [PATCH] Added more options to theme dialog --- .../eu/faircode/email/FragmentDialogTheme.java | 18 ++++++++++++++++++ .../faircode/email/FragmentOptionsDisplay.java | 6 +++++- app/src/main/res/layout/dialog_theme.xml | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java index a62c6a194e..aeaa3b4271 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogTheme.java @@ -3,11 +3,13 @@ package eu.faircode.email; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Paint; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.RadioGroup; import android.widget.TextView; @@ -27,6 +29,7 @@ public class FragmentDialogTheme extends FragmentDialogBase { private SwitchCompat swBlack; private SwitchCompat swHtmlLight; private SwitchCompat swComposerLight; + private Button btnMore; private TextView tvMore; private void eval() { @@ -56,6 +59,9 @@ public class FragmentDialogTheme extends FragmentDialogBase { @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { + Bundle args = getArguments(); + boolean settings = (args != null && args.getBoolean("settings")); + final Context context = getContext(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String theme = prefs.getString("theme", "blue_orange_system"); @@ -70,6 +76,7 @@ public class FragmentDialogTheme extends FragmentDialogBase { swBlack = dview.findViewById(R.id.swBlack); swHtmlLight = dview.findViewById(R.id.swHtmlLight); swComposerLight = dview.findViewById(R.id.swComposerLight); + btnMore = dview.findViewById(R.id.btnMore); tvMore = dview.findViewById(R.id.tvMore); rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @@ -191,6 +198,17 @@ public class FragmentDialogTheme extends FragmentDialogBase { } }); + btnMore.setVisibility(settings ? View.GONE : View.VISIBLE); + btnMore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + v.getContext().startActivity(new Intent(v.getContext(), ActivitySetup.class) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) + .putExtra("tab", "display")); + } + }); + return new AlertDialog.Builder(getContext()) .setView(dview) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index a4af9ad019..f6e2f0ef1c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -293,7 +293,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer btnTheme.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - new FragmentDialogTheme().show(getParentFragmentManager(), "setup:theme"); + Bundle args = new Bundle(); + args.putBoolean("settings", true); + FragmentDialogTheme dialog = new FragmentDialogTheme(); + dialog.setArguments(args); + dialog.show(getParentFragmentManager(), "setup:theme"); } }); diff --git a/app/src/main/res/layout/dialog_theme.xml b/app/src/main/res/layout/dialog_theme.xml index a691eaeb2d..a86e53d189 100644 --- a/app/src/main/res/layout/dialog_theme.xml +++ b/app/src/main/res/layout/dialog_theme.xml @@ -175,6 +175,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swHtmlLight" /> +