diff --git a/app/src/main/java/eu/faircode/email/DB.java b/app/src/main/java/eu/faircode/email/DB.java
index d574e24451..928aba721e 100644
--- a/app/src/main/java/eu/faircode/email/DB.java
+++ b/app/src/main/java/eu/faircode/email/DB.java
@@ -117,7 +117,8 @@ public abstract class DB extends RoomDatabase {
private static Context sContext;
private static DB sInstance;
- static final int DB_DEFAULT_CACHE = 5; // percentage
+ static final int DEFAULT_QUERY_THREADS = 4; // AndroidX default thread count: 4
+ static final int DEFAULT_CACHE_SIZE = 5; // percentage
private static final String DB_NAME = "fairemail";
private static final int DB_CHECKPOINT = 1000; // requery/sqlite-android default
@@ -373,9 +374,9 @@ public abstract class DB extends RoomDatabase {
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- int threads = prefs.getInt("query_threads", 4); // AndroidX default thread count: 4
+ int threads = prefs.getInt("query_threads", DEFAULT_QUERY_THREADS);
boolean wal = prefs.getBoolean("wal", true);
- int sqlite_cache = prefs.getInt("sqlite_cache", DB.DB_DEFAULT_CACHE);
+ int sqlite_cache = prefs.getInt("sqlite_cache", DEFAULT_CACHE_SIZE);
Log.i("DB query threads=" + threads + " wal=" + wal);
ExecutorService executorQuery = Helper.getBackgroundExecutor(threads, "query");
ExecutorService executorTransaction = Helper.getBackgroundExecutor(0, "transaction");
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index 08e0d471f4..40640e83af 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -118,11 +118,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvLastCleanup;
private Button btnApp;
private Button btnMore;
-
private SwitchCompat swProtocol;
private SwitchCompat swLogInfo;
private SwitchCompat swDebug;
- private SwitchCompat swQueries;
+
+ private TextView tvRoomQueryThreads;
+ private SeekBar sbRoomQueryThreads;
+ private ImageButton ibRoom;
private SwitchCompat swWal;
private SwitchCompat swCheckpoints;
private TextView tvSqliteCache;
@@ -234,11 +236,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvLastCleanup = view.findViewById(R.id.tvLastCleanup);
btnApp = view.findViewById(R.id.btnApp);
btnMore = view.findViewById(R.id.btnMore);
-
swProtocol = view.findViewById(R.id.swProtocol);
swLogInfo = view.findViewById(R.id.swLogInfo);
swDebug = view.findViewById(R.id.swDebug);
- swQueries = view.findViewById(R.id.swQueries);
+
+ tvRoomQueryThreads = view.findViewById(R.id.tvRoomQueryThreads);
+ sbRoomQueryThreads = view.findViewById(R.id.sbRoomQueryThreads);
+ ibRoom = view.findViewById(R.id.ibRoom);
swWal = view.findViewById(R.id.swWal);
swCheckpoints = view.findViewById(R.id.swCheckpoints);
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
@@ -599,13 +603,27 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
- swQueries.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ sbRoomQueryThreads.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
- if (checked)
- prefs.edit().putInt("query_threads", 2).commit(); // apply won't work here
- else
- prefs.edit().remove("query_threads").commit(); // apply won't work here
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ prefs.edit().putInt("query_threads", progress).apply();
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+ });
+
+ ibRoom.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ApplicationEx.restart(v.getContext());
}
});
@@ -1104,11 +1122,15 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swProtocol.setChecked(prefs.getBoolean("protocol", false));
swLogInfo.setChecked(prefs.getInt("log_level", Log.getDefaultLogLevel()) <= android.util.Log.INFO);
swDebug.setChecked(prefs.getBoolean("debug", false));
- swQueries.setChecked(prefs.getInt("query_threads", 4) < 4);
+
+ int query_threads = prefs.getInt("query_threads", DB.DEFAULT_QUERY_THREADS);
+ tvRoomQueryThreads.setText(getString(R.string.title_advanced_room_query_threads, NF.format(query_threads)));
+ sbRoomQueryThreads.setProgress(query_threads);
+
swWal.setChecked(prefs.getBoolean("wal", true));
swCheckpoints.setChecked(prefs.getBoolean("checkpoints", true));
- int sqlite_cache = prefs.getInt("sqlite_cache", DB.DB_DEFAULT_CACHE);
+ int sqlite_cache = prefs.getInt("sqlite_cache", DB.DEFAULT_CACHE_SIZE);
int cache_size = sqlite_cache * class_mb * 1024 / 100;
tvSqliteCache.setText(getString(R.string.title_advanced_sqlite_cache,
NF.format(sqlite_cache),
diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml
index 0a7649deaa..9e334e0f9a 100644
--- a/app/src/main/res/layout/fragment_options_misc.xml
+++ b/app/src/main/res/layout/fragment_options_misc.xml
@@ -594,31 +594,40 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
-
+ app:layout_constraintTop_toBottomOf="@id/tvCaptionDebug" />
-
+ app:layout_constraintTop_toBottomOf="@id/tvRoomQueryThreads" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/ibRoom" />
Protocol logging
Debug logging
Debug mode
- Limit parallel database access
+ ROOM query threads %1$s
WAL
Checkpoints
Sqlite cache %1$s %% - %2$s
@@ -730,7 +730,6 @@
This Android version does not support notification grouping
This Android version does not support notification channels
- Enabling this will decrease performance, however, enabling is required on some devices
Enabling this improves search performance, but also increases battery and storage space usage
This will restart the app
List of current experimental features