1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 09:17:58 +00:00

Show message encryption status

This commit is contained in:
M66B 2019-11-17 12:16:06 +01:00
parent c60cccad2c
commit 80b23ce13d
6 changed files with 42 additions and 2 deletions

View file

@ -264,6 +264,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibAuth;
private ImageView ivPriorityHigh;
private ImageView ivPriorityLow;
private ImageView ivEncrypted;
private TextView tvFrom;
private TextView tvSize;
private TextView tvTime;
@ -382,6 +383,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth = itemView.findViewById(R.id.ibAuth);
ivPriorityHigh = itemView.findViewById(R.id.ivPriorityHigh);
ivPriorityLow = itemView.findViewById(R.id.ivPriorityLow);
ivEncrypted = itemView.findViewById(R.id.ivEncrypted);
tvFrom = itemView.findViewById(subject_top ? R.id.tvSubject : R.id.tvFrom);
tvSize = itemView.findViewById(R.id.tvSize);
tvTime = itemView.findViewById(R.id.tvTime);
@ -647,6 +649,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth.setVisibility(View.GONE);
ivPriorityHigh.setVisibility(View.GONE);
ivPriorityLow.setVisibility(View.GONE);
ivEncrypted.setVisibility(View.GONE);
tvFrom.setText(null);
tvSize.setText(null);
tvTime.setText(null);
@ -714,6 +717,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivPriorityHigh.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivPriorityLow.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivEncrypted.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvFrom.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvSize.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
tvTime.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -778,6 +782,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
ivPriorityHigh.setVisibility(EntityMessage.PRIORITIY_HIGH.equals(message.priority) ? View.VISIBLE : View.GONE);
ivPriorityLow.setVisibility(EntityMessage.PRIORITIY_LOW.equals(message.priority) ? View.VISIBLE : View.GONE);
ivEncrypted.setVisibility(message.encrypted > 0 ? View.VISIBLE : View.GONE);
tvFrom.setText(MessageHelper.formatAddresses(addresses, name_email, false));
tvFrom.setPaintFlags(tvFrom.getPaintFlags() & ~Paint.UNDERLINE_TEXT_FLAG);
tvSize.setText(message.totalSize == null ? null : Helper.humanReadableByteCount(message.totalSize, true));
@ -4047,6 +4052,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
Log.i("drafts changed id=" + next.id);
}
if (prev.encrypted != next.encrypted) {
same = false;
Log.i("encrypted changed id=" + next.id);
}
if (prev.visible != next.visible) {
same = false;
Log.i("visible changed id=" + next.id);

View file

@ -2172,6 +2172,8 @@ class Core {
attachment.message = message.id;
attachment.sequence = sequence++;
attachment.id = db.attachment().insertAttachment(attachment);
if (EntityAttachment.PGP_MESSAGE.equals(attachment.encryption))
db.message().setMessageEncrypt(message.id, true);
}
runRules(context, imessage, message, rules);

View file

@ -51,6 +51,7 @@ public interface DaoMessage {
", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" +
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
", SUM(message.encrypt IS NOT NULL) AS encrypted" +
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
", SUM(message.total) AS totalSize" +
", MAX(CASE WHEN" +
@ -100,6 +101,7 @@ public interface DaoMessage {
", SUM(1 - message.ui_seen) AS unseen" +
", SUM(1 - message.ui_flagged) AS unflagged" +
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
", SUM(message.encrypt IS NOT NULL) AS encrypted" +
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
", SUM(message.total) AS totalSize" +
", MAX(CASE WHEN folder.id = :folder THEN message.received ELSE 0 END) AS dummy" +
@ -143,6 +145,7 @@ public interface DaoMessage {
", 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 folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
", (message.encrypt IS NOT NULL) AS encrypted" +
", 1 AS visible" +
", message.total AS totalSize" +
" FROM message" +
@ -277,6 +280,7 @@ public interface DaoMessage {
", 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 folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
", (message.encrypt IS NOT NULL) AS encrypted" +
", 1 AS visible" +
", message.total AS totalSize" +
" FROM message" +
@ -310,6 +314,7 @@ public interface DaoMessage {
", 1 AS unseen" +
", 0 AS unflagged" +
", 0 AS drafts" +
", (message.encrypt IS NOT NULL) AS encrypted" +
", 1 AS visible" +
", message.total AS totalSize" +
" FROM message" +

View file

@ -45,6 +45,7 @@ public class TupleMessageEx extends EntityMessage {
public int unseen;
public int unflagged;
public int drafts;
public int encrypted;
public int visible;
public Long totalSize;
@ -78,6 +79,7 @@ public class TupleMessageEx extends EntityMessage {
this.unseen == other.unseen &&
this.unflagged == other.unflagged &&
this.drafts == other.drafts &&
this.encrypted == other.encrypted &&
this.visible == other.visible &&
Objects.equals(this.totalSize, other.totalSize) &&
this.duplicate == other.duplicate);

View file

@ -94,6 +94,17 @@
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_low_priority_24" />
<ImageView
android:id="@+id/ivEncrypted"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_priority_low"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivPriorityLow"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_lock_24" />
<TextView
android:id="@+id/tvFrom"
android:layout_width="0dp"
@ -107,7 +118,7 @@
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintStart_toEndOf="@id/ivPriorityLow"
app:layout_constraintStart_toEndOf="@id/ivEncrypted"
app:layout_constraintTop_toBottomOf="@id/paddingTop" />
<TextView

View file

@ -93,6 +93,17 @@
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_low_priority_24" />
<ImageView
android:id="@+id/ivEncrypted"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_priority_low"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivPriorityLow"
app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_lock_24" />
<TextView
android:id="@+id/tvFrom"
android:layout_width="0dp"
@ -104,7 +115,7 @@
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintStart_toEndOf="@id/ivPriorityLow"
app:layout_constraintStart_toEndOf="@id/ivEncrypted"
app:layout_constraintTop_toBottomOf="@id/paddingTop" />
<TextView