Removed cache lists options

List caching is managed automatically
pull/156/head
M66B 6 years ago
parent 6add12cfb9
commit ebeeeab4d4

@ -51,17 +51,16 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAuthentication; private SwitchCompat swAuthentication;
private SwitchCompat swParanoid; private SwitchCompat swParanoid;
private TextView tvParanoidHint; private TextView tvParanoidHint;
private SwitchCompat swCacheLists;
private TextView tvCacheListsHint;
private SwitchCompat swWatchdog; private SwitchCompat swWatchdog;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
private SwitchCompat swCrashReports; private SwitchCompat swCrashReports;
private SwitchCompat swDebug; private SwitchCompat swDebug;
private TextView tvMemoryClass;
private TextView tvLastCleanup; private TextView tvLastCleanup;
private final static String[] RESET_OPTIONS = new String[]{ 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[]{ 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); swAuthentication = view.findViewById(R.id.swAuthentication);
swParanoid = view.findViewById(R.id.swParanoid); swParanoid = view.findViewById(R.id.swParanoid);
tvParanoidHint = view.findViewById(R.id.tvParanoidHint); tvParanoidHint = view.findViewById(R.id.tvParanoidHint);
swCacheLists = view.findViewById(R.id.swCacheLists);
tvCacheListsHint = view.findViewById(R.id.tvCacheListsHint);
swWatchdog = view.findViewById(R.id.swWatchdog); swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates); swUpdates = view.findViewById(R.id.swUpdates);
swCrashReports = view.findViewById(R.id.swCrashReports); swCrashReports = view.findViewById(R.id.swCrashReports);
swDebug = view.findViewById(R.id.swDebug); swDebug = view.findViewById(R.id.swDebug);
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
tvLastCleanup = view.findViewById(R.id.tvLastCleanup); tvLastCleanup = view.findViewById(R.id.tvLastCleanup);
setOptions(); 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() { swWatchdog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -256,7 +247,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swEnglish.setChecked(prefs.getBoolean("english", false)); swEnglish.setChecked(prefs.getBoolean("english", false));
swAuthentication.setChecked(prefs.getBoolean("authentication", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", false));
swParanoid.setChecked(prefs.getBoolean("paranoid", true)); swParanoid.setChecked(prefs.getBoolean("paranoid", true));
swCacheLists.setChecked(prefs.getBoolean("cache_lists", true));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE); 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); ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
int class_mb = am.getMemoryClass(); int class_mb = am.getMemoryClass();
tvMemoryClass.setText(getString(R.string.title_advanced_memory_class, class_mb + " MB"));
tvCacheListsHint.setText(getString(R.string.title_advanced_cache_list_hint, class_mb + " MB"));
} }
private void setLastCleanup(long time) { private void setLastCleanup(long time) {

@ -159,14 +159,11 @@ public class ViewModelMessages extends ViewModel {
owner.getLifecycle().addObserver(new LifecycleObserver() { owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() { public void onDestroyed() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean cache = prefs.getBoolean("cache_lists", true);
int free_mb = Log.getFreeMemMb(); int free_mb = Log.getFreeMemMb();
boolean lowmem = (free_mb < LOW_MEM_MB); boolean lowmem = (free_mb < LOW_MEM_MB);
Log.i("Destroy model=" + viewType + Log.i("Destroy model=" + viewType +
" cache=" + cache + " lowmem=" + lowmem + " free=" + free_mb + " MB"); " lowmem=" + lowmem + " free=" + free_mb + " MB");
Model model = models.get(viewType); Model model = models.get(viewType);
if (model != null) { if (model != null) {
@ -174,7 +171,7 @@ public class ViewModelMessages extends ViewModel {
model.list.removeObservers(owner); model.list.removeObservers(owner);
} }
if (viewType == AdapterMessage.ViewType.THREAD || !cache || lowmem) { if (viewType == AdapterMessage.ViewType.THREAD || lowmem) {
Log.i("Remove model=" + viewType); Log.i("Remove model=" + viewType);
remove(viewType); remove(viewType);
} }

@ -125,28 +125,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swParanoid" /> app:layout_constraintTop_toBottomOf="@id/swParanoid" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCacheLists"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_cache_lists"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvParanoidHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvCacheListsHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_cache_list_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCacheLists" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWatchdog" android:id="@+id/swWatchdog"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -154,7 +132,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_watchdog" android:text="@string/title_advanced_watchdog"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCacheListsHint" app:layout_constraintTop_toBottomOf="@id/tvParanoidHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
@ -200,17 +178,29 @@
app:layout_constraintTop_toBottomOf="@id/swDebug" /> app:layout_constraintTop_toBottomOf="@id/swDebug" />
<TextView <TextView
android:id="@+id/tvLastCleanup" android:id="@+id/tvMemoryClass"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
android:layout_marginEnd="48dp" android:layout_marginEnd="48dp"
android:text="@string/title_advanced_last_cleanup" android:text="@string/title_advanced_memory_class"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDebugHint" /> app:layout_constraintTop_toBottomOf="@id/tvDebugHint" />
<TextView
android:id="@+id/tvLastCleanup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_last_cleanup"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMemoryClass" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -225,11 +225,11 @@
<string name="title_advanced_english">Force English language</string> <string name="title_advanced_english">Force English language</string>
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string> <string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
<string name="title_advanced_paranoid">Extra privacy features</string> <string name="title_advanced_paranoid">Extra privacy features</string>
<string name="title_advanced_cache_lists">Cache message lists</string>
<string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string> <string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string>
<string name="title_advanced_updates">Check for updates</string> <string name="title_advanced_updates">Check for updates</string>
<string name="title_advanced_crash_reports">Send error reports</string> <string name="title_advanced_crash_reports">Send error reports</string>
<string name="title_advanced_debug">Debug mode</string> <string name="title_advanced_debug">Debug mode</string>
<string name="title_advanced_memory_class">Memory class: %1$s</string>
<string name="title_advanced_last_cleanup">Last cleanup: %1$s</string> <string name="title_advanced_last_cleanup">Last cleanup: %1$s</string>
<string name="title_advanced_enabled_hint">Globally disable or enable receiving of messages</string> <string name="title_advanced_enabled_hint">Globally disable or enable receiving of messages</string>
@ -253,7 +253,6 @@
<string name="title_advanced_badge_hint">Only available on supported launchers</string> <string name="title_advanced_badge_hint">Only available on supported launchers</string>
<string name="title_advanced_english_hint">This will restart the app</string> <string name="title_advanced_english_hint">This will restart the app</string>
<string name="title_advanced_paranoid_hint">See the FAQ for details</string> <string name="title_advanced_paranoid_hint">See the FAQ for details</string>
<string name="title_advanced_cache_list_hint">Memory available: %1$s</string>
<string name="title_advanced_debug_hint">Enable extra logging and show debug information at various places</string> <string name="title_advanced_debug_hint">Enable extra logging and show debug information at various places</string>
<string name="title_select">Select &#8230;</string> <string name="title_select">Select &#8230;</string>

Loading…
Cancel
Save