mirror of https://github.com/M66B/FairEmail.git
Added auto verify signatures
This commit is contained in:
parent
b53e200afd
commit
71288bd5f3
|
@ -3319,11 +3319,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
boolean auto_decrypt = prefs.getBoolean("auto_decrypt", false);
|
||||
boolean auto_decrypted = properties.getValue("auto_decrypted", message.id);
|
||||
boolean auto_verify = prefs.getBoolean("auto_verify", false);
|
||||
boolean auto_verified = properties.getValue("auto_verified", message.id);
|
||||
if (auto_decrypt && !auto_decrypted &&
|
||||
(EntityMessage.PGP_SIGNENCRYPT.equals(message.encrypt) ||
|
||||
EntityMessage.SMIME_SIGNENCRYPT.equals(message.encrypt))) {
|
||||
properties.setValue("auto_decrypted", message.id, true);
|
||||
onActionDecrypt(message, true);
|
||||
onActionVerifyDecrypt(message, true);
|
||||
} else if (auto_verify && !auto_verified && !message.verified &&
|
||||
(EntityMessage.PGP_SIGNONLY.equals(message.encrypt) ||
|
||||
EntityMessage.SMIME_SIGNONLY.equals(message.encrypt))) {
|
||||
properties.setValue("auto_verified", message.id, true);
|
||||
onActionVerifyDecrypt(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4268,9 +4275,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
properties.setExpanded(message, false, false);
|
||||
properties.setHeight(message.id, null);
|
||||
} else
|
||||
onActionDecrypt(message, false);
|
||||
onActionVerifyDecrypt(message, false);
|
||||
} else if (id == R.id.ibVerify) {
|
||||
onActionDecrypt(message, false);
|
||||
onActionVerifyDecrypt(message, false);
|
||||
} else if (id == R.id.ibUndo) {
|
||||
ActivityCompose.undoSend(message.id, context, owner, parentFragment.getParentFragmentManager());
|
||||
} else if (id == R.id.ibAnswer) {
|
||||
|
@ -5604,13 +5611,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
EntityFolder.JUNK.equals(message.folderType));
|
||||
}
|
||||
|
||||
private void onActionDecrypt(TupleMessageEx message, boolean auto) {
|
||||
private void onActionVerifyDecrypt(TupleMessageEx message, boolean auto) {
|
||||
boolean inline = properties.getValue("inline_encrypted", message.id);
|
||||
int encrypt = (message.encrypt == null || inline ? EntityMessage.PGP_SIGNENCRYPT /* Inline */ : message.encrypt);
|
||||
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(FragmentMessages.ACTION_DECRYPT)
|
||||
new Intent(FragmentMessages.ACTION_VERIFYDECRYPT)
|
||||
.putExtra("id", message.id)
|
||||
.putExtra("auto", auto)
|
||||
.putExtra("type", encrypt));
|
||||
|
|
|
@ -433,7 +433,7 @@ public class FragmentMessages extends FragmentBase
|
|||
static final int REQUEST_CALENDAR = 29;
|
||||
|
||||
static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW";
|
||||
static final String ACTION_DECRYPT = BuildConfig.APPLICATION_ID + ".DECRYPT";
|
||||
static final String ACTION_VERIFYDECRYPT = BuildConfig.APPLICATION_ID + ".VERIFYDECRYPT";
|
||||
static final String ACTION_KEYWORDS = BuildConfig.APPLICATION_ID + ".KEYWORDS";
|
||||
|
||||
private static final long REVIEW_ASK_DELAY = 14 * 24 * 3600 * 1000L; // milliseconds
|
||||
|
@ -5049,7 +5049,7 @@ public class FragmentMessages extends FragmentBase
|
|||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
IntentFilter iff = new IntentFilter();
|
||||
iff.addAction(ACTION_STORE_RAW);
|
||||
iff.addAction(ACTION_DECRYPT);
|
||||
iff.addAction(ACTION_VERIFYDECRYPT);
|
||||
iff.addAction(ACTION_KEYWORDS);
|
||||
lbm.registerReceiver(receiver, iff);
|
||||
|
||||
|
@ -8214,8 +8214,8 @@ public class FragmentMessages extends FragmentBase
|
|||
String action = intent.getAction();
|
||||
if (ACTION_STORE_RAW.equals(action))
|
||||
onStoreRaw(intent);
|
||||
else if (ACTION_DECRYPT.equals(action))
|
||||
onDecrypt(intent);
|
||||
else if (ACTION_VERIFYDECRYPT.equals(action))
|
||||
onVerifyDecrypt(intent);
|
||||
else if (ACTION_KEYWORDS.equals(action))
|
||||
onKeywords(intent);
|
||||
}
|
||||
|
@ -8247,7 +8247,7 @@ public class FragmentMessages extends FragmentBase
|
|||
startActivityForResult(Helper.getChooser(context, create), REQUEST_RAW);
|
||||
}
|
||||
|
||||
private void onDecrypt(Intent intent) {
|
||||
private void onVerifyDecrypt(Intent intent) {
|
||||
long id = intent.getLongExtra("id", -1);
|
||||
boolean auto = intent.getBooleanExtra("auto", false);
|
||||
int type = intent.getIntExtra("type", EntityMessage.ENCRYPT_NONE);
|
||||
|
@ -8255,6 +8255,7 @@ public class FragmentMessages extends FragmentBase
|
|||
final Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putInt("type", type);
|
||||
args.putBoolean("auto", auto);
|
||||
|
||||
if (EntityMessage.SMIME_SIGNONLY.equals(type))
|
||||
onSmime(args);
|
||||
|
@ -8285,7 +8286,7 @@ public class FragmentMessages extends FragmentBase
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityIdentity identity) {
|
||||
Boolean auto = args.getBoolean("auto");
|
||||
boolean auto = args.getBoolean("auto");
|
||||
if (auto && identity == null)
|
||||
return;
|
||||
|
||||
|
@ -9279,6 +9280,7 @@ public class FragmentMessages extends FragmentBase
|
|||
.setGestureInsetBottomIgnored(true).show();
|
||||
} else
|
||||
try {
|
||||
boolean auto = args.getBoolean("auto");
|
||||
String sender = args.getString("sender");
|
||||
Date time = (Date) args.getSerializable("time");
|
||||
boolean known = args.getBoolean("known");
|
||||
|
@ -9302,7 +9304,7 @@ public class FragmentMessages extends FragmentBase
|
|||
if (known && !record.isExpired(time) && match && valid)
|
||||
Snackbar.make(view, R.string.title_signature_valid, Snackbar.LENGTH_LONG)
|
||||
.setGestureInsetBottomIgnored(true).show();
|
||||
else {
|
||||
else if (!auto) {
|
||||
LayoutInflater inflator = LayoutInflater.from(getContext());
|
||||
View dview = inflator.inflate(R.layout.dialog_certificate, null);
|
||||
TextView tvCertificateInvalid = dview.findViewById(R.id.tvCertificateInvalid);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class FragmentOptionsEncryption extends FragmentBase
|
|||
private SwitchCompat swSign;
|
||||
private SwitchCompat swEncrypt;
|
||||
private SwitchCompat swEncryptAuto;
|
||||
private SwitchCompat swAutoVerify;
|
||||
private SwitchCompat swAutoDecrypt;
|
||||
private SwitchCompat swAutoUndoDecrypt;
|
||||
private Button btnReset;
|
||||
|
@ -118,7 +119,7 @@ public class FragmentOptionsEncryption extends FragmentBase
|
|||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"sign_default", "encrypt_default", "encrypt_auto",
|
||||
"auto_decrypt", "auto_undecrypt",
|
||||
"auto_verify", "auto_decrypt", "auto_undecrypt",
|
||||
"openpgp_provider", "autocrypt", "autocrypt_mutual", "encrypt_subject",
|
||||
"sign_algo_smime", "encrypt_algo_smime", "check_certificate"
|
||||
};
|
||||
|
@ -139,6 +140,7 @@ public class FragmentOptionsEncryption extends FragmentBase
|
|||
swSign = view.findViewById(R.id.swSign);
|
||||
swEncrypt = view.findViewById(R.id.swEncrypt);
|
||||
swEncryptAuto = view.findViewById(R.id.swEncryptAuto);
|
||||
swAutoVerify = view.findViewById(R.id.swAutoVerify);
|
||||
swAutoDecrypt = view.findViewById(R.id.swAutoDecrypt);
|
||||
swAutoUndoDecrypt = view.findViewById(R.id.swAutoUndoDecrypt);
|
||||
btnReset = view.findViewById(R.id.btnReset);
|
||||
|
@ -225,6 +227,13 @@ public class FragmentOptionsEncryption extends FragmentBase
|
|||
}
|
||||
});
|
||||
|
||||
swAutoVerify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("auto_verify", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAutoDecrypt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -644,6 +653,7 @@ public class FragmentOptionsEncryption extends FragmentBase
|
|||
swEncrypt.setChecked(prefs.getBoolean("encrypt_default", false));
|
||||
swSign.setEnabled(!swEncrypt.isChecked());
|
||||
swEncryptAuto.setChecked(prefs.getBoolean("encrypt_auto", false));
|
||||
swAutoVerify.setChecked(prefs.getBoolean("auto_verify", false));
|
||||
swAutoDecrypt.setChecked(prefs.getBoolean("auto_decrypt", false));
|
||||
swAutoUndoDecrypt.setChecked(prefs.getBoolean("auto_undecrypt", false));
|
||||
|
||||
|
|
|
@ -119,6 +119,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swEncrypt"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoVerify"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_auto_verify"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swEncryptAuto"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoDecrypt"
|
||||
android:layout_width="0dp"
|
||||
|
@ -127,7 +138,7 @@
|
|||
android:text="@string/title_advanced_auto_decrypt"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swEncryptAuto"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoVerify"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -767,6 +767,7 @@
|
|||
<string name="title_advanced_sign_default">Sign by default</string>
|
||||
<string name="title_advanced_encrypt_default">Encrypt by default</string>
|
||||
<string name="title_advanced_encrypt_auto">Automatically encrypt when all recipients\' keys are available</string>
|
||||
<string name="title_advanced_auto_verify">Automatically verify signed messages</string>
|
||||
<string name="title_advanced_auto_decrypt">Automatically decrypt messages</string>
|
||||
<string name="title_advanced_auto_undo_decrypt">Undo decryption on closing conversation</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue