mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-13 12:33:42 +02:00
Sqlite sync extra
This commit is contained in:
@@ -651,7 +651,8 @@ public class ApplicationEx extends Application
|
||||
} else if (version < 1955) {
|
||||
if (!prefs.contains("doubletap"))
|
||||
editor.putBoolean("doubletap", true);
|
||||
}
|
||||
} else if (version < 1960)
|
||||
editor.remove("sqlite_auto_vacuum");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
|
||||
editor.remove("background_service");
|
||||
|
||||
@@ -410,13 +410,21 @@ public abstract class DB extends RoomDatabase {
|
||||
|
||||
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
||||
// https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/
|
||||
boolean sqlite_auto_vacuum = prefs.getBoolean("sqlite_auto_vacuum", !Helper.isRedmiNote());
|
||||
boolean sqlite_auto_vacuum = prefs.getBoolean("sqlite_auto_vacuum", false);
|
||||
String mode = (sqlite_auto_vacuum ? "FULL" : "INCREMENTAL");
|
||||
Log.i("Set PRAGMA auto_vacuum = " + mode);
|
||||
try (Cursor cursor = db.query("PRAGMA auto_vacuum = " + mode + ";", null)) {
|
||||
cursor.moveToNext(); // required
|
||||
}
|
||||
|
||||
// https://sqlite.org/pragma.html#pragma_synchronous
|
||||
boolean sqlite_sync_extra = prefs.getBoolean("sqlite_sync_extra", true);
|
||||
String sync = (sqlite_sync_extra ? "EXTRA" : "NORMAL");
|
||||
Log.i("Set PRAGMA synchronous = " + sync);
|
||||
try (Cursor cursor = db.query("PRAGMA synchronous = " + sync + ";", null)) {
|
||||
cursor.moveToNext(); // required
|
||||
}
|
||||
|
||||
// https://www.sqlite.org/pragma.html#pragma_cache_size
|
||||
Integer cache_size = getCacheSizeKb(context);
|
||||
if (cache_size != null) {
|
||||
|
||||
@@ -168,6 +168,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private SwitchCompat swCheckpoints;
|
||||
private SwitchCompat swAnalyze;
|
||||
private SwitchCompat swAutoVacuum;
|
||||
private SwitchCompat swSyncExtra;
|
||||
private TextView tvSqliteCache;
|
||||
private SeekBar sbSqliteCache;
|
||||
private TextView tvChunkSize;
|
||||
@@ -237,7 +238,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
"watchdog", "experiments", "main_log", "protocol", "log_level", "debug", "leak_canary",
|
||||
"test1", "test2", "test3", "test4", "test5",
|
||||
"work_manager", // "external_storage",
|
||||
"query_threads", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_cache",
|
||||
"query_threads", "wal",
|
||||
"sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_sync_extra", "sqlite_cache",
|
||||
"chunk_size", "thread_range", "undo_manager",
|
||||
"webview_legacy", "browser_zoom", "fake_dark",
|
||||
"show_recent",
|
||||
@@ -365,6 +367,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
swCheckpoints = view.findViewById(R.id.swCheckpoints);
|
||||
swAnalyze = view.findViewById(R.id.swAnalyze);
|
||||
swAutoVacuum = view.findViewById(R.id.swAutoVacuum);
|
||||
swSyncExtra = view.findViewById(R.id.swSyncExtra);
|
||||
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
|
||||
sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
|
||||
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
|
||||
@@ -1121,11 +1124,22 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
prefs.edit()
|
||||
.putBoolean("sqlite_auto_vacuum", checked)
|
||||
.remove("debug")
|
||||
.apply();
|
||||
.commit();
|
||||
ApplicationEx.restart(v.getContext(), "sqlite_auto_vacuum");
|
||||
}
|
||||
});
|
||||
|
||||
swSyncExtra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton v, boolean checked) {
|
||||
prefs.edit()
|
||||
.putBoolean("sqlite_sync_extra", checked)
|
||||
.remove("debug")
|
||||
.commit();
|
||||
ApplicationEx.restart(v.getContext(), "sqlite_sync_extra");
|
||||
}
|
||||
});
|
||||
|
||||
sbSqliteCache.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
@@ -1964,7 +1978,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
swWal.setChecked(prefs.getBoolean("wal", true));
|
||||
swCheckpoints.setChecked(prefs.getBoolean("sqlite_checkpoints", true));
|
||||
swAnalyze.setChecked(prefs.getBoolean("sqlite_analyze", true));
|
||||
swAutoVacuum.setChecked(prefs.getBoolean("sqlite_auto_vacuum", !Helper.isRedmiNote()));
|
||||
swAutoVacuum.setChecked(prefs.getBoolean("sqlite_auto_vacuum", false));
|
||||
swSyncExtra.setChecked(prefs.getBoolean("sqlite_sync_extra", true));
|
||||
|
||||
int sqlite_cache = prefs.getInt("sqlite_cache", DB.DEFAULT_CACHE_SIZE);
|
||||
Integer cache_size = DB.getCacheSizeKb(getContext());
|
||||
|
||||
Reference in New Issue
Block a user