Added button to simplify decryption

pull/157/head
M66B 6 years ago
parent 1cf32ef90e
commit 3ff91764d8

@ -264,6 +264,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private RecyclerView rvAttachment; private RecyclerView rvAttachment;
private CheckBox cbInline; private CheckBox cbInline;
private ImageButton ibDecrypt;
private Button btnDownloadAttachments; private Button btnDownloadAttachments;
private Button btnSaveAttachments; private Button btnSaveAttachments;
private TextView tvNoInternetAttachments; private TextView tvNoInternetAttachments;
@ -405,6 +406,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bnvActions.setLayoutParams(lparam); bnvActions.setLayoutParams(lparam);
} }
ibDecrypt = vsBody.findViewById(R.id.ibDecrypt);
ibImages = vsBody.findViewById(R.id.ibImages); ibImages = vsBody.findViewById(R.id.ibImages);
ibFull = vsBody.findViewById(R.id.ibFull); ibFull = vsBody.findViewById(R.id.ibFull);
tvBody = vsBody.findViewById(R.id.tvBody); tvBody = vsBody.findViewById(R.id.tvBody);
@ -464,6 +466,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibNotifyContact.setOnClickListener(this); ibNotifyContact.setOnClickListener(this);
ibAddContact.setOnClickListener(this); ibAddContact.setOnClickListener(this);
ibDecrypt.setOnClickListener(this);
btnDownloadAttachments.setOnClickListener(this); btnDownloadAttachments.setOnClickListener(this);
btnSaveAttachments.setOnClickListener(this); btnSaveAttachments.setOnClickListener(this);
@ -496,6 +499,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibNotifyContact.setOnClickListener(null); ibNotifyContact.setOnClickListener(null);
ibAddContact.setOnClickListener(null); ibAddContact.setOnClickListener(null);
ibDecrypt.setOnClickListener(null);
btnDownloadAttachments.setOnClickListener(null); btnDownloadAttachments.setOnClickListener(null);
btnSaveAttachments.setOnClickListener(null); btnSaveAttachments.setOnClickListener(null);
@ -827,6 +831,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbCalendarWait.setVisibility(View.GONE); pbCalendarWait.setVisibility(View.GONE);
cbInline.setVisibility(View.GONE); cbInline.setVisibility(View.GONE);
ibDecrypt.setVisibility(View.GONE);
btnDownloadAttachments.setVisibility(View.GONE); btnDownloadAttachments.setVisibility(View.GONE);
btnSaveAttachments.setVisibility(View.GONE); btnSaveAttachments.setVisibility(View.GONE);
tvNoInternetAttachments.setVisibility(View.GONE); tvNoInternetAttachments.setVisibility(View.GONE);
@ -1110,6 +1115,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Log.i("Show inline=" + show_inline); Log.i("Show inline=" + show_inline);
boolean has_inline = false; boolean has_inline = false;
boolean is_encrypted = false;
boolean download = false; boolean download = false;
boolean save = (attachments.size() > 1); boolean save = (attachments.size() > 1);
boolean downloading = false; boolean downloading = false;
@ -1119,6 +1125,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean inline = (attachment.isInline() || TextUtils.isEmpty(attachment.name)); boolean inline = (attachment.isInline() || TextUtils.isEmpty(attachment.name));
if (inline) if (inline)
has_inline = true; has_inline = true;
if (Objects.equals(attachment.encryption, EntityAttachment.PGP_MESSAGE))
is_encrypted = true;
if (attachment.progress == null && !attachment.available) if (attachment.progress == null && !attachment.available)
download = true; download = true;
if (!attachment.available) if (!attachment.available)
@ -1241,6 +1249,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
cbInline.setOnCheckedChangeListener(null); cbInline.setOnCheckedChangeListener(null);
cbInline.setChecked(show_inline); cbInline.setChecked(show_inline);
cbInline.setVisibility(has_inline ? View.VISIBLE : View.GONE); cbInline.setVisibility(has_inline ? View.VISIBLE : View.GONE);
ibDecrypt.setVisibility(is_encrypted ? View.VISIBLE : View.GONE);
btnDownloadAttachments.setVisibility(download && suitable ? View.VISIBLE : View.GONE); btnDownloadAttachments.setVisibility(download && suitable ? View.VISIBLE : View.GONE);
btnSaveAttachments.setVisibility(save ? View.VISIBLE : View.GONE); btnSaveAttachments.setVisibility(save ? View.VISIBLE : View.GONE);
tvNoInternetAttachments.setVisibility(downloading && !suitable ? View.VISIBLE : View.GONE); tvNoInternetAttachments.setVisibility(downloading && !suitable ? View.VISIBLE : View.GONE);
@ -1369,7 +1378,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message == null) if (message == null)
return; return;
if (view.getId() == R.id.ivSnoozed) if (view.getId() == R.id.ibDecrypt)
onMenuDecrypt(message);
else if (view.getId() == R.id.ivSnoozed)
onShowSnoozed(message); onShowSnoozed(message);
else if (view.getId() == R.id.ivFlagged) else if (view.getId() == R.id.ivFlagged)
onToggleFlag(message); onToggleFlag(message);

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M21,21.78L4.22,5 3,6.22l2.04,2.04C4.42,8.6 4,9.25 4,10v10c0,1.1 0.9,2 2,2h12c0.23,0 0.45,-0.05 0.66,-0.12L19.78,23 21,21.78zM8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1s3.1,1.39 3.1,3.1v2H9.66L20,18.34V10c0,-1.1 -0.9,-2 -2,-2h-1V6c0,-2.76 -2.24,-5 -5,-5 -2.56,0 -4.64,1.93 -4.94,4.4L8.9,7.24V6z"/>
</vector>

@ -18,6 +18,17 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/action_message" /> app:menu="@menu/action_message" />
<ImageButton
android:id="@+id/ibDecrypt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:contentDescription="@string/title_decrypt"
android:src="@drawable/baseline_no_encryption_24"
app:layout_constraintEnd_toStartOf="@+id/ibImages"
app:layout_constraintTop_toBottomOf="@id/bnvActions" />
<ImageButton <ImageButton
android:id="@+id/ibImages" android:id="@+id/ibImages"
android:layout_width="wrap_content" android:layout_width="wrap_content"

Loading…
Cancel
Save