|
|
@ -25,6 +25,7 @@ import android.content.Intent; |
|
|
|
import android.content.IntentFilter; |
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.LayoutInflater; |
|
|
@ -38,6 +39,9 @@ import android.widget.ListView; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileReader; |
|
|
|
import java.text.Collator; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
@ -45,6 +49,9 @@ import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
import javax.mail.Address; |
|
|
|
import javax.mail.internet.InternetAddress; |
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle; |
|
|
@ -60,20 +67,21 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack |
|
|
|
private ListView drawerList; |
|
|
|
private ActionBarDrawerToggle drawerToggle; |
|
|
|
|
|
|
|
static final int LOADER_ACCOUNT_CHECK = 1; |
|
|
|
static final int LOADER_ACCOUNT_PUT = 2; |
|
|
|
static final int LOADER_IDENTITY_PUT = 3; |
|
|
|
static final int LOADER_FOLDER_PUT = 4; |
|
|
|
static final int LOADER_MESSAGE_ACCOUNT = 5; |
|
|
|
static final int LOADER_MESSAGE_VIEW = 6; |
|
|
|
static final int LOADER_MESSAGE_SEEN = 7; |
|
|
|
static final int LOADER_MESSAGE_EDIT = 8; |
|
|
|
static final int LOADER_MESSAGE_SPAM = 9; |
|
|
|
static final int LOADER_MESSAGE_TRASH = 10; |
|
|
|
static final int LOADER_MESSAGE_MOVE = 11; |
|
|
|
static final int LOADER_MESSAGE_ARCHIVE = 12; |
|
|
|
static final int LOADER_SEEN_UNTIL = 13; |
|
|
|
static final int LOADER_DEBUG_INFO = 14; |
|
|
|
static final int LOADER_EXCEPTION = 1; |
|
|
|
static final int LOADER_ACCOUNT_CHECK = 2; |
|
|
|
static final int LOADER_ACCOUNT_PUT = 3; |
|
|
|
static final int LOADER_IDENTITY_PUT = 4; |
|
|
|
static final int LOADER_FOLDER_PUT = 5; |
|
|
|
static final int LOADER_MESSAGE_ACCOUNT = 6; |
|
|
|
static final int LOADER_MESSAGE_VIEW = 7; |
|
|
|
static final int LOADER_MESSAGE_SEEN = 8; |
|
|
|
static final int LOADER_MESSAGE_EDIT = 9; |
|
|
|
static final int LOADER_MESSAGE_SPAM = 10; |
|
|
|
static final int LOADER_MESSAGE_TRASH = 11; |
|
|
|
static final int LOADER_MESSAGE_MOVE = 12; |
|
|
|
static final int LOADER_MESSAGE_ARCHIVE = 13; |
|
|
|
static final int LOADER_SEEN_UNTIL = 14; |
|
|
|
static final int LOADER_DEBUG_INFO = 15; |
|
|
|
|
|
|
|
static final int REQUEST_VIEW = 1; |
|
|
|
static final int REQUEST_UNSEEN = 2; |
|
|
@ -173,6 +181,76 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack |
|
|
|
fragmentTransaction.commit(); |
|
|
|
} |
|
|
|
|
|
|
|
new SimpleLoader() { |
|
|
|
@Override |
|
|
|
public Object onLoad(Bundle args) throws Throwable { |
|
|
|
File file = new File(getCacheDir(), "crash.log"); |
|
|
|
if (file.exists()) { |
|
|
|
DB db = DB.getInstance(ActivityView.this); |
|
|
|
EntityFolder drafts = db.folder().getPrimaryDrafts(); |
|
|
|
if (drafts != null) { |
|
|
|
Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode"); |
|
|
|
|
|
|
|
// Get version info |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
sb.append(String.format("%s: %s/%d\r\n", BuildConfig.APPLICATION_ID, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); |
|
|
|
sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT)); |
|
|
|
sb.append("\r\n"); |
|
|
|
|
|
|
|
// Get device info |
|
|
|
sb.append(String.format("Brand: %s\r\n", Build.BRAND)); |
|
|
|
sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER)); |
|
|
|
sb.append(String.format("Model: %s\r\n", Build.MODEL)); |
|
|
|
sb.append(String.format("Product: %s\r\n", Build.PRODUCT)); |
|
|
|
sb.append(String.format("Device: %s\r\n", Build.DEVICE)); |
|
|
|
sb.append(String.format("Host: %s\r\n", Build.HOST)); |
|
|
|
sb.append(String.format("Display: %s\r\n", Build.DISPLAY)); |
|
|
|
sb.append(String.format("Id: %s\r\n", Build.ID)); |
|
|
|
sb.append("\r\n"); |
|
|
|
|
|
|
|
BufferedReader in = null; |
|
|
|
try { |
|
|
|
String line; |
|
|
|
in = new BufferedReader(new FileReader(file)); |
|
|
|
while ((line = in.readLine()) != null) |
|
|
|
sb.append(line); |
|
|
|
} finally { |
|
|
|
if (in != null) |
|
|
|
in.close(); |
|
|
|
} |
|
|
|
|
|
|
|
EntityMessage draft = new EntityMessage(); |
|
|
|
draft.account = drafts.account; |
|
|
|
draft.folder = drafts.id; |
|
|
|
draft.to = new Address[]{to}; |
|
|
|
draft.subject = getString(R.string.app_name) + " crash log"; |
|
|
|
draft.body = "<pre>" + sb.toString().replaceAll("\\r?\\n", "<br />") + "</pre>"; |
|
|
|
draft.received = new Date().getTime(); |
|
|
|
draft.seen = false; |
|
|
|
draft.ui_seen = false; |
|
|
|
draft.ui_hide = false; |
|
|
|
draft.id = db.message().insertMessage(draft); |
|
|
|
|
|
|
|
file.delete(); |
|
|
|
|
|
|
|
return draft.id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLoaded(Bundle args, Result result) { |
|
|
|
if (result.ex == null && result.data != null) |
|
|
|
startActivity( |
|
|
|
new Intent(ActivityView.this, ActivityCompose.class) |
|
|
|
.putExtra("action", "edit") |
|
|
|
.putExtra("id", (Long) result.data)); |
|
|
|
|
|
|
|
} |
|
|
|
}.load(this, LOADER_EXCEPTION, new Bundle()); |
|
|
|
|
|
|
|
checkIntent(getIntent()); |
|
|
|
} |
|
|
|
|
|
|
|