1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-26 07:53:12 +00:00

Removed cache lists options

List caching is managed automatically
This commit is contained in:
M66B 2019-05-23 18:45:11 +02:00
parent 6add12cfb9
commit ebeeeab4d4
4 changed files with 22 additions and 47 deletions

View file

@ -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) {

View file

@ -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);
}

View file

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

View file

@ -225,11 +225,11 @@
<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_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_updates">Check for updates</string>
<string name="title_advanced_crash_reports">Send error reports</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_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_english_hint">This will restart the app</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_select">Select &#8230;</string>