From 7273d840c86db633c9bfbfca35d2a65276e1977c Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 24 Jan 2021 10:15:16 +0100 Subject: [PATCH] Save manual state --- .../java/eu/faircode/email/FragmentSetup.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 510dc6e4ef..3c43df475f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -90,6 +90,8 @@ public class FragmentSetup extends FragmentBase { private int colorWarning; private Drawable check; + private boolean manual = BuildConfig.DEBUG; + @Override @Nullable public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -219,13 +221,9 @@ public class FragmentSetup extends FragmentBase { ibManual.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (grpManual.getVisibility() == View.GONE) { - ibManual.setImageLevel(0 /* less */); - grpManual.setVisibility(View.VISIBLE); - } else { - ibManual.setImageLevel(1 /* more */); - grpManual.setVisibility(View.GONE); - } + manual = !manual; + ibManual.setImageLevel(manual ? 0 /* less */ : 1 /* more */); + grpManual.setVisibility(manual ? View.VISIBLE : View.GONE); } }); @@ -238,8 +236,10 @@ public class FragmentSetup extends FragmentBase { } }); - ibManual.setImageLevel(BuildConfig.DEBUG ? 0 /* less */ : 1 /* more */); - grpManual.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + if (savedInstanceState != null) + manual = savedInstanceState.getBoolean("fair:manual"); + ibManual.setImageLevel(manual ? 0 /* less */ : 1 /* more */); + grpManual.setVisibility(manual ? View.VISIBLE : View.GONE); btnAccount.setOnClickListener(new View.OnClickListener() { @Override @@ -366,6 +366,12 @@ public class FragmentSetup extends FragmentBase { return view; } + @Override + public void onSaveInstanceState(Bundle outState) { + outState.putBoolean("fair:manual", manual); + super.onSaveInstanceState(outState); + } + @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState);