Browse Source

Improved debug info

main
M66B 6 years ago
parent
commit
03c944122f
4 changed files with 38 additions and 77 deletions
  1. +5
    -3
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +19
    -9
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  3. +0
    -64
      app/src/main/java/eu/faircode/email/MimeMessageEx.java
  4. +14
    -1
      app/src/main/res/layout/fragment_message.xml

+ 5
- 3
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -103,15 +103,17 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
ivAttachments.setVisibility(message.attachments > 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);


+ 19
- 9
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -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


+ 0
- 64
app/src/main/java/eu/faircode/email/MimeMessageEx.java View File

@ -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<String> 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;
}
}
}

+ 14
- 1
app/src/main/res/layout/fragment_message.xml View File

@ -161,6 +161,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
<TextView
android:id="@+id/tvError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="6dp"
android:text="error"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/top_navigation"
android:layout_width="match_parent"
@ -172,7 +185,7 @@
app:labelVisibilityMode="unlabeled"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment"
app:layout_constraintTop_toBottomOf="@id/tvError"
app:menu="@menu/action_view_top" />
<ScrollView


Loading…
Cancel
Save