Added thread range setting

pull/207/head
M66B 3 years ago
parent 6b34286473
commit b67098f333

@ -145,6 +145,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SeekBar sbSqliteCache;
private TextView tvChunkSize;
private SeekBar sbChunkSize;
private TextView tvThreadRange;
private SeekBar sbThreadRange;
private ImageButton ibSqliteCache;
private SwitchCompat swUndoManager;
private SwitchCompat swWebViewLegacy;
@ -198,7 +200,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"protocol", "debug", "log_level", "test1", "test2", "test3", "test4", "test5",
"work_manager", // "external_storage",
"query_threads", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_cache",
"chunk_size", "undo_manager", "webview_legacy",
"chunk_size", "thread_range", "undo_manager", "webview_legacy",
"use_modseq", "uid_command", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop",
"keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff",
@ -301,6 +303,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
tvChunkSize = view.findViewById(R.id.tvChunkSize);
sbChunkSize = view.findViewById(R.id.sbChunkSize);
tvThreadRange = view.findViewById(R.id.tvThreadRange);
sbThreadRange = view.findViewById(R.id.sbThreadRange);
swUndoManager = view.findViewById(R.id.swUndoManager);
swWebViewLegacy = view.findViewById(R.id.swWebViewLegacy);
swModSeq = view.findViewById(R.id.swModSeq);
@ -938,6 +942,23 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
sbThreadRange.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
prefs.edit().putInt("thread_range", progress).apply();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
swProtocol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1618,6 +1639,11 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size));
sbChunkSize.setProgress(chunk_size);
int thread_range = prefs.getInt("thread_range", MessageHelper.DEFAULT_THREAD_RANGE);
int range = (int) Math.pow(2, thread_range);
tvThreadRange.setText(getString(R.string.title_advanced_thread_range, range));
sbThreadRange.setProgress(thread_range);
swUndoManager.setChecked(prefs.getBoolean("undo_manager", false));
swWebViewLegacy.setChecked(prefs.getBoolean("webview_legacy", false));
swModSeq.setChecked(prefs.getBoolean("use_modseq", true));

@ -141,7 +141,7 @@ public class MessageHelper {
static final int DEFAULT_DOWNLOAD_SIZE = 4 * 1024 * 1024; // bytes
static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
static final int MAX_SUBJECT_AGE = 48; // hours
static final long MAX_THREAD_RANGE = 180; // days
static final int DEFAULT_THREAD_RANGE = 7; // 2^7 = 128 days
static final List<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
"from", "by", "via", "with", "id", "for"
@ -1484,8 +1484,12 @@ public class MessageHelper {
List<String> all = new ArrayList<>(refs);
all.add(msgid);
Long start = (received == 0 ? null : received - MAX_THREAD_RANGE * 24 * 3600L);
Long end = (received == 0 ? null : received + MAX_THREAD_RANGE * 24 * 3600L);
int thread_range = prefs.getInt("thread_range", MessageHelper.DEFAULT_THREAD_RANGE);
int range = (int) Math.pow(2, thread_range);
Long start = (received == 0 ? null : received - range * 24 * 3600L);
Long end = (received == 0 ? null : received + range * 24 * 3600L);
List<TupleThreadInfo> infos = (all.size() == 0
? new ArrayList<>()
: db.message().getThreadInfo(account, all, start, end));

@ -877,6 +877,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvChunkSize" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvThreadRange"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_thread_range"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbChunkSize" />
<SeekBar
android:id="@+id/sbThreadRange"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:max="10"
android:min="0"
android:progress="7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvThreadRange" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUndoManager"
android:layout_width="0dp"
@ -886,7 +909,7 @@
android:text="@string/title_advanced_undo_manager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sbChunkSize"
app:layout_constraintTop_toBottomOf="@id/sbThreadRange"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -711,6 +711,7 @@
<string name="title_advanced_analyze" translatable="false">sqlite analyze</string>
<string name="title_advanced_sqlite_cache" translatable="false">sqlite cache: %1$s %% - %2$s</string>
<string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string>
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
<string name="title_advanced_undo_manager" translatable="false">Use Android\'s undo manager</string>
<string name="title_advanced_webview_legacy" translatable="false">Old WebView behavior</string>
<string name="title_advanced_modseq" translatable="false">MODSEQ</string>

Loading…
Cancel
Save