Browse Source

Added message about downloading messages

main
M66B 6 years ago
parent
commit
9d0ca16713
2 changed files with 112 additions and 93 deletions
  1. +111
    -93
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +1
    -0
      app/src/main/res/values/strings.xml

+ 111
- 93
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -247,100 +247,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (savedInstanceState != null) if (savedInstanceState != null)
drawerToggle.setDrawerIndicatorEnabled(savedInstanceState.getBoolean("toggle")); drawerToggle.setDrawerIndicatorEnabled(savedInstanceState.getBoolean("toggle"));
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws Throwable {
File file = new File(context.getCacheDir(), "crash.log");
if (file.exists()) {
// Get version info
StringBuilder sb = new StringBuilder();
sb.append(context.getString(R.string.title_crash_info_remark) + "\n\n\n\n");
sb.append(String.format("%s: %s\r\n", context.getString(R.string.app_name), BuildConfig.VERSION_NAME));
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).append("\r\n");
} finally {
if (in != null)
in.close();
}
file.delete();
String body = "<pre>" + sb.toString().replaceAll("\\r?\\n", "<br />") + "</pre>";
EntityMessage draft = null;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityFolder drafts = db.folder().getPrimaryDrafts();
if (drafts != null) {
draft = new EntityMessage();
draft.account = drafts.account;
draft.folder = drafts.id;
draft.msgid = EntityMessage.generateMessageId();
draft.to = new Address[]{Helper.myAddress()};
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " crash log";
draft.content = true;
draft.received = new Date().getTime();
draft.seen = false;
draft.ui_seen = false;
draft.flagged = false;
draft.ui_flagged = false;
draft.ui_hide = false;
draft.ui_found = false;
draft.id = db.message().insertMessage(draft);
draft.write(context, body);
}
EntityOperation.queue(db, draft, EntityOperation.ADD);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
EntityOperation.process(context);
return (draft == null ? null : draft.id);
}
return null;
}
@Override
protected void onLoaded(Bundle args, Long id) {
if (id != null)
startActivity(
new Intent(ActivityView.this, ActivityCompose.class)
.putExtra("action", "edit")
.putExtra("id", id));
}
}.load(this, new Bundle());
checkFirst();
checkIntent(getIntent()); checkIntent(getIntent());
checkCrash();
if (!Helper.isPlayStoreInstall(this)) if (!Helper.isPlayStoreInstall(this))
checkUpdate(); checkUpdate();
} }
@ -433,6 +342,115 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
} }
private void checkFirst() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("first", true)) {
new AlertDialog.Builder(this)
.setMessage(getString(R.string.title_hint_sync))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.edit().putBoolean("first", false).apply();
}
})
.show();
}
}
private void checkCrash() {
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws Throwable {
File file = new File(context.getCacheDir(), "crash.log");
if (file.exists()) {
// Get version info
StringBuilder sb = new StringBuilder();
sb.append(context.getString(R.string.title_crash_info_remark) + "\n\n\n\n");
sb.append(String.format("%s: %s\r\n", context.getString(R.string.app_name), BuildConfig.VERSION_NAME));
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).append("\r\n");
} finally {
if (in != null)
in.close();
}
file.delete();
String body = "<pre>" + sb.toString().replaceAll("\\r?\\n", "<br />") + "</pre>";
EntityMessage draft = null;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityFolder drafts = db.folder().getPrimaryDrafts();
if (drafts != null) {
draft = new EntityMessage();
draft.account = drafts.account;
draft.folder = drafts.id;
draft.msgid = EntityMessage.generateMessageId();
draft.to = new Address[]{Helper.myAddress()};
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " crash log";
draft.content = true;
draft.received = new Date().getTime();
draft.seen = false;
draft.ui_seen = false;
draft.flagged = false;
draft.ui_flagged = false;
draft.ui_hide = false;
draft.ui_found = false;
draft.id = db.message().insertMessage(draft);
draft.write(context, body);
}
EntityOperation.queue(db, draft, EntityOperation.ADD);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
EntityOperation.process(context);
return (draft == null ? null : draft.id);
}
return null;
}
@Override
protected void onLoaded(Bundle args, Long id) {
if (id != null)
startActivity(
new Intent(ActivityView.this, ActivityCompose.class)
.putExtra("action", "edit")
.putExtra("id", id));
}
}.load(this, new Bundle());
}
private void checkIntent(Intent intent) { private void checkIntent(Intent intent) {
Log.i(Helper.TAG, "View intent=" + intent + " action=" + intent.getAction()); Log.i(Helper.TAG, "View intent=" + intent + " action=" + intent.getAction());
String action = intent.getAction(); String action = intent.getAction();


+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -248,6 +248,7 @@
<string name="title_hint_folder_actions">Long press for options</string> <string name="title_hint_folder_actions">Long press for options</string>
<string name="title_hint_support">If you have a question or a problem, please use the support menu to get help</string> <string name="title_hint_support">If you have a question or a problem, please use the support menu to get help</string>
<string name="title_hint_message_actions">Swipe left to trash; swipe right to archive (if available); long press to mark read/unread or to add/remove star</string> <string name="title_hint_message_actions">Swipe left to trash; swipe right to archive (if available); long press to mark read/unread or to add/remove star</string>
<string name="title_hint_sync">Downloading messages can take some time, depending on the number of messages, the speed of your internet connection and your email provider</string>
<string name="title_open_link">Open link</string> <string name="title_open_link">Open link</string>
<string name="title_updated">There is an update to version %1$s available</string> <string name="title_updated">There is an update to version %1$s available</string>


Loading…
Cancel
Save