Optimization

pull/213/head
M66B 12 months ago
parent 9ca6034855
commit 224525d88e

@ -2276,38 +2276,25 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
long id = Log.getDebugInfo(context, "main", R.string.title_debug_info_remark, null, null, args).id;
if (send) {
boolean sent = false;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage draft = db.message().getMessage(id);
if (draft != null) {
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
Log.w("Outbox missing");
outbox = EntityFolder.getOutbox();
outbox.id = db.folder().insertFolder(outbox);
}
draft.folder = outbox.id;
draft.folder = EntityFolder.getOutbox(context).id;
db.message().updateMessage(draft);
EntityOperation.queue(context, draft, EntityOperation.SEND);
db.setTransactionSuccessful();
sent = true;
args.putBoolean("sent", true);
return null;
}
} finally {
db.endTransaction();
}
if (sent) {
ToastEx.makeText(context, R.string.title_debug_info_send, Toast.LENGTH_LONG).show();
ServiceSend.start(context);
return null;
}
}
return id;
@ -2315,6 +2302,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override
protected void onExecuted(Bundle args, Long id) {
boolean sent = args.getBoolean("sent");
if (sent) {
ToastEx.makeText(ActivityView.this, R.string.title_debug_info_send, Toast.LENGTH_LONG).show();
ServiceSend.start(ActivityView.this);
return;
}
if (id == null)
return;
startActivity(new Intent(ActivityView.this, ActivityCompose.class)

@ -397,13 +397,23 @@ public class EntityFolder extends EntityOrder implements Serializable {
return result;
}
static EntityFolder getOutbox() {
EntityFolder outbox = new EntityFolder();
@NonNull
static EntityFolder getOutbox(Context context) {
DB db = DB.getInstance(context);
EntityFolder outbox = db.folder().getOutbox();
if (outbox != null)
return outbox;
Log.w("Outbox missing");
outbox = new EntityFolder();
outbox.name = "OUTBOX";
outbox.type = EntityFolder.OUTBOX;
outbox.synchronize = false;
outbox.sync_days = 0;
outbox.keep_days = 0;
outbox.id = db.folder().insertFolder(outbox);
return outbox;
}

@ -1006,11 +1006,7 @@ public class EntityRule {
throw new IllegalArgumentException("Rule template not found name=" + rule.name);
}
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
outbox = EntityFolder.getOutbox();
outbox.id = db.folder().insertFolder(outbox);
}
EntityFolder outbox = EntityFolder.getOutbox(context);
Address[] from = new InternetAddress[]{new InternetAddress(identity.email, identity.name, StandardCharsets.UTF_8.name())};

@ -7120,12 +7120,7 @@ public class FragmentCompose extends FragmentBase {
}
} else if (action == R.id.action_send) {
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
Log.w("Outbox missing");
outbox = EntityFolder.getOutbox();
outbox.id = db.folder().insertFolder(outbox);
}
EntityFolder outbox = EntityFolder.getOutbox(context);
// Delay sending message
if (draft.ui_snoozed == null && send_delayed != 0) {

@ -903,11 +903,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
try {
db.beginTransaction();
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
outbox = EntityFolder.getOutbox();
outbox.id = db.folder().insertFolder(outbox);
}
EntityFolder.getOutbox(context);
db.setTransactionSuccessful();
} finally {

@ -287,11 +287,7 @@ public class ServiceExternal extends Service {
if (to == null || to.length == 0)
throw new IllegalArgumentException("No to recipients: " + toName);
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
outbox = EntityFolder.getOutbox();
outbox.id = db.folder().insertFolder(outbox);
}
EntityFolder outbox = EntityFolder.getOutbox(context);
Address[] from = new Address[]{
new InternetAddress(identity.get(0).email, identity.get(0).name, StandardCharsets.UTF_8.name())};

Loading…
Cancel
Save