Create outbox on setup

To make sure the event listener is started
pull/12/merge
M66B 6 years ago
parent 222a16b963
commit 5f77582bec

@ -599,20 +599,9 @@ public class FragmentCompose extends Fragment {
if (draft.to == null && draft.cc == null && draft.bcc == null)
throw new MessagingException(getContext().getString(R.string.title_to_missing));
// Get outbox
EntityFolder outbox = folder.getOutbox();
if (outbox == null) {
outbox = new EntityFolder();
outbox.name = "OUTBOX";
outbox.type = EntityFolder.TYPE_OUTBOX;
outbox.synchronize = false;
outbox.after = 0;
outbox.id = folder.insertFolder(outbox);
}
// Build outgoing message
EntityMessage out = new EntityMessage();
out.folder = outbox.id;
out.folder = folder.getOutbox().id;
out.identity = draft.identity;
out.replying = draft.replying;
out.thread = draft.thread;

@ -37,6 +37,8 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class FragmentSetup extends Fragment {
private Button btnAccount;
@ -48,6 +50,8 @@ public class FragmentSetup extends Fragment {
private TextView tvIdentityDone;
private TextView tvPermissionsDone;
private ExecutorService executor = Executors.newCachedThreadPool();
private static final String[] permissions = new String[]{
Manifest.permission.READ_CONTACTS
};
@ -151,7 +155,7 @@ public class FragmentSetup extends Fragment {
tvIdentityDone.setVisibility(View.INVISIBLE);
tvPermissionsDone.setVisibility(View.INVISIBLE);
DB db = DB.getInstance(getContext());
final DB db = DB.getInstance(getContext());
db.account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
@Override
@ -173,6 +177,22 @@ public class FragmentSetup extends Fragment {
onRequestPermissionsResult(0, permissions, grantResults);
// Creat outbox
executor.submit(new Runnable() {
@Override
public void run() {
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {
outbox = new EntityFolder();
outbox.name = "OUTBOX";
outbox.type = EntityFolder.TYPE_OUTBOX;
outbox.synchronize = false;
outbox.after = 0;
outbox.id = db.folder().insertFolder(outbox);
}
}
});
return view;
}

Loading…
Cancel
Save