Fixed debug/crash info

This commit is contained in:
M66B 2018-08-09 07:00:20 +00:00
parent 3cfaeaa5fe
commit 7ea6ba1762
5 changed files with 21 additions and 18 deletions

View File

@ -44,7 +44,7 @@ public class ApplicationEx extends Application {
DB db = null; DB db = null;
try { try {
db = DB.getBlockingInstance(ApplicationEx.this); db = DB.getBlockingInstance(ApplicationEx.this);
EntityFolder drafts = db.folder().getLocalDrafts(); EntityFolder drafts = EntityFolder.getDrafts(ApplicationEx.this, db, -1);
if (drafts != null) { if (drafts != null) {
Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode"); Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode");

View File

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.content.Context;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -103,6 +105,21 @@ public class EntityFolder {
@NonNull @NonNull
public Integer after; // days public Integer after; // days
static EntityFolder getDrafts(Context context, DB db, long account) {
EntityFolder drafts = db.folder().getFolderByType(account, EntityFolder.TYPE_DRAFTS);
if (drafts == null)
drafts = db.folder().getLocalDrafts();
if (drafts == null) {
drafts = new EntityFolder();
drafts.name = context.getString(R.string.title_folder_local_drafts);
drafts.type = EntityFolder.TYPE_DRAFTS;
drafts.synchronize = false;
drafts.after = 0;
drafts.id = db.folder().insertFolder(drafts);
}
return drafts;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof EntityFolder) { if (obj instanceof EntityFolder) {

View File

@ -61,7 +61,7 @@ public class FragmentAbout extends FragmentEx {
public void run() { public void run() {
try { try {
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
EntityFolder drafts = db.folder().getLocalDrafts(); EntityFolder drafts = EntityFolder.getDrafts(getContext(), db, -1);
if (drafts != null) { if (drafts != null) {
StringBuilder info = Helper.getDebugInfo(); StringBuilder info = Helper.getDebugInfo();
info.insert(0, getString(R.string.title_debug_info_remark) + "\n\n\n\n"); info.insert(0, getString(R.string.title_debug_info_remark) + "\n\n\n\n");

View File

@ -517,17 +517,7 @@ public class FragmentCompose extends FragmentEx {
if (ident == null) if (ident == null)
throw new IllegalArgumentException(getContext().getString(R.string.title_from_missing)); throw new IllegalArgumentException(getContext().getString(R.string.title_from_missing));
EntityFolder drafts = db.folder().getFolderByType(ident.account, EntityFolder.TYPE_DRAFTS); EntityFolder drafts = EntityFolder.getDrafts(getContext(), db, ident.account);
if (drafts == null)
drafts = db.folder().getLocalDrafts();
if (drafts == null) {
drafts = new EntityFolder();
drafts.name = getContext().getString(R.string.title_folder_local_drafts);
drafts.type = EntityFolder.TYPE_DRAFTS;
drafts.synchronize = false;
drafts.after = 0;
db.folder().insertFolder(drafts);
}
long rid = args.getLong("rid", -1); long rid = args.getLong("rid", -1);
String thread = args.getString("thread"); String thread = args.getString("thread");

View File

@ -408,11 +408,7 @@ public class FragmentMessage extends FragmentEx {
try { try {
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
EntityMessage draft = db.message().getMessage(id); EntityMessage draft = db.message().getMessage(id);
EntityFolder drafts = db.folder().getFolderByType(draft.account, EntityFolder.TYPE_DRAFTS); EntityFolder drafts = EntityFolder.getDrafts(getContext(), db, draft.account);
if (drafts == null)
drafts = db.folder().getLocalDrafts();
if (drafts == null)
return;
draft.id = null; draft.id = null;
draft.folder = drafts.id; draft.folder = drafts.id;
draft.id = db.message().insertMessage(draft); draft.id = db.message().insertMessage(draft);