Added send retry max setting

pull/214/head
M66B 4 months ago
parent b0ec6e7489
commit f98dc7a60c

@ -127,6 +127,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swLookupMx;
private SwitchCompat swReplyMove;
private SwitchCompat swReplyMoveInbox;
private EditText etSendRetryMax;
private final static List<String> RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList(
"keyboard", "keyboard_no_fullscreen",
@ -146,7 +147,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"format_flowed", "usenet_signature", "remove_signatures",
"receipt_default", "receipt_type", "receipt_legacy",
"forward_new",
"lookup_mx", "reply_move", "reply_move_inbox"
"lookup_mx", "reply_move", "reply_move_inbox",
"send_retry_max"
));
@Override
@ -219,6 +221,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swLookupMx = view.findViewById(R.id.swLookupMx);
swReplyMove = view.findViewById(R.id.swReplyMove);
swReplyMoveInbox = view.findViewById(R.id.swReplyMoveInbox);
etSendRetryMax = view.findViewById(R.id.etSendRetryMax);
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext(), false);
@ -762,6 +765,27 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
etSendRetryMax.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
}
@Override
public void afterTextChanged(Editable s) {
Integer count = Helper.parseInt(s.toString());
if (count == null)
prefs.edit().remove("send_retry_max").apply();
else
prefs.edit().putInt("send_retry_max", count).apply();
}
});
// Initialize
FragmentDialogTheme.setBackground(getContext(), view, false);
@ -798,6 +822,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
return;
if ("purge_contact_age".equals(key) || "purge_contact_freq".equals(key))
return;
if ("send_retry_max".equals(key))
return;
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
@ -938,6 +964,10 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swReplyMove.setChecked(prefs.getBoolean("reply_move", false));
swReplyMoveInbox.setChecked(prefs.getBoolean("reply_move_inbox", true));
swReplyMoveInbox.setEnabled(swReplyMove.isChecked());
int send_retry_max = prefs.getInt("send_retry_max", 0);
etSendRetryMax.setText(send_retry_max > 0 ? Integer.toString(send_retry_max) : null);
etSendRetryMax.setHint(Integer.toString(ServiceSend.RETRY_MAX_DEFAULT));
} catch (Throwable ex) {
Log.e(ex);
}

@ -79,6 +79,7 @@ import biweekly.component.VEvent;
import biweekly.property.Method;
public class ServiceSend extends ServiceBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private int retry_max = RETRY_MAX_DEFAULT;
private TupleUnsent lastUnsent = null;
private Network lastActive = null;
private boolean lastSuitable = false;
@ -91,7 +92,6 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
private static final ExecutorService executor =
Helper.getBackgroundExecutor(1, "send");
private static final int RETRY_MAX = 3;
private static final long RETRY_WAIT = 5000L; // milliseconds
private static final int CONNECTIVITY_DELAY = 5000; // milliseconds
private static final int PROGRESS_UPDATE_INTERVAL = 1000; // milliseconds
@ -100,12 +100,17 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
static final int PI_SEND = 1;
static final int PI_FIX = 2;
static final int RETRY_MAX_DEFAULT = 3;
@Override
public void onCreate() {
EntityLog.log(this, "Service send create");
super.onCreate();
startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
retry_max = prefs.getInt("send_retry_max", RETRY_MAX_DEFAULT);
owner = new TwoStateOwner(this, "send");
PowerManager pm = Helper.getSystemService(this, PowerManager.class);
@ -471,7 +476,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
(ex instanceof AuthenticationFailedException && !ConnectionHelper.isIoError(ex)) ||
ex instanceof SendFailedException ||
ex instanceof IllegalArgumentException);
int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries);
int tries_left = (unrecoverable ? 0 : retry_max - op.tries);
db.operation().setOperationError(op.id, Log.formatThrowable(ex));
if (message != null) {

@ -1112,6 +1112,52 @@
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swReplyMoveInbox" />
<TextView
android:id="@+id/tvSendRetryMax"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_send_retry_max"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReplyMoveHint" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etSendRetryMax"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="right"
android:imeOptions="actionDone"
android:inputType="number"
android:maxLength="2"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSendRetryMax" />
<TextView
android:id="@+id/tvSendRetryCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="×"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintBottom_toBottomOf="@id/etSendRetryMax"
app:layout_constraintStart_toEndOf="@id/etSendRetryMax"
app:layout_constraintTop_toTopOf="@id/etSendRetryMax" />
<TextView
android:id="@+id/tvSendRetryHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_send_retry_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etSendRetryMax" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -499,6 +499,8 @@
<string name="title_advanced_discard_delete">On discard draft, permanently delete draft</string>
<string name="title_advanced_reply_move">On replying to a message, save the reply in the same folder</string>
<string name="title_advanced_reply_move_inbox">Also for messages in the inbox</string>
<string name="title_advanced_send_retry_max">Maximum send attempts</string>
<string name="title_advanced_send_retry_hint">Sending will be retried on connectivity changes</string>
<string name="title_advanced_auto_link">Automatically create links</string>
<string name="title_advanced_plain_only">Send plain text only by default</string>

Loading…
Cancel
Save