mirror of https://github.com/M66B/FairEmail.git
Auto confirm forward raw
This commit is contained in:
parent
a32e118ed3
commit
f2cbbeb83a
|
@ -23,6 +23,7 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
|
@ -32,6 +33,8 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -42,6 +45,7 @@ import androidx.core.content.FileProvider;
|
|||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.NumberFormat;
|
||||
|
@ -52,7 +56,7 @@ import java.util.Objects;
|
|||
public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
||||
private boolean enabled;
|
||||
|
||||
private static final long AUTO_CONFIRM_DELAY = 10 * 1000L;
|
||||
private static final long AUTO_CONFIRM_DELAY = 2 * 1000L;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
@ -64,15 +68,21 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
if (savedInstanceState != null)
|
||||
enabled = savedInstanceState.getBoolean("fair:enabled");
|
||||
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_forward_raw, null);
|
||||
final Context context = getContext();
|
||||
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_forward_raw, null);
|
||||
ProgressBar pbDownloaded = dview.findViewById(R.id.pbDownloaded);
|
||||
TextView tvRemaining = dview.findViewById(R.id.tvRemaining);
|
||||
TextView tvOption = dview.findViewById(R.id.tvOption);
|
||||
TextView tvNoInternet = dview.findViewById(R.id.tvNoInternet);
|
||||
CheckBox cbAutoConfirm = dview.findViewById(R.id.cbAutoConfirm);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean eml_auto_confirm = prefs.getBoolean("eml_auto_confirm", false);
|
||||
|
||||
pbDownloaded.setProgress(0);
|
||||
pbDownloaded.setMax(ids.length);
|
||||
tvRemaining.setText(getString(R.string.title_eml_downloaded, "-"));
|
||||
cbAutoConfirm.setChecked(eml_auto_confirm);
|
||||
|
||||
tvOption.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -83,6 +93,13 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
}
|
||||
});
|
||||
|
||||
cbAutoConfirm.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("eml_auto_confirm", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
NumberFormat NF = NumberFormat.getNumberInstance();
|
||||
|
||||
new SimpleTask<long[]>() {
|
||||
|
@ -158,7 +175,7 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, long[] ids) {
|
||||
DB db = DB.getInstance(getContext());
|
||||
DB db = DB.getInstance(context);
|
||||
LiveData<Integer> ld = db.message().liveRaw(ids);
|
||||
ld.observe(getViewLifecycleOwner(), new Observer<Integer>() {
|
||||
@Override
|
||||
|
@ -181,12 +198,15 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
enabled = true;
|
||||
Button ok = getPositiveButton();
|
||||
ok.setEnabled(enabled);
|
||||
ok.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getPositiveButton().performClick();
|
||||
}
|
||||
}, AUTO_CONFIRM_DELAY);
|
||||
|
||||
boolean eml_auto_confirm = prefs.getBoolean("eml_auto_confirm", false);
|
||||
if (eml_auto_confirm)
|
||||
ok.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getPositiveButton().performClick();
|
||||
}
|
||||
}, AUTO_CONFIRM_DELAY);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -198,7 +218,7 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
}
|
||||
}.execute(this, getArguments(), "messages:forward");
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
return new AlertDialog.Builder(context)
|
||||
.setView(dview)
|
||||
.setPositiveButton(R.string.title_send, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -228,7 +228,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
"cc_bcc", "inline_image_hint", "compose_reference", "send_dialog",
|
||||
"setup_reminder", "setup_advanced",
|
||||
"signature_images_hint",
|
||||
"gmail_checked"
|
||||
"gmail_checked",
|
||||
"eml_auto_confirm"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,5 +82,14 @@
|
|||
android:textColor="?attr/colorWarning"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRemaining" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbAutoConfirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/title_auto_confirm"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNoInternet" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
||||
|
|
|
@ -1161,6 +1161,7 @@
|
|||
<string name="title_eml_remark">To forward messages, the raw (original) messages need to be downloaded from the email server. This requires an internet connection and the messages must still be stored on the email server.</string>
|
||||
<string name="title_eml_option">This can be prevented by enabling always downloading raw message files in the connection settings</string>
|
||||
<string name="title_eml_downloaded">Raw messages downloaded: %1$s</string>
|
||||
<string name="title_auto_confirm">Automatically confirm after a few seconds</string>
|
||||
|
||||
<string name="title_buttons">Select buttons</string>
|
||||
<string name="title_buttons_hint">The actual actions available depend on the account type and configuration</string>
|
||||
|
|
Loading…
Reference in New Issue