Experiment: fast fetch

pull/209/head
M66B 2 years ago
parent d54ec79ad6
commit a040f38621

@ -1762,8 +1762,32 @@ class Core {
Log.e(ex1);
}
if (download)
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state, stats);
if (download) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean fast_fetch = prefs.getBoolean("fast_fetch", false);
if (fast_fetch) {
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (maxSize == 0)
maxSize = Long.MAX_VALUE;
boolean download_eml = prefs.getBoolean("download_eml", false);
if (!message.content)
if (state.getNetworkState().isUnmetered() || (message.size != null && message.size < maxSize))
EntityOperation.queue(context, message, EntityOperation.BODY);
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
for (EntityAttachment attachment : attachments)
if (!attachment.available)
if (state.getNetworkState().isUnmetered() || (attachment.size != null && attachment.size < maxSize))
EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id);
if (download_eml &&
(message.raw == null || !message.raw) &&
(state.getNetworkState().isUnmetered() || (message.total != null && message.total < maxSize)))
EntityOperation.queue(context, message, EntityOperation.RAW);
} else
downloadMessage(context, account, folder, istore, ifolder, imessage, message.id, state, stats);
}
}
if (!stats.isEmpty())
@ -4479,10 +4503,11 @@ class Core {
File file = message.getFile(context);
Helper.writeText(file, body);
String text = HtmlHelper.getFullText(body);
message.content = true;
message.preview = HtmlHelper.getPreview(text);
message.language = HtmlHelper.getLanguage(context, message.subject, text);
db.message().setMessageContent(message.id,
true,
message.content,
message.language,
parts.isPlainOnly(download_plain),
message.preview,

@ -203,6 +203,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swKeepAlivePoll;
private SwitchCompat swEmptyPool;
private SwitchCompat swIdleDone;
private SwitchCompat swFastFetch;
private SwitchCompat swLogarithmicBackoff;
private SwitchCompat swExactAlarms;
private SwitchCompat swInfra;
@ -260,7 +261,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"show_recent",
"use_modseq", "uid_command", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "auth_apop", "use_top",
"keep_alive_poll", "empty_pool", "idle_done", "logarithmic_backoff",
"keep_alive_poll", "empty_pool", "idle_done", "fast_fetch", "logarithmic_backoff",
"exact_alarms", "infra", "dkim_verify", "dup_msgids", "global_keywords", "test_iab"
};
@ -414,6 +415,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swKeepAlivePoll = view.findViewById(R.id.swKeepAlivePoll);
swEmptyPool = view.findViewById(R.id.swEmptyPool);
swIdleDone = view.findViewById(R.id.swIdleDone);
swFastFetch = view.findViewById(R.id.swFastFetch);
swLogarithmicBackoff = view.findViewById(R.id.swLogarithmicBackoff);
swExactAlarms = view.findViewById(R.id.swExactAlarms);
swInfra = view.findViewById(R.id.swInfra);
@ -1412,6 +1414,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swFastFetch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("fast_fetch", checked).apply();
}
});
swLogarithmicBackoff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2124,6 +2133,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swKeepAlivePoll.setChecked(prefs.getBoolean("keep_alive_poll", false));
swEmptyPool.setChecked(prefs.getBoolean("empty_pool", true));
swIdleDone.setChecked(prefs.getBoolean("idle_done", true));
swFastFetch.setChecked(prefs.getBoolean("fast_fetch", false));
swLogarithmicBackoff.setChecked(prefs.getBoolean("logarithmic_backoff", true));
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
swInfra.setChecked(prefs.getBoolean("infra", false));

@ -1460,6 +1460,17 @@
app:layout_constraintTop_toBottomOf="@id/swEmptyPool"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFastFetch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_fast_fetch"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swIdleDone"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLogarithmicBackoff"
android:layout_width="0dp"
@ -1469,7 +1480,7 @@
android:text="@string/title_advanced_logarithmic_backoff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swIdleDone"
app:layout_constraintTop_toBottomOf="@id/swFastFetch"
app:switchPadding="12dp" />
<TextView

@ -809,6 +809,7 @@
<string name="title_advanced_auth_apop" translatable="false">APOP</string>
<string name="title_advanced_use_top" translatable="false">Use TOP</string>
<string name="title_advanced_idle_done" translatable="false">IDLE/DONE</string>
<string name="title_advanced_fast_fetch" translatable="false">Fast FETCH</string>
<string name="title_advanced_logarithmic_backoff" translatable="false">Logarithmic back-off</string>
<string name="title_advanced_logarithmic_backoff_hint" translatable="false">Turning this off can result in a significant increase in battery usage!</string>
<string name="title_advanced_keep_alive_poll" translatable="false">Poll on keep-alive</string>

Loading…
Cancel
Save