|
@ -136,8 +136,7 @@ public class FragmentCompose extends FragmentEx { |
|
|
@Override |
|
|
@Override |
|
|
@Nullable |
|
|
@Nullable |
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
|
setSubtitle(R.string.title_compose); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTitle(R.string.title_compose); |
|
|
view = (ViewGroup) inflater.inflate(R.layout.fragment_compose, container, false); |
|
|
view = (ViewGroup) inflater.inflate(R.layout.fragment_compose, container, false); |
|
|
|
|
|
|
|
|
// Get controls |
|
|
// Get controls |
|
@ -962,9 +961,10 @@ public class FragmentCompose extends FragmentEx { |
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference); |
|
|
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference); |
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context); |
|
|
EntityMessage draft; |
|
|
EntityMessage draft; |
|
|
|
|
|
EntityAccount account; |
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context); |
|
|
|
|
|
try { |
|
|
try { |
|
|
db.beginTransaction(); |
|
|
db.beginTransaction(); |
|
|
|
|
|
|
|
@ -972,10 +972,14 @@ public class FragmentCompose extends FragmentEx { |
|
|
if (draft == null || draft.ui_hide) { |
|
|
if (draft == null || draft.ui_hide) { |
|
|
if ("edit".equals(action)) |
|
|
if ("edit".equals(action)) |
|
|
throw new IllegalStateException("Message to edit not found"); |
|
|
throw new IllegalStateException("Message to edit not found"); |
|
|
} else |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (draft.account_name == null) { |
|
|
|
|
|
account = db.account().getAccount(draft.account); |
|
|
|
|
|
draft.account_name = account.name; |
|
|
|
|
|
} |
|
|
return draft; |
|
|
return draft; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
EntityAccount account; |
|
|
|
|
|
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); |
|
@ -983,8 +987,9 @@ public class FragmentCompose extends FragmentEx { |
|
|
account = db.account().getPrimaryAccount(); |
|
|
account = db.account().getPrimaryAccount(); |
|
|
if (account == null) |
|
|
if (account == null) |
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_account)); |
|
|
throw new IllegalArgumentException(context.getString(R.string.title_no_account)); |
|
|
} else |
|
|
|
|
|
|
|
|
} else { |
|
|
account = db.account().getAccount(aid); |
|
|
account = db.account().getAccount(aid); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
account = db.account().getAccount(ref.account); |
|
|
account = db.account().getAccount(ref.account); |
|
|
|
|
|
|
|
@ -1038,6 +1043,7 @@ public class FragmentCompose extends FragmentEx { |
|
|
|
|
|
|
|
|
draft = new EntityMessage(); |
|
|
draft = new EntityMessage(); |
|
|
draft.account = account.id; |
|
|
draft.account = account.id; |
|
|
|
|
|
draft.account_name = account.name; |
|
|
draft.folder = drafts.id; |
|
|
draft.folder = drafts.id; |
|
|
draft.msgid = EntityMessage.generateMessageId(); |
|
|
draft.msgid = EntityMessage.generateMessageId(); |
|
|
|
|
|
|
|
@ -1203,6 +1209,8 @@ public class FragmentCompose extends FragmentEx { |
|
|
final String action = getArguments().getString("action"); |
|
|
final String action = getArguments().getString("action"); |
|
|
Log.i(Helper.TAG, "Loaded draft id=" + draft.id + " action=" + action); |
|
|
Log.i(Helper.TAG, "Loaded draft id=" + draft.id + " action=" + action); |
|
|
|
|
|
|
|
|
|
|
|
setSubtitle(draft.account_name); |
|
|
|
|
|
|
|
|
etTo.setText(MessageHelper.getFormattedAddresses(draft.to, true)); |
|
|
etTo.setText(MessageHelper.getFormattedAddresses(draft.to, true)); |
|
|
etCc.setText(MessageHelper.getFormattedAddresses(draft.cc, true)); |
|
|
etCc.setText(MessageHelper.getFormattedAddresses(draft.cc, true)); |
|
|
etBcc.setText(MessageHelper.getFormattedAddresses(draft.bcc, true)); |
|
|
etBcc.setText(MessageHelper.getFormattedAddresses(draft.bcc, true)); |
|
|