From a80c544df6077097dc5515cfc2cb0bb88f817cbf Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 27 Dec 2014 13:46:19 +0000 Subject: [PATCH] Add support for Cc: and Bcc: --- TODO | 1 - .../i2p/bote/android/NewEmailFragment.java | 67 ++++++++++++++---- .../i2p/bote/android/ViewEmailFragment.java | 34 +++++++-- .../ic_unfold_less_grey600_24dp.png | Bin 0 -> 331 bytes .../ic_unfold_more_grey600_24dp.png | Bin 0 -> 321 bytes .../ic_unfold_less_grey600_24dp.png | Bin 0 -> 272 bytes .../ic_unfold_more_grey600_24dp.png | Bin 0 -> 267 bytes .../ic_unfold_less_grey600_24dp.png | Bin 0 -> 394 bytes .../ic_unfold_more_grey600_24dp.png | Bin 0 -> 399 bytes .../ic_unfold_less_grey600_24dp.png | Bin 0 -> 504 bytes .../ic_unfold_more_grey600_24dp.png | Bin 0 -> 469 bytes .../main/res/layout/fragment_new_email.xml | 50 ++++++++++--- .../main/res/layout/fragment_view_email.xml | 46 +++++++++++- app/src/main/res/values/strings.xml | 2 + 14 files changed, 169 insertions(+), 31 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_unfold_less_grey600_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/ic_unfold_more_grey600_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_unfold_less_grey600_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_unfold_more_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_unfold_less_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_unfold_more_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_unfold_less_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_unfold_more_grey600_24dp.png diff --git a/TODO b/TODO index 3a731a9..2b6297e 100644 --- a/TODO +++ b/TODO @@ -19,7 +19,6 @@ Features: - Fingerprints that users can compare to validate - Public address book lookup - "Write email" link in address book -- Add optional CC: and BCC: fields - Attachments - "Empty trash" option in Trash folder - Overlay to explain diff --git a/app/src/main/java/i2p/bote/android/NewEmailFragment.java b/app/src/main/java/i2p/bote/android/NewEmailFragment.java index 109d8f0..0baf19f 100644 --- a/app/src/main/java/i2p/bote/android/NewEmailFragment.java +++ b/app/src/main/java/i2p/bote/android/NewEmailFragment.java @@ -94,9 +94,13 @@ public class NewEmailFragment extends Fragment { Spinner mSpinner; int mDefaultPos; ArrayAdapter mAdapter; - ContactsCompletionView mRecipients; + ImageView mMore; + ContactsCompletionView mTo; + ContactsCompletionView mCc; + ContactsCompletionView mBcc; EditText mSubject; EditText mContent; + boolean mMoreVisible; boolean mDirty; public static NewEmailFragment newInstance(String quoteMsgFolder, String quoteMsgId, @@ -127,7 +131,10 @@ public class NewEmailFragment extends Fragment { super.onViewCreated(view, savedInstanceState); mSpinner = (Spinner) view.findViewById(R.id.sender_spinner); - mRecipients = (ContactsCompletionView) view.findViewById(R.id.recipients); + mMore = (ImageView) view.findViewById(R.id.more); + mTo = (ContactsCompletionView) view.findViewById(R.id.to); + mCc = (ContactsCompletionView) view.findViewById(R.id.cc); + mBcc = (ContactsCompletionView) view.findViewById(R.id.bcc); mSubject = (EditText) view.findViewById(R.id.subject); mContent = (EditText) view.findViewById(R.id.message); @@ -136,7 +143,8 @@ public class NewEmailFragment extends Fragment { QuoteMsgType quoteMsgType = (QuoteMsgType) getArguments().getSerializable(QUOTE_MSG_TYPE); boolean hide = I2PBote.getInstance().getConfiguration().getHideLocale(); - List recipients = new ArrayList(); + List toRecipients = new ArrayList(); + List ccRecipients = new ArrayList(); String origSubject = null; String origContent = null; String origFrom = null; @@ -150,14 +158,15 @@ public class NewEmailFragment extends Fragment { if (quoteMsgType == QuoteMsgType.REPLY) { String recipient = BoteHelper.getNameAndDestination( origEmail.getReplyAddress(I2PBote.getInstance().getIdentities())); - recipients.add(extractPerson(recipient)); + toRecipients.add(extractPerson(recipient)); } else if (quoteMsgType == QuoteMsgType.REPLY_ALL) { + // TODO split between To and Cc // TODO don't include our address // What happens if an email is received by multiple local identities? for (Address address : origEmail.getAllAddresses(true)) { Person person = extractPerson(address.toString()); if (person != null) - recipients.add(person); + toRecipients.add(person); } } @@ -184,6 +193,19 @@ public class NewEmailFragment extends Fragment { mSpinner.setAdapter(identities); mSpinner.setSelection(mDefaultPos); + // Set up Cc/Bcc button + mMore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mCc.setVisibility(mMoreVisible ? View.GONE : View.VISIBLE); + mBcc.setVisibility(mMoreVisible ? View.GONE : View.VISIBLE); + mMore.setImageResource(mMoreVisible ? + R.drawable.ic_unfold_more_grey600_24dp : + R.drawable.ic_unfold_less_grey600_24dp); + mMoreVisible = !mMoreVisible; + } + }); + // Set up contacts auto-complete List contacts = new ArrayList(); try { @@ -227,9 +249,14 @@ public class NewEmailFragment extends Fragment { } }; - mRecipients.setAdapter(mAdapter); - for (Person recipient : recipients) { - mRecipients.addObject(recipient); + mTo.setAdapter(mAdapter); + mCc.setAdapter(mAdapter); + mBcc.setAdapter(mAdapter); + for (Person recipient : toRecipients) { + mTo.addObject(recipient); + } + for (Person recipient : ccRecipients) { + mCc.addObject(recipient); } if (origSubject != null) { @@ -261,7 +288,9 @@ public class NewEmailFragment extends Fragment { } if (savedInstanceState == null) { - mRecipients.setPrefix(getResources().getString(R.string.email_to) + " "); + mTo.setPrefix(getResources().getString(R.string.email_to) + " "); + mCc.setPrefix(getResources().getString(R.string.email_cc) + " "); + mBcc.setPrefix(getResources().getString(R.string.email_bcc) + " "); } TextWatcher dirtyWatcher = new TextWatcher() { @@ -373,21 +402,33 @@ public class NewEmailFragment extends Fragment { // Bote versions to see a sender (and validate the signature). email.setSender(ia); - for (Object obj : mRecipients.getObjects()) { + for (Object obj : mTo.getObjects()) { Person person = (Person) obj; email.addRecipient(Message.RecipientType.TO, new InternetAddress( person.getAddress(), person.getName())); } + if (mMoreVisible) { + for (Object obj : mCc.getObjects()) { + Person person = (Person) obj; + email.addRecipient(Message.RecipientType.CC, new InternetAddress( + person.getAddress(), person.getName())); + } + for (Object obj : mBcc.getObjects()) { + Person person = (Person) obj; + email.addRecipient(Message.RecipientType.BCC, new InternetAddress( + person.getAddress(), person.getName())); + } + } // Check that we have someone to send to Address[] rcpts = email.getAllRecipients(); if (rcpts == null || rcpts.length == 0) { // No recipients - mRecipients.setError(getActivity().getString(R.string.add_one_recipient)); - mRecipients.requestFocus(); + mTo.setError(getActivity().getString(R.string.add_one_recipient)); + mTo.requestFocus(); return false; } else { - mRecipients.setError(null); + mTo.setError(null); } email.setSubject(mSubject.getText().toString(), "UTF-8"); diff --git a/app/src/main/java/i2p/bote/android/ViewEmailFragment.java b/app/src/main/java/i2p/bote/android/ViewEmailFragment.java index e45eed3..8c1b2ad 100644 --- a/app/src/main/java/i2p/bote/android/ViewEmailFragment.java +++ b/app/src/main/java/i2p/bote/android/ViewEmailFragment.java @@ -80,7 +80,7 @@ public class ViewEmailFragment extends Fragment { TextView subject = (TextView) v.findViewById(R.id.email_subject); ImageView picture = (ImageView) v.findViewById(R.id.picture); TextView sender = (TextView) v.findViewById(R.id.email_sender); - LinearLayout recipients = (LinearLayout) v.findViewById(R.id.email_recipients); + LinearLayout toRecipients = (LinearLayout) v.findViewById(R.id.email_to); TextView sent = (TextView) v.findViewById(R.id.email_sent); TextView received = (TextView) v.findViewById(R.id.email_received); TextView content = (TextView) v.findViewById(R.id.email_content); @@ -114,13 +114,37 @@ public class ViewEmailFragment extends Fragment { if (email.isAnonymous() && !BoteHelper.isSentEmail(email)) sender.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); - Address[] emailRecipients = email.getToAddresses(); - if (emailRecipients != null) { - for (Address recipient : emailRecipients) { + Address[] emailToRecipients = email.getToAddresses(); + if (emailToRecipients != null) { + for (Address recipient : emailToRecipients) { TextView tv = new TextView(getActivity()); tv.setText(BoteHelper.getDisplayAddress(recipient.toString())); tv.setTextAppearance(getActivity(), R.style.TextAppearance_AppCompat_Secondary); - recipients.addView(tv); + toRecipients.addView(tv); + } + } + + Address[] emailCcRecipients = email.getCCAddresses(); + if (emailCcRecipients != null) { + v.findViewById(R.id.email_cc_row).setVisibility(View.VISIBLE); + LinearLayout ccRecipients = (LinearLayout) v.findViewById(R.id.email_cc); + for (Address recipient : emailCcRecipients) { + TextView tv = new TextView(getActivity()); + tv.setText(BoteHelper.getDisplayAddress(recipient.toString())); + tv.setTextAppearance(getActivity(), R.style.TextAppearance_AppCompat_Secondary); + ccRecipients.addView(tv); + } + } + + Address[] emailBccRecipients = email.getBCCAddresses(); + if (emailBccRecipients != null) { + v.findViewById(R.id.email_bcc_row).setVisibility(View.VISIBLE); + LinearLayout bccRecipients = (LinearLayout) v.findViewById(R.id.email_bcc); + for (Address recipient : emailBccRecipients) { + TextView tv = new TextView(getActivity()); + tv.setText(BoteHelper.getDisplayAddress(recipient.toString())); + tv.setTextAppearance(getActivity(), R.style.TextAppearance_AppCompat_Secondary); + bccRecipients.addView(tv); } } diff --git a/app/src/main/res/drawable-hdpi/ic_unfold_less_grey600_24dp.png b/app/src/main/res/drawable-hdpi/ic_unfold_less_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e1fb473fd1a45462ef29b5385a41d9b1f3584e3a GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZK3>dAqwX{BQ3+vmeOgEbxddW?r;B5V$MLsUefgRU1lk_HJ1~3Zgo4@Tg@J-!ZPcXxUzq$bE2bextTgJ76YtAa zu{I}5o}HFBV{zQ)g1Lhw`=xuQdz2$}rhIl-A*1!QFW|R^e2U-&Op YndPP@9}hU)1bT|k0wldT1B8K;Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZK3>dAqwX{BQ3+vmeOgEbxddW?uUtFrh<)JirPWJnB<}Nnny~9z_yz9Z_nU4_{iG5L P^aO*atDnm{r-UW|uZDN1 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_unfold_less_grey600_24dp.png b/app/src/main/res/drawable-mdpi/ic_unfold_less_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..99a474a35a8bcb07c532d6dc752946318d2441b8 GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1g=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G&@^*J&_}|`tWO=~G=WkL+ z;pyTSVsScIBUORdh^LNMXQ{Wh@`F7uF1ao}^TV`d+CTlj!BU)||JYA(t2|l4wqcsa ziceBWe;6(@1;u%FpD*2DjU}JdFVJv?p(y0dMCI(Me KKbLh*2~7ZnG literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_unfold_more_grey600_24dp.png b/app/src/main/res/drawable-mdpi/ic_unfold_more_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..cbcda9d88e3b691ccf6c2c9436e7fac07d8dd824 GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1g=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G&@^*J&_}|`tWO=~G=WkL+ z?CIhdVsScIBUORdh-XF{n}Uj?bMni2g&c)2XW@X4@(M>*u?ANfM^sj1vXtq*ICXfz zDaSV+8>T7zk(%K>-C=5TLdZ*}1t%0b+ZV2BTw0=Oa4KQXi%YI8O{O9;g%bmwF6iJ^ zd9s9U!!(T*pQMuhTww68*?OdE7vr2guRTsXe05fP#PI5-v3#+PfCkVx44$rjF6*2U FngA8kSatva literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_unfold_less_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_unfold_less_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..bc3e3631c99ad020643ee6391efe488c74311b59 GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}tg=CK)Uj~LMH3o);76yi2K%s^g z3=E|}g|8AA7_4S6Fo+k-*%fF5lweBoc6VX;-`;;_Kaj^+;1OBOz`!jG!i)^F=14Fw zFfw_%IEF+VetXR^ugO8A;ogHXMI`i)t*g!cbnBFMt%P47wB6vVcVzk&a#))5>I{K&u;p0bC`3yNxA>M zvdP&=me*DkT-#GCmYeg_Vx6);V|9aUo=-yiBC|vD%!U4bzI|;+nKSckdwCgil@GUm zq)anAG|S&J*QNa5(y8J{+-`hsn($S9SDkFJf1H5W{v(EOt{X1=@I?EO@Y5sCFXU8Y mY<_m#_$;wJlSS#m-gU->X9A*}p4I|`h{4m<&t;ucLK6T8*PJ{6 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_unfold_more_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_unfold_more_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..bd15f86401ffd4ea1dfda8cc9ceb792691bee3a0 GIT binary patch literal 399 zcmV;A0dW3_P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_009R{L_t(o!|j$!PQx$|Kxb7pw7m@d1i04QHDIZSg04ZK zwk8Dg3H*l8B?%DQJcb!SCn!LL5DXfhT#?E zC8eOlAE<2#EB=91Pw|>UaE=$mrU=J>vuID(;flZUcT^s{AQY|QgGtN_W_)?@Cq;wu z$$jh}%-FH?-W0qs&D}H$vLFlohhWZ*mG|b6_xNTvXOB{Q6i+lL)h)%XfwTV|E0>BB zUQw#Jf#cfIShMcof7>uti>EX+ib>Oa6$1-)HxgndW tt&*J`Z*3JWbR!+!i<}Lg+jSPCh$A>#%qFlL(c=IB002ovPDHLkV1h0}qJ{tf literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_unfold_less_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_unfold_less_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f43a8b8b8c82d50b922590183b001776c1631195 GIT binary patch literal 504 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw6p}rHd>I(3)EF2VS{N990fib~ zFff!FFfhDIU|_JC!N4G1FlSew4N!t9$=lt9;eUJonf*W>XMsm#F#`j)FbFd;%$g&? zz`$7G>EalYaqsO7-@HQx0;~!0Et5nvwyzEet+k$H^(8^a!p+-r;he*tA$2Lo>f>ywTPLhP z&XU@jJVB0oORlWQSBV9=&o$PzvxQpD|M6%-#2m>qnIQRd?#%9vg&sD2O^2H8J5Mg0 zaK|EF%+Jv(WL4auMlp*>i_)Mzizm}`3%3=VQgQd2?;JZ}m&H;2N6b8RA1sb+jZaK} rD6(X(wY$+)U>GSda=!TA{Ewl5?X<>!-iI2%2x0Ja^>bP0l+XkK+C9cz literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_unfold_more_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_unfold_more_grey600_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..17618bebf2fba56a531716c202c8d48a5f5a5305 GIT binary patch literal 469 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw6p}rHd>I(3)EF2VS{N990fib~ zFff!FFfhDIU|_JC!N4G1FlSew4N!t9$=lt9;eUJonf*W>XMsm#F#`j)FbFd;%$g&? zz`*G1>EalYaqsO-@2tZH5-bU_Du!zxzZQ*p@n%+3CjYeND{Xdsk91;qHnz4bnfUhT zg0%wjFFy9GFmGO;#vIR-!|XDW}*C2>U`ibF^~fwu8_X) z%GAL(q-Cvl^DNCL<#Iu$t$#9tw2r&4dbiGT;u4Dsr{8ehcqs9JN8&?B(W#t7L zjk{tOWTu{b`@H90`_2QNwi2;RRG;s8=DAlT(86-*;VOCC^U+s~PCtJl7H7~I{an^L HB{Ts5&?~d9 literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/fragment_new_email.xml b/app/src/main/res/layout/fragment_new_email.xml index 5586118..506ad11 100644 --- a/app/src/main/res/layout/fragment_new_email.xml +++ b/app/src/main/res/layout/fragment_new_email.xml @@ -1,29 +1,57 @@ - + android:paddingTop="@dimen/activity_vertical_margin"> + android:orientation="vertical"> + android:layout_height="wrap_content"/> + + + + + + + + + + + android:layout_height="wrap_content" + android:visibility="gone"/> - - + + android:inputType="textEmailSubject"/> + android:inputType="textMultiLine"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_view_email.xml b/app/src/main/res/layout/fragment_view_email.xml index af3ff25..6205564 100644 --- a/app/src/main/res/layout/fragment_view_email.xml +++ b/app/src/main/res/layout/fragment_view_email.xml @@ -93,7 +93,51 @@ android:textAppearance="@style/TextAppearance.AppCompat.Secondary"/> + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b0c64b5..0b99b47 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -103,6 +103,8 @@ This email does not have a valid signature. It was probably not sent by %s. From: To: + Cc: + Bcc: Sent: Received: Status: