diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 22b93735..32818479 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -103,15 +103,17 @@ public class AdapterMessage extends PagedListAdapter 0 ? View.VISIBLE : View.GONE); tvSubject.setText(message.subject); - String extra = (debug ? (message.ui_hide ? "HIDDEN " : "") + message.uid + "/" + message.id + " " : ""); if (viewType == ViewType.FOLDER) { - tvCount.setText(extra + Integer.toString(message.count)); + tvCount.setText(Integer.toString(message.count)); tvCount.setVisibility(debug || message.count > 1 ? View.VISIBLE : View.GONE); } else { - tvCount.setText(extra + Helper.localizeFolderName(context, message.folderName)); + tvCount.setText(Helper.localizeFolderName(context, message.folderName)); tvCount.setVisibility(View.VISIBLE); } + if (debug) + message.error += (message.ui_hide ? " HIDDEN " : " ") + message.msgid + "/" + message.uid + "/" + message.id; + tvError.setText(message.error); tvError.setVisibility(message.error == null ? View.GONE : View.VISIBLE); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index ada4eb02..ffb4b717 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -70,14 +70,15 @@ import androidx.recyclerview.widget.RecyclerView; public class FragmentMessage extends FragmentEx { private boolean debug; - private TextView tvTime; private TextView tvFrom; + private TextView tvTime; + private TextView tvSubject; + private TextView tvCount; private TextView tvTo; private TextView tvCc; private TextView tvBcc; private RecyclerView rvAttachment; - private TextView tvSubject; - private TextView tvCount; + private TextView tvError; private BottomNavigationView top_navigation; private TextView tvBody; private BottomNavigationView bottom_navigation; @@ -103,13 +104,14 @@ public class FragmentMessage extends FragmentEx { // Get controls tvFrom = view.findViewById(R.id.tvFrom); + tvTime = view.findViewById(R.id.tvTime); + tvSubject = view.findViewById(R.id.tvSubject); + tvCount = view.findViewById(R.id.tvCount); tvTo = view.findViewById(R.id.tvTo); tvCc = view.findViewById(R.id.tvCc); tvBcc = view.findViewById(R.id.tvBcc); rvAttachment = view.findViewById(R.id.rvAttachment); - tvTime = view.findViewById(R.id.tvTime); - tvSubject = view.findViewById(R.id.tvSubject); - tvCount = view.findViewById(R.id.tvCount); + tvError = view.findViewById(R.id.tvError); top_navigation = view.findViewById(R.id.top_navigation); tvBody = view.findViewById(R.id.tvBody); bottom_navigation = view.findViewById(R.id.bottom_navigation); @@ -257,14 +259,16 @@ public class FragmentMessage extends FragmentEx { String extra = (debug ? (message.ui_hide ? "HIDDEN " : "") + message.uid + "/" + message.id + " " : ""); tvFrom.setText(message.from == null ? null : MessageHelper.getFormattedAddresses(message.from, true)); - tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true)); - tvCc.setText(message.cc == null ? null : MessageHelper.getFormattedAddresses(message.cc, true)); - tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true)); tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent))); tvSubject.setText(message.subject); + tvCount.setText(extra + Integer.toString(message.count)); tvCount.setVisibility(debug || message.count > 1 ? View.VISIBLE : View.GONE); + tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true)); + tvCc.setText(message.cc == null ? null : MessageHelper.getFormattedAddresses(message.cc, true)); + tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true)); + int typeface = (message.ui_seen ? Typeface.NORMAL : Typeface.BOLD); tvFrom.setTypeface(null, typeface); tvTime.setTypeface(null, typeface); @@ -286,6 +290,12 @@ public class FragmentMessage extends FragmentEx { } }); + if (debug) + message.error += (message.ui_hide ? " HIDDEN " : " ") + message.msgid + "/" + message.uid + "/" + message.id; + + tvError.setText(message.error); + tvError.setVisibility(message.error == null ? View.GONE : View.VISIBLE); + MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen); actionSeen.setIcon(message.ui_seen ? R.drawable.baseline_visibility_off_24 diff --git a/app/src/main/java/eu/faircode/email/MimeMessageEx.java b/app/src/main/java/eu/faircode/email/MimeMessageEx.java deleted file mode 100644 index 28c198a2..00000000 --- a/app/src/main/java/eu/faircode/email/MimeMessageEx.java +++ /dev/null @@ -1,64 +0,0 @@ -package eu.faircode.email; - -import android.text.TextUtils; -import android.util.Log; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; - -public class MimeMessageEx extends MimeMessage { - private long id = -1; - - public MimeMessageEx(Session session, long id) { - super(session); - this.id = id; - } - - @Override - protected void updateMessageID() throws MessagingException { - try { - StringBuffer sb = new StringBuffer(); - sb.append('<') - .append(id).append('.') - .append(BuildConfig.APPLICATION_ID).append('.') - .append(System.currentTimeMillis()).append('.') - .append("anonymous@localhost") - .append('>'); - - setHeader("Message-ID", sb.toString()); - Log.v(Helper.TAG, "Override Message-ID=" + sb.toString()); - } catch (Throwable ex) { - Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); - super.updateMessageID(); - } - } - - public static long getId(MimeMessage message) { - try { - String msgid = message.getMessageID(); - if (msgid == null) - return -1; - - List parts = new ArrayList<>(Arrays.asList(msgid.split("\\."))); - if (parts.size() < 1) - return -1; - - String part = parts.get(0); - parts.remove(0); - if (!TextUtils.join(".", parts).startsWith(BuildConfig.APPLICATION_ID)) - return -1; - - long id = Long.parseLong(part.substring(1)); - Log.v(Helper.TAG, "Parsed Message-ID=" + msgid + " id=" + id); - return id; - } catch (Throwable ex) { - Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); - return -1; - } - } -} diff --git a/app/src/main/res/layout/fragment_message.xml b/app/src/main/res/layout/fragment_message.xml index 18a87e20..f2a1ed97 100644 --- a/app/src/main/res/layout/fragment_message.xml +++ b/app/src/main/res/layout/fragment_message.xml @@ -161,6 +161,19 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" /> + +