Browse Source

Create outbox on setup

To make sure the event listener is started
main
M66B 6 years ago
parent
commit
5f77582bec
2 changed files with 22 additions and 13 deletions
  1. +1
    -12
      app/src/main/java/eu/faircode/email/FragmentCompose.java
  2. +21
    -1
      app/src/main/java/eu/faircode/email/FragmentSetup.java

+ 1
- 12
app/src/main/java/eu/faircode/email/FragmentCompose.java View File

@ -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;


+ 21
- 1
app/src/main/java/eu/faircode/email/FragmentSetup.java View File

@ -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