From c56fa6fe0d702fd6f5ed1dd98acfb7d52a2706f7 Mon Sep 17 00:00:00 2001 From: str4d Date: Thu, 12 Jun 2014 04:23:09 +0000 Subject: [PATCH] Quote subject and content when replying to emails --- res/values/strings.xml | 5 ++++ src/i2p/bote/android/NewEmailFragment.java | 27 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 4d53bcc..8cb579c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -71,6 +71,11 @@ Add at least one recipient. Email queued for sending + Re: + Re: + %s wrote: + %s wrote: + Address book is empty New contact diff --git a/src/i2p/bote/android/NewEmailFragment.java b/src/i2p/bote/android/NewEmailFragment.java index cf6ccc3..22e524a 100644 --- a/src/i2p/bote/android/NewEmailFragment.java +++ b/src/i2p/bote/android/NewEmailFragment.java @@ -108,6 +108,9 @@ public class NewEmailFragment extends Fragment { String quoteMsgId = getArguments().getString(QUOTE_MSG_ID); Email origEmail = null; String recipientAddr = null; + String origSubject = null; + String origContent = null; + String origFrom = null; try { origEmail = BoteHelper.getEmail(quoteMsgFolder, quoteMsgId); if (origEmail != null) { @@ -115,6 +118,9 @@ public class NewEmailFragment extends Fragment { BoteHelper.getOneLocalRecipient(origEmail).toString()); recipientAddr = BoteHelper.getNameAndDestination( origEmail.getReplyAddress(I2PBote.getInstance().getIdentities())); + origSubject = origEmail.getSubject(); + origContent = origEmail.getText(); + origFrom = BoteHelper.getShortSenderName(origEmail.getOneFromAddress(), 50); } } catch (PasswordException e) { // TODO Auto-generated catch block @@ -168,6 +174,27 @@ public class NewEmailFragment extends Fragment { mSubject = (EditText) view.findViewById(R.id.subject); mContent = (EditText) view.findViewById(R.id.message); + boolean hide = I2PBote.getInstance().getConfiguration().getHideLocale(); + if (origSubject != null) { + String responsePrefix = getResources().getString( + hide ? R.string.response_prefix_re_hide + : R.string.response_prefix_re); + if (!origSubject.startsWith(responsePrefix)) + origSubject = responsePrefix + " " + origSubject; + mSubject.setText(origSubject); + } + if (origContent != null) { + StringBuilder quotation = new StringBuilder(); + quotation.append("\n\n"); + quotation.append(getResources().getString( + hide ? R.string.response_quote_wrote + : R.string.response_quote_wrote_hide, + origFrom)); + String[] lines = origContent.split("\r?\n|\r"); + for (String line: lines) + quotation = quotation.append("\n> ").append(line); + mContent.setText(quotation); + } if (savedInstanceState == null) { mRecipients.setPrefix(getResources().getString(R.string.email_to) + " ");