From ebeeeab4d49d1eded8d9b3a47485f84ead275c67 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 23 May 2019 18:45:11 +0200 Subject: [PATCH] Removed cache lists options List caching is managed automatically --- .../faircode/email/FragmentOptionsMisc.java | 19 ++------- .../eu/faircode/email/ViewModelMessages.java | 7 +--- .../main/res/layout/fragment_options_misc.xml | 40 +++++++------------ app/src/main/res/values/strings.xml | 3 +- 4 files changed, 22 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 82c78caf40..cb012cdf00 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -51,17 +51,16 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swAuthentication; private SwitchCompat swParanoid; private TextView tvParanoidHint; - private SwitchCompat swCacheLists; - private TextView tvCacheListsHint; private SwitchCompat swWatchdog; private SwitchCompat swUpdates; private SwitchCompat swCrashReports; private SwitchCompat swDebug; + private TextView tvMemoryClass; private TextView tvLastCleanup; private final static String[] RESET_OPTIONS = new String[]{ - "badge", "subscriptions", "subscribed_only", "english", "authentication", "paranoid", "cache_lists", "watchdog", "updates", "crash_reports", "debug" + "badge", "subscriptions", "subscribed_only", "english", "authentication", "paranoid", "watchdog", "updates", "crash_reports", "debug" }; private final static String[] RESET_QUESTIONS = new String[]{ @@ -85,13 +84,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swAuthentication = view.findViewById(R.id.swAuthentication); swParanoid = view.findViewById(R.id.swParanoid); tvParanoidHint = view.findViewById(R.id.tvParanoidHint); - swCacheLists = view.findViewById(R.id.swCacheLists); - tvCacheListsHint = view.findViewById(R.id.tvCacheListsHint); swWatchdog = view.findViewById(R.id.swWatchdog); swUpdates = view.findViewById(R.id.swUpdates); swCrashReports = view.findViewById(R.id.swCrashReports); swDebug = view.findViewById(R.id.swDebug); + tvMemoryClass = view.findViewById(R.id.tvMemoryClass); tvLastCleanup = view.findViewById(R.id.tvLastCleanup); setOptions(); @@ -158,13 +156,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc }); } - swCacheLists.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("cache_lists", checked).apply(); - } - }); - swWatchdog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -256,7 +247,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swEnglish.setChecked(prefs.getBoolean("english", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", false)); swParanoid.setChecked(prefs.getBoolean("paranoid", true)); - swCacheLists.setChecked(prefs.getBoolean("cache_lists", true)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE); @@ -265,8 +255,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); int class_mb = am.getMemoryClass(); - - tvCacheListsHint.setText(getString(R.string.title_advanced_cache_list_hint, class_mb + " MB")); + tvMemoryClass.setText(getString(R.string.title_advanced_memory_class, class_mb + " MB")); } private void setLastCleanup(long time) { diff --git a/app/src/main/java/eu/faircode/email/ViewModelMessages.java b/app/src/main/java/eu/faircode/email/ViewModelMessages.java index 000f502b88..3cbcfba744 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelMessages.java +++ b/app/src/main/java/eu/faircode/email/ViewModelMessages.java @@ -159,14 +159,11 @@ public class ViewModelMessages extends ViewModel { owner.getLifecycle().addObserver(new LifecycleObserver() { @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroyed() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean cache = prefs.getBoolean("cache_lists", true); - int free_mb = Log.getFreeMemMb(); boolean lowmem = (free_mb < LOW_MEM_MB); Log.i("Destroy model=" + viewType + - " cache=" + cache + " lowmem=" + lowmem + " free=" + free_mb + " MB"); + " lowmem=" + lowmem + " free=" + free_mb + " MB"); Model model = models.get(viewType); if (model != null) { @@ -174,7 +171,7 @@ public class ViewModelMessages extends ViewModel { model.list.removeObservers(owner); } - if (viewType == AdapterMessage.ViewType.THREAD || !cache || lowmem) { + if (viewType == AdapterMessage.ViewType.THREAD || lowmem) { Log.i("Remove model=" + viewType); remove(viewType); } diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index fc80ccf768..676bdd06cc 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -125,28 +125,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swParanoid" /> - - - - + + + app:layout_constraintTop_toBottomOf="@id/tvMemoryClass" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dea2fca166..5e4887289e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -225,11 +225,11 @@ Force English language Show a warning when the receiving server could not authenticate the message Extra privacy features - Cache message lists Periodically check if FairEmail is still active Check for updates Send error reports Debug mode + Memory class: %1$s Last cleanup: %1$s Globally disable or enable receiving of messages @@ -253,7 +253,6 @@ Only available on supported launchers This will restart the app See the FAQ for details - Memory available: %1$s Enable extra logging and show debug information at various places Select …