|
|
@ -128,6 +128,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
private EditText etSubject;
|
|
|
|
private EditText etSubject;
|
|
|
|
private RecyclerView rvAttachment;
|
|
|
|
private RecyclerView rvAttachment;
|
|
|
|
private EditText etBody;
|
|
|
|
private EditText etBody;
|
|
|
|
|
|
|
|
private TextView tvSignature;
|
|
|
|
|
|
|
|
private TextView tvReference;
|
|
|
|
private BottomNavigationView edit_bar;
|
|
|
|
private BottomNavigationView edit_bar;
|
|
|
|
private BottomNavigationView bottom_navigation;
|
|
|
|
private BottomNavigationView bottom_navigation;
|
|
|
|
private ProgressBar pbWait;
|
|
|
|
private ProgressBar pbWait;
|
|
|
@ -135,14 +137,23 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
private Group grpExtra;
|
|
|
|
private Group grpExtra;
|
|
|
|
private Group grpAddresses;
|
|
|
|
private Group grpAddresses;
|
|
|
|
private Group grpAttachments;
|
|
|
|
private Group grpAttachments;
|
|
|
|
|
|
|
|
private Group grpSignature;
|
|
|
|
|
|
|
|
private Group grpReference;
|
|
|
|
|
|
|
|
|
|
|
|
private AdapterAttachment adapter;
|
|
|
|
private AdapterAttachment adapter;
|
|
|
|
|
|
|
|
|
|
|
|
private long working = -1;
|
|
|
|
private long working = -1;
|
|
|
|
private boolean autosave = false;
|
|
|
|
private boolean autosave = false;
|
|
|
|
|
|
|
|
private boolean pro = false;
|
|
|
|
|
|
|
|
|
|
|
|
private OpenPgpServiceConnection pgpService;
|
|
|
|
private OpenPgpServiceConnection pgpService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
pro = Helper.isPro(getContext());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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) {
|
|
|
@ -164,6 +175,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
etSubject = view.findViewById(R.id.etSubject);
|
|
|
|
etSubject = view.findViewById(R.id.etSubject);
|
|
|
|
rvAttachment = view.findViewById(R.id.rvAttachment);
|
|
|
|
rvAttachment = view.findViewById(R.id.rvAttachment);
|
|
|
|
etBody = view.findViewById(R.id.etBody);
|
|
|
|
etBody = view.findViewById(R.id.etBody);
|
|
|
|
|
|
|
|
tvSignature = view.findViewById(R.id.tvSignature);
|
|
|
|
|
|
|
|
tvReference = view.findViewById(R.id.tvReference);
|
|
|
|
edit_bar = view.findViewById(R.id.edit_bar);
|
|
|
|
edit_bar = view.findViewById(R.id.edit_bar);
|
|
|
|
bottom_navigation = view.findViewById(R.id.bottom_navigation);
|
|
|
|
bottom_navigation = view.findViewById(R.id.bottom_navigation);
|
|
|
|
pbWait = view.findViewById(R.id.pbWait);
|
|
|
|
pbWait = view.findViewById(R.id.pbWait);
|
|
|
@ -171,6 +184,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
grpExtra = view.findViewById(R.id.grpExtra);
|
|
|
|
grpExtra = view.findViewById(R.id.grpExtra);
|
|
|
|
grpAddresses = view.findViewById(R.id.grpAddresses);
|
|
|
|
grpAddresses = view.findViewById(R.id.grpAddresses);
|
|
|
|
grpAttachments = view.findViewById(R.id.grpAttachments);
|
|
|
|
grpAttachments = view.findViewById(R.id.grpAttachments);
|
|
|
|
|
|
|
|
grpSignature = view.findViewById(R.id.grpSignature);
|
|
|
|
|
|
|
|
grpReference = view.findViewById(R.id.grpReference);
|
|
|
|
|
|
|
|
|
|
|
|
// Wire controls
|
|
|
|
// Wire controls
|
|
|
|
spIdentity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
spIdentity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
@ -180,17 +195,9 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
int at = (identity == null ? -1 : identity.email.indexOf('@'));
|
|
|
|
int at = (identity == null ? -1 : identity.email.indexOf('@'));
|
|
|
|
tvExtraPrefix.setText(at < 0 ? null : identity.email.substring(0, at) + "+");
|
|
|
|
tvExtraPrefix.setText(at < 0 ? null : identity.email.substring(0, at) + "+");
|
|
|
|
tvExtraSuffix.setText(at < 0 ? null : identity.email.substring(at));
|
|
|
|
tvExtraSuffix.setText(at < 0 ? null : identity.email.substring(at));
|
|
|
|
|
|
|
|
if (pro) {
|
|
|
|
String signature = (identity == null ? null : identity.signature);
|
|
|
|
tvSignature.setText(identity == null ? null : Html.fromHtml(identity.signature));
|
|
|
|
if (TextUtils.isEmpty(signature))
|
|
|
|
grpSignature.setVisibility(identity == null || TextUtils.isEmpty(identity.signature) ? View.GONE : View.VISIBLE);
|
|
|
|
signature = "‌";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String html = Html.toHtml(etBody.getText());
|
|
|
|
|
|
|
|
int cstart = html.indexOf("<tt>");
|
|
|
|
|
|
|
|
int cend = html.lastIndexOf("</tt>");
|
|
|
|
|
|
|
|
if (cstart >= 0 && cend > cstart) {
|
|
|
|
|
|
|
|
html = html.substring(0, cstart + 4) + signature + html.substring(cend);
|
|
|
|
|
|
|
|
etBody.setText(Html.fromHtml(html));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -198,6 +205,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
tvExtraPrefix.setText(null);
|
|
|
|
tvExtraPrefix.setText(null);
|
|
|
|
tvExtraSuffix.setText(null);
|
|
|
|
tvExtraSuffix.setText(null);
|
|
|
|
|
|
|
|
tvSignature.setText(null);
|
|
|
|
|
|
|
|
grpSignature.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -298,6 +307,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
grpAddresses.setVisibility(View.GONE);
|
|
|
|
grpAddresses.setVisibility(View.GONE);
|
|
|
|
grpAttachments.setVisibility(View.GONE);
|
|
|
|
grpAttachments.setVisibility(View.GONE);
|
|
|
|
etBody.setVisibility(View.GONE);
|
|
|
|
etBody.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
grpSignature.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
grpReference.setVisibility(View.GONE);
|
|
|
|
edit_bar.setVisibility(View.GONE);
|
|
|
|
edit_bar.setVisibility(View.GONE);
|
|
|
|
bottom_navigation.setVisibility(View.GONE);
|
|
|
|
bottom_navigation.setVisibility(View.GONE);
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
@ -640,7 +651,7 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
Properties props = MessageHelper.getSessionProperties(Helper.AUTH_TYPE_PASSWORD, false);
|
|
|
|
Properties props = MessageHelper.getSessionProperties(Helper.AUTH_TYPE_PASSWORD, false);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
Session isession = Session.getInstance(props, null);
|
|
|
|
MimeMessage imessage = new MimeMessage(isession);
|
|
|
|
MimeMessage imessage = new MimeMessage(isession);
|
|
|
|
MessageHelper.build(context, message, attachments, imessage);
|
|
|
|
MessageHelper.build(context, message, imessage);
|
|
|
|
|
|
|
|
|
|
|
|
// Serialize message
|
|
|
|
// Serialize message
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
@ -918,6 +929,7 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
UnderlineSpan[] uspans = spannable.getSpans(0, spannable.length(), UnderlineSpan.class);
|
|
|
|
UnderlineSpan[] uspans = spannable.getSpans(0, spannable.length(), UnderlineSpan.class);
|
|
|
|
for (UnderlineSpan uspan : uspans)
|
|
|
|
for (UnderlineSpan uspan : uspans)
|
|
|
|
spannable.removeSpan(uspan);
|
|
|
|
spannable.removeSpan(uspan);
|
|
|
|
|
|
|
|
|
|
|
|
args.putString("body", Html.toHtml(spannable));
|
|
|
|
args.putString("body", Html.toHtml(spannable));
|
|
|
|
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Run load id=" + working);
|
|
|
|
Log.i(Helper.TAG, "Run load id=" + working);
|
|
|
@ -1026,7 +1038,6 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
boolean raw = args.getBoolean("raw", false);
|
|
|
|
boolean raw = args.getBoolean("raw", false);
|
|
|
|
long answer = args.getLong("answer", -1);
|
|
|
|
long answer = args.getLong("answer", -1);
|
|
|
|
boolean pro = Helper.isPro(getContext());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference);
|
|
|
|
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference);
|
|
|
|
|
|
|
|
|
|
|
@ -1140,9 +1151,6 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
body = "";
|
|
|
|
body = "";
|
|
|
|
else
|
|
|
|
else
|
|
|
|
body = body.replaceAll("\\r?\\n", "<br />");
|
|
|
|
body = body.replaceAll("\\r?\\n", "<br />");
|
|
|
|
|
|
|
|
|
|
|
|
if (pro)
|
|
|
|
|
|
|
|
body += "<p>‌</p><p><tt>‌</tt></p>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
result.draft.thread = ref.thread;
|
|
|
|
result.draft.thread = ref.thread;
|
|
|
|
|
|
|
|
|
|
|
@ -1170,28 +1178,14 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
//msg.replying = ref.id;
|
|
|
|
result.draft.forwarding = ref.id;
|
|
|
|
result.draft.from = ref.to;
|
|
|
|
result.draft.from = ref.to;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long time = (ref.sent == null ? ref.received : ref.sent);
|
|
|
|
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, ref.subject);
|
|
|
|
result.draft.subject = context.getString(R.string.title_subject_reply, ref.subject);
|
|
|
|
body = String.format("<p>%s %s:</p><blockquote>%s</blockquote>",
|
|
|
|
else if ("forward".equals(action))
|
|
|
|
Html.escapeHtml(new Date(time).toString()),
|
|
|
|
|
|
|
|
Html.escapeHtml(MessageHelper.getFormattedAddresses(result.draft.to, true)),
|
|
|
|
|
|
|
|
HtmlHelper.sanitize(ref.read(context)));
|
|
|
|
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
|
|
|
|
result.draft.subject = context.getString(R.string.title_subject_forward, ref.subject);
|
|
|
|
result.draft.subject = context.getString(R.string.title_subject_forward, ref.subject);
|
|
|
|
body = String.format("<p>%s %s:</p><blockquote>%s</blockquote>",
|
|
|
|
|
|
|
|
Html.escapeHtml(new Date(time).toString()),
|
|
|
|
|
|
|
|
Html.escapeHtml(MessageHelper.getFormattedAddresses(ref.from, true)),
|
|
|
|
|
|
|
|
HtmlHelper.sanitize(ref.read(context)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pro)
|
|
|
|
|
|
|
|
body = "<p><tt>‌</tt></p>" + body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (answer > 0 && ("reply".equals(action) || "reply_all".equals(action))) {
|
|
|
|
if (answer > 0 && ("reply".equals(action) || "reply_all".equals(action))) {
|
|
|
|
String text = db.answer().getAnswer(answer).text;
|
|
|
|
String text = db.answer().getAnswer(answer).text;
|
|
|
@ -1206,8 +1200,7 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
text = text.replace("$email$", email == null ? "" : email);
|
|
|
|
text = text.replace("$email$", email == null ? "" : email);
|
|
|
|
|
|
|
|
|
|
|
|
body = text + body;
|
|
|
|
body = text + body;
|
|
|
|
} else
|
|
|
|
}
|
|
|
|
body = "<p>‌</p>" + body;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result.draft.content = true;
|
|
|
|
result.draft.content = true;
|
|
|
@ -1302,22 +1295,36 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
etBody.setText(null);
|
|
|
|
etBody.setText(null);
|
|
|
|
|
|
|
|
|
|
|
|
Bundle a = new Bundle();
|
|
|
|
final Bundle a = new Bundle();
|
|
|
|
a.putLong("id", result.draft.id);
|
|
|
|
a.putLong("id", result.draft.id);
|
|
|
|
|
|
|
|
if (result.draft.replying != null)
|
|
|
|
|
|
|
|
a.putLong("reference", result.draft.replying);
|
|
|
|
|
|
|
|
else if (result.draft.forwarding != null)
|
|
|
|
|
|
|
|
a.putLong("reference", result.draft.forwarding);
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Spanned>() {
|
|
|
|
new SimpleTask<Spanned[]>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected Spanned onLoad(final Context context, Bundle args) throws Throwable {
|
|
|
|
protected Spanned[] onLoad(final Context context, Bundle args) throws Throwable {
|
|
|
|
final long id = args.getLong("id");
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
|
|
|
|
|
|
|
|
String body = EntityMessage.read(context, id);
|
|
|
|
String body = EntityMessage.read(context, id);
|
|
|
|
return Html.fromHtml(body, cidGetter, null);
|
|
|
|
String quote = (reference < 0 ? null : EntityMessage.getQuote(context, reference));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Spanned[]{
|
|
|
|
|
|
|
|
Html.fromHtml(body, cidGetter, null),
|
|
|
|
|
|
|
|
quote == null ? null : Html.fromHtml(quote)};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onLoaded(Bundle args, Spanned body) {
|
|
|
|
protected void onLoaded(Bundle args, Spanned[] texts) {
|
|
|
|
getActivity().invalidateOptionsMenu();
|
|
|
|
getActivity().invalidateOptionsMenu();
|
|
|
|
etBody.setText(body);
|
|
|
|
etBody.setText(texts[0]);
|
|
|
|
etBody.setSelection(0);
|
|
|
|
etBody.setSelection(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvReference.setText(texts[1]);
|
|
|
|
|
|
|
|
grpReference.setVisibility(texts[1] == null ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|