|
|
@ -1463,9 +1463,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
return attachment;
|
|
|
|
return attachment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SimpleTask<DraftAccount> draftLoader = new SimpleTask<DraftAccount>() {
|
|
|
|
private SimpleTask<EntityMessage> draftLoader = new SimpleTask<EntityMessage>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected DraftAccount onExecute(Context context, Bundle args) throws IOException {
|
|
|
|
protected EntityMessage onExecute(Context context, Bundle args) throws IOException {
|
|
|
|
String action = args.getString("action");
|
|
|
|
String action = args.getString("action");
|
|
|
|
long id = args.getLong("id", -1);
|
|
|
|
long id = args.getLong("id", -1);
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
@ -1473,31 +1473,33 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Load draft action=" + action + " id=" + id + " reference=" + reference);
|
|
|
|
Log.i("Load draft action=" + action + " id=" + id + " reference=" + reference);
|
|
|
|
|
|
|
|
|
|
|
|
DraftAccount result = new DraftAccount();
|
|
|
|
EntityMessage draft;
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
db.beginTransaction();
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
result.draft = db.message().getMessage(id);
|
|
|
|
draft = db.message().getMessage(id);
|
|
|
|
if (result.draft == null || result.draft.ui_hide) {
|
|
|
|
if (draft == null || draft.ui_hide) {
|
|
|
|
// New draft
|
|
|
|
// New draft
|
|
|
|
if ("edit".equals(action))
|
|
|
|
if ("edit".equals(action))
|
|
|
|
throw new IllegalStateException("Draft not found hide=" + (result.draft != null));
|
|
|
|
throw new IllegalStateException("Draft not found hide=" + (draft != null));
|
|
|
|
|
|
|
|
|
|
|
|
List<TupleIdentityEx> identities = db.identity().getComposableIdentities();
|
|
|
|
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityFolder drafts;
|
|
|
|
EntityMessage ref = db.message().getMessage(reference);
|
|
|
|
EntityMessage ref = db.message().getMessage(reference);
|
|
|
|
if (ref == null) {
|
|
|
|
if (ref == null) {
|
|
|
|
long aid = args.getLong("account", -1);
|
|
|
|
long aid = args.getLong("account", -1);
|
|
|
|
if (aid < 0) {
|
|
|
|
drafts = (aid < 0
|
|
|
|
result.account = db.account().getPrimaryAccount();
|
|
|
|
? db.folder().getPrimaryDrafts()
|
|
|
|
if (result.account == null)
|
|
|
|
: db.folder().getFolderByType(aid, EntityFolder.DRAFTS));
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
|
|
|
|
if (drafts == null)
|
|
|
|
} else
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
|
|
|
|
result.account = db.account().getAccount(aid);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
result.account = db.account().getAccount(ref.account);
|
|
|
|
drafts = db.folder().getFolderByType(ref.account, EntityFolder.DRAFTS);
|
|
|
|
|
|
|
|
if (drafts == null)
|
|
|
|
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
|
|
|
|
|
|
|
|
|
|
|
|
// Reply to recipient, not to known self
|
|
|
|
// Reply to recipient, not to known self
|
|
|
|
if (ref.reply != null && ref.reply.length > 0) {
|
|
|
|
if (ref.reply != null && ref.reply.length > 0) {
|
|
|
@ -1536,45 +1538,38 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EntityFolder drafts;
|
|
|
|
|
|
|
|
drafts = db.folder().getFolderByType(result.account.id, EntityFolder.DRAFTS);
|
|
|
|
|
|
|
|
if (drafts == null)
|
|
|
|
|
|
|
|
drafts = db.folder().getPrimaryDrafts();
|
|
|
|
|
|
|
|
if (drafts == null)
|
|
|
|
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String body = "";
|
|
|
|
String body = "";
|
|
|
|
|
|
|
|
|
|
|
|
result.draft = new EntityMessage();
|
|
|
|
draft = new EntityMessage();
|
|
|
|
result.draft.account = result.account.id;
|
|
|
|
draft.account = drafts.account;
|
|
|
|
result.draft.folder = drafts.id;
|
|
|
|
draft.folder = drafts.id;
|
|
|
|
result.draft.msgid = EntityMessage.generateMessageId();
|
|
|
|
draft.msgid = EntityMessage.generateMessageId();
|
|
|
|
|
|
|
|
|
|
|
|
if (ref == null) {
|
|
|
|
if (ref == null) {
|
|
|
|
result.draft.thread = result.draft.msgid;
|
|
|
|
draft.thread = draft.msgid;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String to = args.getString("to");
|
|
|
|
String to = args.getString("to");
|
|
|
|
result.draft.to = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to));
|
|
|
|
draft.to = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to));
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String cc = args.getString("cc");
|
|
|
|
String cc = args.getString("cc");
|
|
|
|
result.draft.cc = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc));
|
|
|
|
draft.cc = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc));
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String bcc = args.getString("bcc");
|
|
|
|
String bcc = args.getString("bcc");
|
|
|
|
result.draft.bcc = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc));
|
|
|
|
draft.bcc = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc));
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
} catch (AddressException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result.draft.subject = args.getString("subject", "");
|
|
|
|
draft.subject = args.getString("subject", "");
|
|
|
|
body = args.getString("body", "");
|
|
|
|
body = args.getString("body", "");
|
|
|
|
body = body.replaceAll("\\r?\\n", "<br />");
|
|
|
|
body = body.replaceAll("\\r?\\n", "<br />");
|
|
|
|
|
|
|
|
|
|
|
@ -1582,11 +1577,11 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
body = EntityAnswer.getAnswerText(db, answer, null) + body;
|
|
|
|
body = EntityAnswer.getAnswerText(db, answer, null) + body;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ("reply".equals(action) || "reply_all".equals(action)) {
|
|
|
|
if ("reply".equals(action) || "reply_all".equals(action)) {
|
|
|
|
result.draft.references = (ref.references == null ? "" : ref.references + " ") + ref.msgid;
|
|
|
|
draft.references = (ref.references == null ? "" : ref.references + " ") + ref.msgid;
|
|
|
|
result.draft.inreplyto = ref.msgid;
|
|
|
|
draft.inreplyto = ref.msgid;
|
|
|
|
result.draft.thread = ref.thread;
|
|
|
|
draft.thread = ref.thread;
|
|
|
|
result.draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
|
|
|
|
draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
|
|
|
|
result.draft.from = ref.to;
|
|
|
|
draft.from = ref.to;
|
|
|
|
|
|
|
|
|
|
|
|
if ("reply_all".equals(action)) {
|
|
|
|
if ("reply_all".equals(action)) {
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
@ -1602,23 +1597,23 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
addresses.remove(address);
|
|
|
|
addresses.remove(address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.draft.cc = addresses.toArray(new Address[0]);
|
|
|
|
draft.cc = addresses.toArray(new Address[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
result.draft.thread = result.draft.msgid; // new thread
|
|
|
|
draft.thread = draft.msgid; // new thread
|
|
|
|
result.draft.from = ref.to;
|
|
|
|
draft.from = ref.to;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("reply".equals(action) || "reply_all".equals(action))
|
|
|
|
if ("reply".equals(action) || "reply_all".equals(action))
|
|
|
|
result.draft.subject = context.getString(R.string.title_subject_reply,
|
|
|
|
draft.subject = context.getString(R.string.title_subject_reply,
|
|
|
|
ref.subject == null ? "" : ref.subject);
|
|
|
|
ref.subject == null ? "" : ref.subject);
|
|
|
|
else if ("forward".equals(action))
|
|
|
|
else if ("forward".equals(action))
|
|
|
|
result.draft.subject = context.getString(R.string.title_subject_forward,
|
|
|
|
draft.subject = context.getString(R.string.title_subject_forward,
|
|
|
|
ref.subject == null ? "" : ref.subject);
|
|
|
|
ref.subject == null ? "" : ref.subject);
|
|
|
|
|
|
|
|
|
|
|
|
if (answer > 0 && ("reply".equals(action) || "reply_all".equals(action)))
|
|
|
|
if (answer > 0 && ("reply".equals(action) || "reply_all".equals(action)))
|
|
|
|
body = EntityAnswer.getAnswerText(db, answer, result.draft.to) + body;
|
|
|
|
body = EntityAnswer.getAnswerText(db, answer, draft.to) + body;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Select identity matching from address
|
|
|
|
// Select identity matching from address
|
|
|
@ -1630,15 +1625,15 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
String from = null;
|
|
|
|
String from = null;
|
|
|
|
if (iindex >= 0)
|
|
|
|
if (iindex >= 0)
|
|
|
|
from = Helper.canonicalAddress(((InternetAddress) result.draft.from[iindex]).getAddress());
|
|
|
|
from = Helper.canonicalAddress(((InternetAddress) draft.from[iindex]).getAddress());
|
|
|
|
for (EntityIdentity identity : identities) {
|
|
|
|
for (EntityIdentity identity : identities) {
|
|
|
|
String email = Helper.canonicalAddress(identity.email);
|
|
|
|
String email = Helper.canonicalAddress(identity.email);
|
|
|
|
if (email.equals(from)) {
|
|
|
|
if (email.equals(from)) {
|
|
|
|
result.draft.identity = identity.id;
|
|
|
|
draft.identity = identity.id;
|
|
|
|
result.draft.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
|
|
|
draft.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (identity.account.equals(result.draft.account)) {
|
|
|
|
if (identity.account.equals(draft.account)) {
|
|
|
|
icount++;
|
|
|
|
icount++;
|
|
|
|
if (identity.primary)
|
|
|
|
if (identity.primary)
|
|
|
|
primary = identity;
|
|
|
|
primary = identity;
|
|
|
@ -1646,31 +1641,31 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
first = identity;
|
|
|
|
first = identity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (result.draft.identity != null)
|
|
|
|
if (draft.identity != null)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
iindex++;
|
|
|
|
iindex++;
|
|
|
|
} while (iindex < (result.draft.from == null ? -1 : result.draft.from.length));
|
|
|
|
} while (iindex < (draft.from == null ? -1 : draft.from.length));
|
|
|
|
|
|
|
|
|
|
|
|
// Select identity
|
|
|
|
// Select identity
|
|
|
|
if (result.draft.identity == null) {
|
|
|
|
if (draft.identity == null) {
|
|
|
|
if (primary != null) {
|
|
|
|
if (primary != null) {
|
|
|
|
result.draft.identity = primary.id;
|
|
|
|
draft.identity = primary.id;
|
|
|
|
result.draft.from = new InternetAddress[]{new InternetAddress(primary.email, primary.name)};
|
|
|
|
draft.from = new InternetAddress[]{new InternetAddress(primary.email, primary.name)};
|
|
|
|
} else if (first != null && icount == 1) {
|
|
|
|
} else if (first != null && icount == 1) {
|
|
|
|
result.draft.identity = first.id;
|
|
|
|
draft.identity = first.id;
|
|
|
|
result.draft.from = new InternetAddress[]{new InternetAddress(first.email, first.name)};
|
|
|
|
draft.from = new InternetAddress[]{new InternetAddress(first.email, first.name)};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result.draft.sender = MessageHelper.getSortKey(result.draft.from);
|
|
|
|
draft.sender = MessageHelper.getSortKey(draft.from);
|
|
|
|
|
|
|
|
|
|
|
|
result.draft.received = new Date().getTime();
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
|
|
|
|
|
|
|
|
result.draft.id = db.message().insertMessage(result.draft);
|
|
|
|
draft.id = db.message().insertMessage(draft);
|
|
|
|
Helper.writeText(EntityMessage.getFile(context, result.draft.id), body);
|
|
|
|
Helper.writeText(EntityMessage.getFile(context, draft.id), body);
|
|
|
|
|
|
|
|
|
|
|
|
db.message().setMessageContent(result.draft.id, true, HtmlHelper.getPreview(body));
|
|
|
|
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body));
|
|
|
|
|
|
|
|
|
|
|
|
// Write reference text
|
|
|
|
// Write reference text
|
|
|
|
if (ref != null && ref.content) {
|
|
|
|
if (ref != null && ref.content) {
|
|
|
@ -1678,14 +1673,14 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
Html.escapeHtml(new Date(ref.received).toString()),
|
|
|
|
Html.escapeHtml(new Date(ref.received).toString()),
|
|
|
|
Html.escapeHtml(MessageHelper.formatAddresses(ref.from)),
|
|
|
|
Html.escapeHtml(MessageHelper.formatAddresses(ref.from)),
|
|
|
|
Helper.readText(EntityMessage.getFile(context, ref.id)));
|
|
|
|
Helper.readText(EntityMessage.getFile(context, ref.id)));
|
|
|
|
Helper.writeText(EntityMessage.getRefFile(context, result.draft.id), refBody);
|
|
|
|
Helper.writeText(EntityMessage.getRefFile(context, draft.id), refBody);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("new".equals(action)) {
|
|
|
|
if ("new".equals(action)) {
|
|
|
|
ArrayList<Uri> uris = args.getParcelableArrayList("attachments");
|
|
|
|
ArrayList<Uri> uris = args.getParcelableArrayList("attachments");
|
|
|
|
if (uris != null)
|
|
|
|
if (uris != null)
|
|
|
|
for (Uri uri : uris)
|
|
|
|
for (Uri uri : uris)
|
|
|
|
addAttachment(context, result.draft.id, uri, false);
|
|
|
|
addAttachment(context, draft.id, uri, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
int sequence = 0;
|
|
|
|
int sequence = 0;
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(ref.id);
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(ref.id);
|
|
|
@ -1694,7 +1689,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
("forward".equals(action) || attachment.isInline())) {
|
|
|
|
("forward".equals(action) || attachment.isInline())) {
|
|
|
|
long orig = attachment.id;
|
|
|
|
long orig = attachment.id;
|
|
|
|
attachment.id = null;
|
|
|
|
attachment.id = null;
|
|
|
|
attachment.message = result.draft.id;
|
|
|
|
attachment.message = draft.id;
|
|
|
|
attachment.sequence = ++sequence;
|
|
|
|
attachment.sequence = ++sequence;
|
|
|
|
attachment.id = db.attachment().insertAttachment(attachment);
|
|
|
|
attachment.id = db.attachment().insertAttachment(attachment);
|
|
|
|
|
|
|
|
|
|
|
@ -1704,21 +1699,18 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EntityOperation.queue(context, db, result.draft, EntityOperation.ADD);
|
|
|
|
EntityOperation.queue(context, db, draft, EntityOperation.ADD);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Existing draft
|
|
|
|
if (!draft.content) {
|
|
|
|
result.account = db.account().getAccount(result.draft.account);
|
|
|
|
if (draft.uid == null)
|
|
|
|
|
|
|
|
|
|
|
|
if (!result.draft.content) {
|
|
|
|
|
|
|
|
if (result.draft.uid == null)
|
|
|
|
|
|
|
|
throw new IllegalStateException("Draft without uid");
|
|
|
|
throw new IllegalStateException("Draft without uid");
|
|
|
|
EntityOperation.queue(context, db, result.draft, EntityOperation.BODY);
|
|
|
|
EntityOperation.queue(context, db, draft, EntityOperation.BODY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(result.draft.id);
|
|
|
|
List<EntityAttachment> attachments = db.attachment().getAttachments(draft.id);
|
|
|
|
for (EntityAttachment attachment : attachments)
|
|
|
|
for (EntityAttachment attachment : attachments)
|
|
|
|
if (!attachment.available)
|
|
|
|
if (!attachment.available)
|
|
|
|
EntityOperation.queue(context, db, result.draft, EntityOperation.ATTACHMENT, attachment.sequence);
|
|
|
|
EntityOperation.queue(context, db, draft, EntityOperation.ATTACHMENT, attachment.sequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
db.setTransactionSuccessful();
|
|
|
@ -1726,21 +1718,21 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
db.endTransaction();
|
|
|
|
db.endTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return draft;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onExecuted(Bundle args, final DraftAccount result) {
|
|
|
|
protected void onExecuted(Bundle args, final EntityMessage draft) {
|
|
|
|
working = result.draft.id;
|
|
|
|
working = draft.id;
|
|
|
|
|
|
|
|
|
|
|
|
final String action = getArguments().getString("action");
|
|
|
|
final String action = getArguments().getString("action");
|
|
|
|
Log.i("Loaded draft id=" + result.draft.id + " action=" + action);
|
|
|
|
Log.i("Loaded draft id=" + draft.id + " action=" + action);
|
|
|
|
|
|
|
|
|
|
|
|
etExtra.setText(result.draft.extra);
|
|
|
|
etExtra.setText(draft.extra);
|
|
|
|
etTo.setText(MessageHelper.formatAddressesCompose(result.draft.to));
|
|
|
|
etTo.setText(MessageHelper.formatAddressesCompose(draft.to));
|
|
|
|
etCc.setText(MessageHelper.formatAddressesCompose(result.draft.cc));
|
|
|
|
etCc.setText(MessageHelper.formatAddressesCompose(draft.cc));
|
|
|
|
etBcc.setText(MessageHelper.formatAddressesCompose(result.draft.bcc));
|
|
|
|
etBcc.setText(MessageHelper.formatAddressesCompose(draft.bcc));
|
|
|
|
etSubject.setText(result.draft.subject);
|
|
|
|
etSubject.setText(draft.subject);
|
|
|
|
|
|
|
|
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
etTo.setTag(reference < 0 ? "" : etTo.getText().toString());
|
|
|
|
etTo.setTag(reference < 0 ? "" : etTo.getText().toString());
|
|
|
@ -1758,7 +1750,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
|
|
|
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
List<TupleIdentityEx> identities = db.identity().getComposableIdentities();
|
|
|
|
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null);
|
|
|
|
if (identities == null)
|
|
|
|
if (identities == null)
|
|
|
|
identities = new ArrayList<>();
|
|
|
|
identities = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
@ -1789,9 +1781,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
spIdentity.setAdapter(adapter);
|
|
|
|
spIdentity.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
|
|
// Select identity
|
|
|
|
// Select identity
|
|
|
|
if (result.draft.identity != null)
|
|
|
|
if (draft.identity != null)
|
|
|
|
for (int pos = 0; pos < identities.size(); pos++) {
|
|
|
|
for (int pos = 0; pos < identities.size(); pos++) {
|
|
|
|
if (identities.get(pos).id.equals(result.draft.identity)) {
|
|
|
|
if (identities.get(pos).id.equals(draft.identity)) {
|
|
|
|
spIdentity.setSelection(pos);
|
|
|
|
spIdentity.setSelection(pos);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1806,7 +1798,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
|
|
|
|
|
|
|
|
db.attachment().liveAttachments(result.draft.id).observe(getViewLifecycleOwner(),
|
|
|
|
db.attachment().liveAttachments(draft.id).observe(getViewLifecycleOwner(),
|
|
|
|
new Observer<List<EntityAttachment>>() {
|
|
|
|
new Observer<List<EntityAttachment>>() {
|
|
|
|
private int last_available = 0;
|
|
|
|
private int last_available = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -1838,11 +1830,11 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
rvAttachment.setTag(downloading);
|
|
|
|
rvAttachment.setTag(downloading);
|
|
|
|
checkInternet();
|
|
|
|
checkInternet();
|
|
|
|
|
|
|
|
|
|
|
|
checkDraft(result.draft.id);
|
|
|
|
checkDraft(draft.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
db.message().liveMessage(result.draft.id).observe(getViewLifecycleOwner(), new Observer<EntityMessage>() {
|
|
|
|
db.message().liveMessage(draft.id).observe(getViewLifecycleOwner(), new Observer<EntityMessage>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onChanged(EntityMessage draft) {
|
|
|
|
public void onChanged(EntityMessage draft) {
|
|
|
|
// Draft was deleted
|
|
|
|
// Draft was deleted
|
|
|
@ -2451,11 +2443,6 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private class DraftAccount {
|
|
|
|
|
|
|
|
EntityMessage draft;
|
|
|
|
|
|
|
|
EntityAccount account;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class IdentityAdapter extends ArrayAdapter<TupleIdentityEx> {
|
|
|
|
public class IdentityAdapter extends ArrayAdapter<TupleIdentityEx> {
|
|
|
|
private Context context;
|
|
|
|
private Context context;
|
|
|
|
private List<TupleIdentityEx> identities;
|
|
|
|
private List<TupleIdentityEx> identities;
|
|
|
|