Made signed/encrypted icon clickable

pull/194/merge
M66B 3 years ago
parent e195836f86
commit 053a99652c

@ -34,7 +34,6 @@ import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.RemoteAction; import android.app.RemoteAction;
import android.content.ActivityNotFoundException;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ContentResolver; import android.content.ContentResolver;
@ -42,7 +41,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Color; import android.graphics.Color;
@ -342,8 +340,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibPriority; private ImageButton ibPriority;
private ImageButton ibSensitivity; private ImageButton ibSensitivity;
private ImageView ivImportance; private ImageView ivImportance;
private ImageView ivSigned; private ImageButton ibSigned;
private ImageView ivEncrypted; private ImageButton ibEncrypted;
private TextView tvFrom; private TextView tvFrom;
private TextView tvSize; private TextView tvSize;
private TextView tvTime; private TextView tvTime;
@ -651,8 +649,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibPriority = itemView.findViewById(R.id.ibPriority); ibPriority = itemView.findViewById(R.id.ibPriority);
ibSensitivity = itemView.findViewById(R.id.ibSensitivity); ibSensitivity = itemView.findViewById(R.id.ibSensitivity);
ivImportance = itemView.findViewById(R.id.ivImportance); ivImportance = itemView.findViewById(R.id.ivImportance);
ivSigned = itemView.findViewById(R.id.ivSigned); ibSigned = itemView.findViewById(R.id.ibSigned);
ivEncrypted = itemView.findViewById(R.id.ivEncrypted); ibEncrypted = itemView.findViewById(R.id.ibEncrypted);
tvFrom = itemView.findViewById(subject_top ? R.id.tvSubject : R.id.tvFrom); tvFrom = itemView.findViewById(subject_top ? R.id.tvSubject : R.id.tvFrom);
tvSize = itemView.findViewById(R.id.tvSize); tvSize = itemView.findViewById(R.id.tvSize);
tvTime = itemView.findViewById(R.id.tvTime); tvTime = itemView.findViewById(R.id.tvTime);
@ -914,6 +912,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth.setOnClickListener(this); ibAuth.setOnClickListener(this);
ibPriority.setOnClickListener(this); ibPriority.setOnClickListener(this);
ibSensitivity.setOnClickListener(this); ibSensitivity.setOnClickListener(this);
ibSigned.setOnClickListener(this);
ibEncrypted.setOnClickListener(this);
ibSnoozed.setOnClickListener(this); ibSnoozed.setOnClickListener(this);
ibFlagged.setOnClickListener(this); ibFlagged.setOnClickListener(this);
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
@ -1018,6 +1018,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth.setOnClickListener(null); ibAuth.setOnClickListener(null);
ibPriority.setOnClickListener(null); ibPriority.setOnClickListener(null);
ibSensitivity.setOnClickListener(null); ibSensitivity.setOnClickListener(null);
ibSigned.setOnClickListener(null);
ibEncrypted.setOnClickListener(null);
ibSnoozed.setOnClickListener(null); ibSnoozed.setOnClickListener(null);
ibFlagged.setOnClickListener(null); ibFlagged.setOnClickListener(null);
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
@ -1162,8 +1164,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibPriority.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibPriority.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibSensitivity.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibSensitivity.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivImportance.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ivImportance.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivSigned.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibSigned.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivEncrypted.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibEncrypted.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvFrom.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); tvFrom.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvSize.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); tvSize.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvTime.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); tvTime.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -1260,12 +1262,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else } else
ivImportance.setVisibility(View.GONE); ivImportance.setVisibility(View.GONE);
ivSigned.setVisibility(message.signed > 0 ? View.VISIBLE : View.GONE); if (!Objects.equals(ibSigned.getTag(), message.verified)) {
if (message.verified) ibSigned.setTag(message.verified);
ivSigned.setColorFilter(colorEncrypt); if (message.verified)
else ibSigned.setColorFilter(colorEncrypt);
ivSigned.clearColorFilter(); else
ivEncrypted.setVisibility(message.encrypted > 0 ? View.VISIBLE : View.GONE); ibSigned.clearColorFilter();
}
ibSigned.setVisibility(message.isSigned() ? View.VISIBLE : View.GONE);
ibEncrypted.setVisibility(message.isEncrypted() ? View.VISIBLE : View.GONE);
MessageHelper.AddressFormat format = email_format; MessageHelper.AddressFormat format = email_format;
@ -2783,9 +2788,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDecrypt.setImageTintList(ColorStateList.valueOf(unlocked ibDecrypt.setImageTintList(ColorStateList.valueOf(unlocked
? colorControlNormal : colorAccent)); ? colorControlNormal : colorAccent));
ibDecrypt.setVisibility(!EntityFolder.OUTBOX.equals(message.folderType) && ibDecrypt.setVisibility(!EntityFolder.OUTBOX.equals(message.folderType) &&
(args.getBoolean("inline_encrypted") || (args.getBoolean("inline_encrypted") || message.isEncrypted())
EntityMessage.PGP_SIGNENCRYPT.equals(message.ui_encrypt) ||
EntityMessage.SMIME_SIGNENCRYPT.equals(message.ui_encrypt))
? View.VISIBLE : View.GONE); ? View.VISIBLE : View.GONE);
boolean reformatted_hint = prefs.getBoolean("reformatted_hint", true); boolean reformatted_hint = prefs.getBoolean("reformatted_hint", true);
@ -3513,6 +3516,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onShowPriority(message); onShowPriority(message);
else if (id == R.id.ibSensitivity) else if (id == R.id.ibSensitivity)
onShowSensitivity(message); onShowSensitivity(message);
else if (id == R.id.ibSigned)
onShowSigned(message);
else if (id == R.id.ibEncrypted)
onShowEncrypted(message);
else if (id == R.id.ibSnoozed) else if (id == R.id.ibSnoozed)
onShowSnoozed(message); onShowSnoozed(message);
else if (id == R.id.ibFlagged) else if (id == R.id.ibFlagged)
@ -3996,6 +4003,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ToastEx.makeText(context, resid, Toast.LENGTH_LONG).show(); ToastEx.makeText(context, resid, Toast.LENGTH_LONG).show();
} }
private void onShowSigned(TupleMessageEx message) {
int resid = -1;
if (EntityMessage.PGP_SIGNONLY.equals(message.ui_encrypt))
resid = R.string.title_advanced_caption_pgp;
else if (EntityMessage.SMIME_SIGNONLY.equals(message.ui_encrypt))
resid = R.string.title_advanced_caption_smime;
if (resid > 0)
ToastEx.makeText(context, resid, Toast.LENGTH_LONG).show();
}
private void onShowEncrypted(TupleMessageEx message) {
int resid = -1;
if (EntityMessage.PGP_SIGNENCRYPT.equals(message.ui_encrypt))
resid = R.string.title_advanced_caption_pgp;
else if (EntityMessage.SMIME_SIGNENCRYPT.equals(message.ui_encrypt))
resid = R.string.title_advanced_caption_smime;
if (resid > 0)
ToastEx.makeText(context, resid, Toast.LENGTH_LONG).show();
}
private void onShowSnoozed(TupleMessageEx message) { private void onShowSnoozed(TupleMessageEx message) {
if (message.ui_snoozed != null && message.ui_snoozed != Long.MAX_VALUE) { if (message.ui_snoozed != null && message.ui_snoozed != Long.MAX_VALUE) {
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT); DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
@ -6181,9 +6208,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
result.add(message.subject); result.add(message.subject);
} }
if (message.encrypted > 0) if (message.isSigned())
result.add(context.getString(R.string.title_legend_encrypted)); result.add(context.getString(R.string.title_legend_encrypted));
else if (message.signed > 0) else if (message.isEncrypted())
result.add(context.getString(R.string.title_legend_signed)); result.add(context.getString(R.string.title_legend_signed));
if (ibAuth.getVisibility() == View.VISIBLE) if (ibAuth.getVisibility() == View.VISIBLE)
@ -6728,14 +6755,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false; same = false;
log("drafts changed", next.id); log("drafts changed", next.id);
} }
if (prev.signed != next.signed) {
same = false;
log("signed changed", next.id);
}
if (prev.encrypted != next.encrypted) {
same = false;
log("encrypted changed", next.id);
}
if (prev.visible != next.visible) { if (prev.visible != next.visible) {
same = false; same = false;
log("visible changed " + prev.visible + "/" + next.visible, next.id); log("visible changed " + prev.visible + "/" + next.visible, next.id);

@ -57,8 +57,6 @@ public interface DaoMessage {
", SUM(1 - message.ui_seen) AS unseen" + ", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" + ", SUM(1 - message.ui_flagged) AS unflagged" +
", SUM(folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" + ", SUM(folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" +
", (message.ui_encrypt IN (2, 4)) AS signed" +
", (message.ui_encrypt IN (1, 3)) AS encrypted" +
", COUNT(DISTINCT" + ", COUNT(DISTINCT" +
" CASE WHEN NOT message.hash IS NULL THEN message.hash" + " CASE WHEN NOT message.hash IS NULL THEN message.hash" +
" WHEN NOT message.msgid IS NULL THEN message.msgid" + " WHEN NOT message.msgid IS NULL THEN message.msgid" +
@ -137,8 +135,6 @@ public interface DaoMessage {
", SUM(1 - message.ui_seen) AS unseen" + ", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" + ", SUM(1 - message.ui_flagged) AS unflagged" +
", SUM(folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" + ", SUM(folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" +
", (message.ui_encrypt IN (2, 4)) AS signed" +
", (message.ui_encrypt IN (1, 3)) AS encrypted" +
", COUNT(DISTINCT" + ", COUNT(DISTINCT" +
" CASE WHEN NOT message.hash IS NULL THEN message.hash" + " CASE WHEN NOT message.hash IS NULL THEN message.hash" +
" WHEN NOT message.msgid IS NULL THEN message.msgid" + " WHEN NOT message.msgid IS NULL THEN message.msgid" +
@ -210,8 +206,6 @@ public interface DaoMessage {
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" + ", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" + ", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" +
", (folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" + ", (folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" +
", (message.ui_encrypt IN (2, 4)) AS signed" +
", (message.ui_encrypt IN (1, 3)) AS encrypted" +
", 1 AS visible" + ", 1 AS visible" +
", NOT message.ui_seen AS visible_unseen" + ", NOT message.ui_seen AS visible_unseen" +
", message.total AS totalSize" + ", message.total AS totalSize" +
@ -478,8 +472,6 @@ public interface DaoMessage {
", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" + ", CASE WHEN message.ui_seen THEN 0 ELSE 1 END AS unseen" +
", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" + ", CASE WHEN message.ui_flagged THEN 0 ELSE 1 END AS unflagged" +
", (folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" + ", (folder.type = '" + EntityFolder.DRAFTS + "') AS drafts" +
", (message.ui_encrypt IN (2, 4)) AS signed" +
", (message.ui_encrypt IN (1, 3)) AS encrypted" +
", 1 AS visible" + ", 1 AS visible" +
", NOT message.ui_seen AS visible_unseen" + ", NOT message.ui_seen AS visible_unseen" +
", message.total AS totalSize" + ", message.total AS totalSize" +
@ -510,8 +502,6 @@ public interface DaoMessage {
", 1 AS unseen" + ", 1 AS unseen" +
", 0 AS unflagged" + ", 0 AS unflagged" +
", 0 AS drafts" + ", 0 AS drafts" +
", (message.ui_encrypt IN (2, 4)) AS signed" +
", (message.ui_encrypt IN (1, 3)) AS encrypted" +
", 1 AS visible" + ", 1 AS visible" +
", NOT message.ui_seen AS visible_unseen" + ", NOT message.ui_seen AS visible_unseen" +
", message.total AS totalSize" + ", message.total AS totalSize" +

@ -319,6 +319,16 @@ public class EntityMessage implements Serializable {
return hasKeyword(MessageHelper.FLAG_FORWARDED); return hasKeyword(MessageHelper.FLAG_FORWARDED);
} }
boolean isSigned() {
return (EntityMessage.PGP_SIGNONLY.equals(ui_encrypt) ||
EntityMessage.SMIME_SIGNONLY.equals(ui_encrypt));
}
boolean isEncrypted() {
return (EntityMessage.PGP_SIGNENCRYPT.equals(ui_encrypt) ||
EntityMessage.SMIME_SIGNENCRYPT.equals(ui_encrypt));
}
String[] checkFromDomain(Context context) { String[] checkFromDomain(Context context) {
return MessageHelper.equalDomain(context, from, smtp_from); return MessageHelper.equalDomain(context, from, smtp_from);
} }

@ -57,8 +57,6 @@ public class TupleMessageEx extends EntityMessage {
public int unseen; public int unseen;
public int unflagged; public int unflagged;
public int drafts; public int drafts;
public int signed;
public int encrypted;
public int visible; public int visible;
public int visible_unseen; public int visible_unseen;
public Long totalSize; public Long totalSize;
@ -163,8 +161,6 @@ public class TupleMessageEx extends EntityMessage {
this.unseen == other.unseen && this.unseen == other.unseen &&
this.unflagged == other.unflagged && this.unflagged == other.unflagged &&
this.drafts == other.drafts && this.drafts == other.drafts &&
this.signed == other.signed &&
this.encrypted == other.encrypted &&
this.visible == other.visible && this.visible == other.visible &&
this.visible_unseen == other.visible_unseen && this.visible_unseen == other.visible_unseen &&
Objects.equals(this.totalSize, other.totalSize) && Objects.equals(this.totalSize, other.totalSize) &&

@ -117,25 +117,27 @@
app:srcCompat="@drawable/importance" app:srcCompat="@drawable/importance"
app:tint="?attr/colorAccent" /> app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageView <eu.faircode.email.FixedImageButton
android:id="@+id/ivSigned" android:id="@+id/ibSigned"
android:layout_width="21dp" android:layout_width="21dp"
android:layout_height="21dp" android:layout_height="21dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_signed" android:contentDescription="@string/title_legend_signed"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivImportance" app:layout_constraintStart_toEndOf="@id/ivImportance"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_gesture_24" /> app:srcCompat="@drawable/twotone_gesture_24" />
<eu.faircode.email.FixedImageView <eu.faircode.email.FixedImageButton
android:id="@+id/ivEncrypted" android:id="@+id/ibEncrypted"
android:layout_width="21dp" android:layout_width="21dp"
android:layout_height="21dp" android:layout_height="21dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_encrypted" android:contentDescription="@string/title_legend_encrypted"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivSigned" app:layout_constraintStart_toEndOf="@id/ibSigned"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_lock_24" /> app:srcCompat="@drawable/twotone_lock_24" />
@ -152,7 +154,7 @@
android:text="From" android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/tvSize" app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintStart_toEndOf="@id/ivEncrypted" app:layout_constraintStart_toEndOf="@id/ibEncrypted"
app:layout_constraintTop_toBottomOf="@id/paddingTop" /> app:layout_constraintTop_toBottomOf="@id/paddingTop" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -116,25 +116,27 @@
app:srcCompat="@drawable/importance" app:srcCompat="@drawable/importance"
app:tint="?attr/colorAccent" /> app:tint="?attr/colorAccent" />
<eu.faircode.email.FixedImageView <eu.faircode.email.FixedImageButton
android:id="@+id/ivSigned" android:id="@+id/ibSigned"
android:layout_width="21dp" android:layout_width="21dp"
android:layout_height="21dp" android:layout_height="21dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_signed" android:contentDescription="@string/title_legend_signed"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivImportance" app:layout_constraintStart_toEndOf="@id/ivImportance"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_gesture_24" /> app:srcCompat="@drawable/twotone_gesture_24" />
<eu.faircode.email.FixedImageView <eu.faircode.email.FixedImageButton
android:id="@+id/ivEncrypted" android:id="@+id/ibEncrypted"
android:layout_width="21dp" android:layout_width="21dp"
android:layout_height="21dp" android:layout_height="21dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_encrypted" android:contentDescription="@string/title_legend_encrypted"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivSigned" app:layout_constraintStart_toEndOf="@id/ibSigned"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/twotone_lock_24" /> app:srcCompat="@drawable/twotone_lock_24" />
@ -149,7 +151,7 @@
android:text="From" android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/tvSize" app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintStart_toEndOf="@id/ivEncrypted" app:layout_constraintStart_toEndOf="@id/ibEncrypted"
app:layout_constraintTop_toBottomOf="@id/paddingTop" /> app:layout_constraintTop_toBottomOf="@id/paddingTop" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

Loading…
Cancel
Save