From 6899d416eab0366a3b5d536d4bf133b66b3051bd Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 17 Aug 2019 09:26:45 +0200 Subject: [PATCH] Moved subscribe settings to receive tab --- .../faircode/email/FragmentOptionsMisc.java | 30 +---------- .../email/FragmentOptionsSynchronize.java | 30 ++++++++++- .../main/res/layout/fragment_options_misc.xml | 49 +----------------- .../layout/fragment_options_synchronize.xml | 50 ++++++++++++++++++- 4 files changed, 79 insertions(+), 80 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 685c3e2465..1da2241949 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -45,9 +45,6 @@ import androidx.constraintlayout.widget.Group; import androidx.preference.PreferenceManager; public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { - private SwitchCompat swSubscriptions; - private TextView tvSubscriptionPro; - private SwitchCompat swSubscribedOnly; private Spinner spBiometricsTimeout; private SwitchCompat swDoubleBack; private SwitchCompat swEnglish; @@ -65,7 +62,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private Group grpDebug; private final static String[] RESET_OPTIONS = new String[]{ - "subscriptions", "subscribed_only", "biometrics_timeout", "double_back", "english", "watchdog", "updates", "crash_reports", "debug" + "biometrics_timeout", "double_back", "english", "watchdog", "updates", "crash_reports", "debug" }; private final static String[] RESET_QUESTIONS = new String[]{ @@ -82,9 +79,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc // Get controls - swSubscriptions = view.findViewById(R.id.swSubscriptions); - tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro); - swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); swDoubleBack = view.findViewById(R.id.swDoubleBack); swEnglish = view.findViewById(R.id.swEnglish); @@ -107,23 +101,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("subscriptions", checked).apply(); - } - }); - - Helper.linkPro(tvSubscriptionPro); - - swSubscribedOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("subscribed_only", checked).apply(); - ServiceSynchronize.reload(getContext(), "subscribed_only"); - } - }); - spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { @@ -277,11 +254,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private void setOptions() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean pro = ActivityBilling.isPro(getContext()); - swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false) && pro); - swSubscriptions.setEnabled(pro); - swSubscribedOnly.setChecked(prefs.getBoolean("subscribed_only", false)); - int biometrics_timeout = prefs.getInt("biometrics_timeout", 2); int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues); for (int pos = 0; pos < biometricTimeoutValues.length; pos++) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index 25afdc59f8..0a5f6dab1f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -59,11 +59,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private SwitchCompat swDeleteUnseen; private SwitchCompat swSyncKept; private SwitchCompat swSyncFolders; + private SwitchCompat swSubscriptions; + private TextView tvSubscriptionPro; + private SwitchCompat swSubscribedOnly; private SwitchCompat swCheckMx; private final static String[] RESET_OPTIONS = new String[]{ "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", - "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "check_mx" + "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "subscribed_only", "check_mx" }; @Override @@ -87,6 +90,9 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swDeleteUnseen = view.findViewById(R.id.swDeleteUnseen); swSyncKept = view.findViewById(R.id.swSyncKept); swSyncFolders = view.findViewById(R.id.swSyncFolders); + swSubscriptions = view.findViewById(R.id.swSubscriptions); + tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro); + swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly); swCheckMx = view.findViewById(R.id.swCheckMx); setOptions(); @@ -201,6 +207,23 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr } }); + swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("subscriptions", checked).apply(); + } + }); + + Helper.linkPro(tvSubscriptionPro); + + swSubscribedOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("subscribed_only", checked).apply(); + ServiceSynchronize.reload(getContext(), "subscribed_only"); + } + }); + swCheckMx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -252,6 +275,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private void setOptions() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean pro = ActivityBilling.isPro(getContext()); swEnabled.setChecked(prefs.getBoolean("enabled", true)); @@ -264,7 +288,6 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr break; } - boolean pro = ActivityBilling.isPro(getContext()); swSchedule.setChecked(prefs.getBoolean("schedule", false) && pro); swSchedule.setEnabled(pro); tvScheduleStart.setText(formatHour(getContext(), prefs.getInt("schedule_start", 0))); @@ -275,6 +298,9 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swDeleteUnseen.setChecked(prefs.getBoolean("delete_unseen", false)); swSyncKept.setChecked(prefs.getBoolean("sync_kept", true)); swSyncFolders.setChecked(prefs.getBoolean("sync_folders", true)); + swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false) && pro); + swSubscriptions.setEnabled(pro); + swSubscribedOnly.setChecked(prefs.getBoolean("subscribed_only", false)); swCheckMx.setChecked(prefs.getBoolean("check_mx", false)); } diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 5bed70ce0f..ab7f5c14f8 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -19,64 +19,17 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> + + + + + + + +