Add support for Cc: and Bcc:
@@ -94,9 +94,13 @@ public class NewEmailFragment extends Fragment {
|
||||
Spinner mSpinner;
|
||||
int mDefaultPos;
|
||||
ArrayAdapter<Person> 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<Person> recipients = new ArrayList<Person>();
|
||||
List<Person> toRecipients = new ArrayList<Person>();
|
||||
List<Person> ccRecipients = new ArrayList<Person>();
|
||||
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<Person> contacts = new ArrayList<Person>();
|
||||
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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_unfold_less_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 331 B |
BIN
app/src/main/res/drawable-hdpi/ic_unfold_more_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
app/src/main/res/drawable-mdpi/ic_unfold_less_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 272 B |
BIN
app/src/main/res/drawable-mdpi/ic_unfold_more_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 267 B |
BIN
app/src/main/res/drawable-xhdpi/ic_unfold_less_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 394 B |
BIN
app/src/main/res/drawable-xhdpi/ic_unfold_more_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 399 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_unfold_less_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 504 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_unfold_more_grey600_24dp.png
Normal file
|
After Width: | Height: | Size: 469 B |
@@ -1,29 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin" >
|
||||
android:paddingTop="@dimen/activity_vertical_margin">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/sender_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<i2p.bote.android.util.ContactsCompletionView
|
||||
android:id="@+id/to"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<requestFocus/>
|
||||
</i2p.bote.android.util.ContactsCompletionView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more"
|
||||
android:layout_width="@dimen/listitem_picture_size"
|
||||
android:layout_height="@dimen/listitem_picture_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_unfold_more_grey600_24dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<i2p.bote.android.util.ContactsCompletionView
|
||||
android:id="@+id/recipients"
|
||||
android:id="@+id/cc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<requestFocus />
|
||||
</i2p.bote.android.util.ContactsCompletionView>
|
||||
<i2p.bote.android.util.ContactsCompletionView
|
||||
android:id="@+id/bcc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/subject"
|
||||
@@ -31,7 +59,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/subject"
|
||||
android:inputType="textEmailSubject" />
|
||||
android:inputType="textEmailSubject"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/message"
|
||||
@@ -39,7 +67,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/compose_email"
|
||||
android:inputType="textMultiLine" />
|
||||
android:inputType="textMultiLine"/>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
@@ -93,7 +93,51 @@
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Secondary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_recipients"
|
||||
android:id="@+id/email_to"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/email_cc_row"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:text="@string/email_cc"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Secondary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_cc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/email_bcc_row"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:text="@string/email_bcc"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Secondary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_bcc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -103,6 +103,8 @@
|
||||
<string name="signature_invalid">This email does not have a valid signature. It was probably not sent by %s.</string>
|
||||
<string name="email_from">From:</string>
|
||||
<string name="email_to">To:</string>
|
||||
<string name="email_cc">Cc:</string>
|
||||
<string name="email_bcc">Bcc:</string>
|
||||
<string name="label_sent">Sent:</string>
|
||||
<string name="email_received">Received:</string>
|
||||
<string name="email_status">Status:</string>
|
||||
|
||||