1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 09:47:13 +00:00

Refactoring

This commit is contained in:
M66B 2019-12-02 08:44:50 +01:00
parent b39a7e852d
commit a5de71cb6a

View file

@ -1536,7 +1536,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, Object result) {
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
properties.setValue("inline_encrypted", message.id, args.getBoolean("inline_encrypted"));
TupleMessageEx amessage = getMessage();
if (amessage == null || !amessage.id.equals(message.id))
@ -1566,8 +1565,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbBody.setVisibility(View.GONE);
// Show attachments/images
// Show attachments
cowner.start();
// Show encrypt actions
ibVerify.setVisibility(EntityMessage.PGP_SIGNONLY.equals(message.encrypt)
? View.VISIBLE : View.GONE);
ibDecrypt.setVisibility(args.getBoolean("inline_encrypted") ||
EntityMessage.PGP_SIGNENCRYPT.equals(message.encrypt)
? View.VISIBLE : View.GONE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean auto_decrypt = prefs.getBoolean("auto_decrypt", false);
if (auto_decrypt && EntityMessage.PGP_SIGNENCRYPT.equals(message.encrypt))
onActionDecrypt(message, true);
// Show images
ibImages.setVisibility(has_images ? View.VISIBLE : View.GONE);
}
@ -1586,12 +1599,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
boolean show_inline = properties.getValue("inline", message.id);
boolean inline_encrypted = properties.getValue("inline_encrypted", message.id);
Log.i("Show inline=" + show_inline + " encrypted=" + inline_encrypted);
Log.i("Show inline=" + show_inline);
boolean has_inline = false;
boolean is_signed = false;
boolean is_encrypted = false;
boolean download = false;
boolean save = (attachments.size() > 1);
boolean downloading = false;
@ -1602,10 +1612,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean inline = (attachment.isInline() && attachment.isImage());
if (inline)
has_inline = true;
if (Objects.equals(attachment.encryption, EntityAttachment.PGP_MESSAGE))
is_encrypted = true;
if (Objects.equals(attachment.encryption, EntityAttachment.PGP_SIGNATURE))
is_signed = true;
if (attachment.progress == null && !attachment.available)
download = true;
if (!attachment.available)
@ -1641,14 +1647,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
btnDownloadAttachments.setVisibility(download && suitable ? View.VISIBLE : View.GONE);
tvNoInternetAttachments.setVisibility(downloading && !suitable ? View.VISIBLE : View.GONE);
ibVerify.setVisibility(is_signed ? View.VISIBLE : View.GONE);
ibDecrypt.setVisibility(inline_encrypted || is_encrypted ? View.VISIBLE : View.GONE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean auto_decrypt = prefs.getBoolean("auto_decrypt", false);
if (auto_decrypt && is_encrypted)
onActionDecrypt(message, true);
cbInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -2702,7 +2700,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
lbm.sendBroadcast(
new Intent(FragmentMessages.ACTION_DECRYPT)
.putExtra("id", message.id)
.putExtra("auto", auto));
.putExtra("auto", auto)
.putExtra("type", (int) message.encrypt));
}
private void onActionReplyMenu(TupleMessageEx message) {