mirror of https://github.com/M66B/FairEmail.git
Create outbox on setup
To make sure the event listener is started
This commit is contained in:
parent
222a16b963
commit
5f77582bec
|
@ -599,20 +599,9 @@ public class FragmentCompose extends Fragment {
|
||||||
if (draft.to == null && draft.cc == null && draft.bcc == null)
|
if (draft.to == null && draft.cc == null && draft.bcc == null)
|
||||||
throw new MessagingException(getContext().getString(R.string.title_to_missing));
|
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
|
// Build outgoing message
|
||||||
EntityMessage out = new EntityMessage();
|
EntityMessage out = new EntityMessage();
|
||||||
out.folder = outbox.id;
|
out.folder = folder.getOutbox().id;
|
||||||
out.identity = draft.identity;
|
out.identity = draft.identity;
|
||||||
out.replying = draft.replying;
|
out.replying = draft.replying;
|
||||||
out.thread = draft.thread;
|
out.thread = draft.thread;
|
||||||
|
|
|
@ -37,6 +37,8 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class FragmentSetup extends Fragment {
|
public class FragmentSetup extends Fragment {
|
||||||
private Button btnAccount;
|
private Button btnAccount;
|
||||||
|
@ -48,6 +50,8 @@ public class FragmentSetup extends Fragment {
|
||||||
private TextView tvIdentityDone;
|
private TextView tvIdentityDone;
|
||||||
private TextView tvPermissionsDone;
|
private TextView tvPermissionsDone;
|
||||||
|
|
||||||
|
private ExecutorService executor = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
private static final String[] permissions = new String[]{
|
private static final String[] permissions = new String[]{
|
||||||
Manifest.permission.READ_CONTACTS
|
Manifest.permission.READ_CONTACTS
|
||||||
};
|
};
|
||||||
|
@ -151,7 +155,7 @@ public class FragmentSetup extends Fragment {
|
||||||
tvIdentityDone.setVisibility(View.INVISIBLE);
|
tvIdentityDone.setVisibility(View.INVISIBLE);
|
||||||
tvPermissionsDone.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>>() {
|
db.account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,6 +177,22 @@ public class FragmentSetup extends Fragment {
|
||||||
|
|
||||||
onRequestPermissionsResult(0, permissions, grantResults);
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue