summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryingying <yingying@codeaurora.org>2013-12-26 22:19:57 +0800
committerAdnan <adnan@cyngn.com>2014-09-03 15:41:21 -0700
commit0dfaa88298dcbe2856af29f7965e3113118dde94 (patch)
tree2aa0e9d1bfa9062bb31dab3c947852c25782d615
parent03e6e2b7b5d79a6f127347bac0269bd9819e95d4 (diff)
downloadandroid_packages_apps_UnifiedEmail-0dfaa88298dcbe2856af29f7965e3113118dde94.tar.gz
android_packages_apps_UnifiedEmail-0dfaa88298dcbe2856af29f7965e3113118dde94.tar.bz2
android_packages_apps_UnifiedEmail-0dfaa88298dcbe2856af29f7965e3113118dde94.zip
UnifiedEmail: Display the pick recipients button.
- Display the pick recipients button if the user enable "Select recipients from Contacts" item. And after the user press this button, it will go to the Contacts list to let the user pick the recipients as to/cc/bcc list. Change-Id: I3221afc97aed16753596dfcd45526709756a540e
-rw-r--r--res/drawable-hdpi/ic_pick_recipients.pngbin0 -> 5790 bytes
-rw-r--r--res/drawable-mdpi/ic_pick_recipients.pngbin0 -> 4610 bytes
-rw-r--r--res/drawable-xhdpi/ic_pick_recipients.pngbin0 -> 7317 bytes
-rw-r--r--res/layout-sw600dp/compose.xml11
-rw-r--r--res/layout/cc_bcc_view.xml29
-rw-r--r--res/layout/compose_recipients.xml10
-rw-r--r--src/com/android/mail/compose/ComposeActivity.java85
-rw-r--r--src/com/android/mail/providers/Settings.java18
-rw-r--r--src/com/android/mail/providers/UIProvider.java8
-rw-r--r--src/com/android/mail/providers/protos/mock/MockUiProvider.java1
10 files changed, 153 insertions, 9 deletions
diff --git a/res/drawable-hdpi/ic_pick_recipients.png b/res/drawable-hdpi/ic_pick_recipients.png
new file mode 100644
index 000000000..a9ff98021
--- /dev/null
+++ b/res/drawable-hdpi/ic_pick_recipients.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_pick_recipients.png b/res/drawable-mdpi/ic_pick_recipients.png
new file mode 100644
index 000000000..abaa30eed
--- /dev/null
+++ b/res/drawable-mdpi/ic_pick_recipients.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_pick_recipients.png b/res/drawable-xhdpi/ic_pick_recipients.png
new file mode 100644
index 000000000..c5157743a
--- /dev/null
+++ b/res/drawable-xhdpi/ic_pick_recipients.png
Binary files differ
diff --git a/res/layout-sw600dp/compose.xml b/res/layout-sw600dp/compose.xml
index 9e6ae6239..c106fffba 100644
--- a/res/layout-sw600dp/compose.xml
+++ b/res/layout-sw600dp/compose.xml
@@ -71,7 +71,18 @@
<com.android.ex.chips.RecipientEditTextView
android:id="@+id/to"
style="@style/RecipientEditTextViewStyle"
+ android:layout_width="0dip"
+ android:layout_weight="1"
android:contentDescription="@string/to"/>
+
+ <ImageButton android:id="@+id/to_pick_recipients"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="4dip"
+ android:gravity="bottom"
+ android:src="@drawable/ic_pick_recipients"
+ android:background="@null" />
+
</LinearLayout>
<View style="@style/RecipientComposeFieldSpacer"/>
diff --git a/res/layout/cc_bcc_view.xml b/res/layout/cc_bcc_view.xml
index acc957bcf..3d9f587fd 100644
--- a/res/layout/cc_bcc_view.xml
+++ b/res/layout/cc_bcc_view.xml
@@ -36,10 +36,21 @@
android:id="@+id/cc_label"
android:contentDescription="@string/cc"/>
- <com.android.ex.chips.RecipientEditTextView
- android:id="@+id/cc"
- style="@style/RecipientEditTextViewStyle"
- android:contentDescription="@string/cc"/>
+ <com.android.ex.chips.RecipientEditTextView
+ android:id="@+id/cc"
+ style="@style/RecipientEditTextViewStyle"
+ android:layout_width="0dip"
+ android:layout_weight="1"
+ android:contentDescription="@string/cc"/>
+
+ <ImageButton android:id="@+id/cc_pick_recipients"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="4dip"
+ android:gravity="bottom"
+ android:src="@drawable/ic_pick_recipients"
+ android:background="@null" />
+
</LinearLayout>
<View style="@style/RecipientComposeFieldSpacer"/>
@@ -64,8 +75,18 @@
<com.android.ex.chips.RecipientEditTextView
android:id="@+id/bcc"
style="@style/RecipientEditTextViewStyle"
+ android:layout_width="0dip"
+ android:layout_weight="1"
android:contentDescription="@string/bcc"/>
+ <ImageButton android:id="@+id/bcc_pick_recipients"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="4dip"
+ android:gravity="bottom"
+ android:src="@drawable/ic_pick_recipients"
+ android:background="@null" />
+
</LinearLayout>
<View style="@style/RecipientComposeFieldSpacer"/>
diff --git a/res/layout/compose_recipients.xml b/res/layout/compose_recipients.xml
index 4211a0bf5..06a583daf 100644
--- a/res/layout/compose_recipients.xml
+++ b/res/layout/compose_recipients.xml
@@ -38,8 +38,18 @@
<com.android.ex.chips.RecipientEditTextView
android:id="@+id/to"
style="@style/RecipientEditTextViewStyle"
+ android:layout_width="0dip"
+ android:layout_weight="1"
android:contentDescription="@string/to"/>
+ <ImageButton android:id="@+id/to_pick_recipients"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="4dip"
+ android:gravity="bottom"
+ android:src="@drawable/ic_pick_recipients"
+ android:background="@null" />
+
</LinearLayout>
<View style="@style/RecipientComposeFieldSpacer"/>
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index b502f6476..d15eacf8c 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -43,6 +43,7 @@ import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.provider.BaseColumns;
+import android.provider.ContactsContract.Contacts;
import android.text.Editable;
import android.text.Html;
import android.text.SpannableString;
@@ -65,6 +66,7 @@ import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
@@ -114,6 +116,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
@@ -212,6 +215,14 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
// Request numbers for activities we start
private static final int RESULT_PICK_ATTACHMENT = 1;
private static final int RESULT_CREATE_ACCOUNT = 2;
+ private static final int RESULT_PICK_CONTACT_TO = 3;
+ private static final int RESULT_PICK_CONTACT_CC = 4;
+ private static final int RESULT_PICK_CONTACT_BCC = 5;
+
+ // The action to pick recipients
+ private static final String ACTION_MULTI_PICK_EMAIL =
+ "com.android.contacts.action.MULTI_PICK_EMAIL";
+
// TODO(mindyp) set mime-type for auto send?
public static final String AUTO_SEND_ACTION = "com.android.mail.action.AUTO_SEND";
@@ -238,6 +249,9 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
private RecipientEditTextView mTo;
private RecipientEditTextView mCc;
private RecipientEditTextView mBcc;
+ private ImageButton mToPickRecipients;
+ private ImageButton mCcPickRecipients;
+ private ImageButton mBccPickRecipients;
private Button mCcBccButton;
private CcBccView mCcBccView;
private AttachmentsView mAttachmentsView;
@@ -257,6 +271,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
private View mFromSpinnerWrapper;
@VisibleForTesting
protected FromAddressSpinner mFromSpinner;
+ private boolean mPickingRecipients;
private boolean mAddingAttachment;
private boolean mAttachmentsChanged;
private boolean mTextChanged;
@@ -675,6 +690,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
}
initChangeListeners();
+ updateHideOrShowPickRecipients();
updateHideOrShowCcBcc();
updateHideOrShowQuotedText(mShowQuotedText);
@@ -799,6 +815,15 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, null, this);
showWaitFragment(null);
}
+ } else if (result == RESULT_OK && request == RESULT_PICK_CONTACT_TO) {
+ addAddressesToList(data, mTo);
+ mPickingRecipients = false;
+ } else if (result == RESULT_OK && request == RESULT_PICK_CONTACT_CC) {
+ addAddressesToList(data, mCc);
+ mPickingRecipients = false;
+ } else if (result == RESULT_OK && request == RESULT_PICK_CONTACT_BCC) {
+ addAddressesToList(data, mBcc);
+ mPickingRecipients = false;
}
}
@@ -1138,6 +1163,12 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
mCc.setTokenizer(new Rfc822Tokenizer());
mBcc = (RecipientEditTextView) findViewById(R.id.bcc);
mBcc.setTokenizer(new Rfc822Tokenizer());
+ mToPickRecipients = (ImageButton) findViewById(R.id.to_pick_recipients);
+ mToPickRecipients.setOnClickListener(this);
+ mCcPickRecipients = (ImageButton) findViewById(R.id.cc_pick_recipients);
+ mCcPickRecipients.setOnClickListener(this);
+ mBccPickRecipients = (ImageButton) findViewById(R.id.bcc_pick_recipients);
+ mBccPickRecipients.setOnClickListener(this);
// TODO: add special chips text change watchers before adding
// this as a text changed watcher to the to, cc, bcc fields.
mSubject = (TextView) findViewById(R.id.subject);
@@ -1650,6 +1681,18 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
}
}
+ private void updateHideOrShowPickRecipients() {
+ if (mAccount.settings.selectRecipients) {
+ mToPickRecipients.setVisibility(View.VISIBLE);
+ mCcPickRecipients.setVisibility(View.VISIBLE);
+ mBccPickRecipients.setVisibility(View.VISIBLE);
+ } else {
+ mToPickRecipients.setVisibility(View.GONE);
+ mCcPickRecipients.setVisibility(View.GONE);
+ mBccPickRecipients.setVisibility(View.GONE);
+ }
+ }
+
private void updateHideOrShowCcBcc() {
// Its possible there is a menu item OR a button.
boolean ccVisible = mCcBccView.isCcVisible();
@@ -1812,6 +1855,25 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
return tokenized;
}
+ void addAddressesToList(Intent data, RecipientEditTextView list) {
+ if (data == null && list == null) return;
+
+ Bundle choiceSet = data.getExtras().getBundle("result");
+ Set<String> set = choiceSet.keySet();
+ Iterator<String> i = set.iterator();
+ while (i.hasNext()) {
+ String[] array = choiceSet.getStringArray(i.next());
+ // For this array, it store the contact's name by the index 0
+ // and store the contact's address by the index 1.
+ // Format the address as: <address>
+ addAddressToList("<" + array[1] + ">", list);
+ }
+
+ // Make the list will be displayed as parsed.
+ list.requestFocus(); // request the focus
+ focusBody(); // focus to body view
+ }
+
@VisibleForTesting
void addAddressesToList(Collection<String> addresses, RecipientEditTextView list) {
for (String address : addresses) {
@@ -1940,7 +2002,13 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
@Override
public void onClick(View v) {
final int id = v.getId();
- if (id == R.id.add_cc_bcc) {
+ if (id == R.id.to_pick_recipients) {
+ pickRecipient(RESULT_PICK_CONTACT_TO);
+ } else if (id == R.id.cc_pick_recipients) {
+ pickRecipient(RESULT_PICK_CONTACT_CC);
+ } else if (id == R.id.bcc_pick_recipients) {
+ pickRecipient(RESULT_PICK_CONTACT_BCC);
+ } else if (id == R.id.add_cc_bcc) {
// Verify that cc/ bcc aren't showing.
// Animate in cc/bcc.
showCcBccViews();
@@ -2962,6 +3030,19 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
RESULT_PICK_ATTACHMENT);
}
+ private void pickRecipient(int requestCode) {
+ mPickingRecipients = true;
+
+ // Start the activity to pick the recipient.
+ Intent intent = new Intent(ACTION_MULTI_PICK_EMAIL);
+ intent.setType(Contacts.CONTENT_TYPE);
+ startActivityForResult(intent, requestCode);
+
+ // Set the focus to body view.
+ // And it will make the recipient view to parse the address.
+ focusBody();
+ }
+
private void showCcBccViews() {
mCcBccView.show(true, true, true);
if (mCcBccButton != null) {
@@ -3263,7 +3344,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
}
if (shouldSave()) {
- doSave(!mAddingAttachment /* show toast */);
+ doSave(!mAddingAttachment && !mPickingRecipients /* show toast */);
}
}
diff --git a/src/com/android/mail/providers/Settings.java b/src/com/android/mail/providers/Settings.java
index fa7ff6495..e2c99e19e 100644
--- a/src/com/android/mail/providers/Settings.java
+++ b/src/com/android/mail/providers/Settings.java
@@ -75,6 +75,7 @@ public class Settings implements Parcelable {
public final boolean confirmArchive;
public final boolean confirmSend;
public final boolean addAttachment;
+ public final boolean selectRecipients;
public final int conversationViewMode;
public final Uri defaultInbox;
/**
@@ -118,6 +119,7 @@ public class Settings implements Parcelable {
confirmArchive = false;
confirmSend = false;
addAttachment = true;
+ selectRecipients = true;
defaultInbox = Uri.EMPTY;
defaultInboxName = "";
forceReplyFromDefault = false;
@@ -142,6 +144,7 @@ public class Settings implements Parcelable {
confirmArchive = inParcel.readInt() != 0;
confirmSend = inParcel.readInt() != 0;
addAttachment = inParcel.readInt() != 0;
+ selectRecipients = inParcel.readInt() != 0;
defaultInbox = Utils.getValidUri(inParcel.readString());
defaultInboxName = inParcel.readString();
forceReplyFromDefault = inParcel.readInt() != 0;
@@ -167,6 +170,8 @@ public class Settings implements Parcelable {
confirmArchive = cursor.getInt(cursor.getColumnIndex(SettingsColumns.CONFIRM_ARCHIVE)) != 0;
confirmSend = cursor.getInt(cursor.getColumnIndex(SettingsColumns.CONFIRM_SEND)) != 0;
addAttachment = cursor.getInt(cursor.getColumnIndex(SettingsColumns.ADD_ATTACHMENT)) != 0;
+ selectRecipients = cursor.getInt(
+ cursor.getColumnIndex(SettingsColumns.SELECT_RECIPIENTS)) != 0;
defaultInbox = Utils.getValidUri(
cursor.getString(cursor.getColumnIndex(SettingsColumns.DEFAULT_INBOX)));
defaultInboxName =
@@ -201,6 +206,8 @@ public class Settings implements Parcelable {
confirmArchive = json.optBoolean(SettingsColumns.CONFIRM_ARCHIVE, sDefault.confirmArchive);
confirmSend = json.optBoolean(SettingsColumns.CONFIRM_SEND, sDefault.confirmSend);
addAttachment = json.optBoolean(SettingsColumns.ADD_ATTACHMENT, sDefault.addAttachment);
+ selectRecipients = json.optBoolean(SettingsColumns.SELECT_RECIPIENTS,
+ sDefault.selectRecipients);
defaultInbox = Utils.getValidUri( json.optString(SettingsColumns.DEFAULT_INBOX));
defaultInboxName = json.optString(SettingsColumns.DEFAULT_INBOX_NAME,
sDefault.defaultInboxName);
@@ -249,6 +256,7 @@ public class Settings implements Parcelable {
json.put(SettingsColumns.CONFIRM_ARCHIVE, confirmArchive);
json.put(SettingsColumns.CONFIRM_SEND, confirmSend);
json.put(SettingsColumns.ADD_ATTACHMENT, addAttachment);
+ json.put(SettingsColumns.SELECT_RECIPIENTS, selectRecipients);
json.put(SettingsColumns.DEFAULT_INBOX,
getNonNull(defaultInbox, sDefault.defaultInbox));
json.put(SettingsColumns.DEFAULT_INBOX_NAME,
@@ -290,6 +298,8 @@ public class Settings implements Parcelable {
map.put(UIProvider.AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, confirmArchive ? 1 : 0);
map.put(UIProvider.AccountColumns.SettingsColumns.CONFIRM_SEND, confirmSend ? 1 : 0);
map.put(UIProvider.AccountColumns.SettingsColumns.ADD_ATTACHMENT, addAttachment ? 1 : 0);
+ map.put(UIProvider.AccountColumns.SettingsColumns.SELECT_RECIPIENTS,
+ selectRecipients ? 1 : 0);
map.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX, defaultInbox);
map.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, defaultInboxName);
map.put(UIProvider.AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT,
@@ -341,6 +351,7 @@ public class Settings implements Parcelable {
dest.writeInt(confirmArchive ? 1 : 0);
dest.writeInt(confirmSend ? 1 : 0);
dest.writeInt(addAttachment ? 1 : 0);
+ dest.writeInt(selectRecipients ? 1 : 0);
dest.writeString(getNonNull(defaultInbox, sDefault.defaultInbox).toString());
dest.writeString((String) getNonNull(defaultInboxName, sDefault.defaultInboxName));
dest.writeInt(forceReplyFromDefault ? 1 : 0);
@@ -451,6 +462,7 @@ public class Settings implements Parcelable {
&& confirmArchive == that.confirmArchive
&& confirmSend == that.confirmSend
&& addAttachment == that.addAttachment
+ && selectRecipients == that.selectRecipients
&& Objects.equal(defaultInbox, that.defaultInbox)
// Not checking default Inbox name, since is is identical to the URI check above.
&& forceReplyFromDefault == that.forceReplyFromDefault
@@ -470,9 +482,9 @@ public class Settings implements Parcelable {
^ Objects.hashCode(signature, mAutoAdvance, mTransientAutoAdvance,
messageTextSize, snapHeaders, replyBehavior, convListIcon,
convListAttachmentPreviews, confirmDelete, confirmArchive, confirmSend,
- addAttachment, defaultInbox, forceReplyFromDefault, maxAttachmentSize,
- swipe, priorityArrowsEnabled, setupIntentUri, conversationViewMode,
- veiledAddressPattern, moveToInbox);
+ addAttachment, selectRecipients, defaultInbox, forceReplyFromDefault,
+ maxAttachmentSize, swipe, priorityArrowsEnabled, setupIntentUri,
+ conversationViewMode, veiledAddressPattern, moveToInbox);
}
return mHashCode;
}
diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java
index f22e60ce9..16e2fbc16 100644
--- a/src/com/android/mail/providers/UIProvider.java
+++ b/src/com/android/mail/providers/UIProvider.java
@@ -168,6 +168,7 @@ public class UIProvider {
.put(AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, Integer.class)
.put(AccountColumns.SettingsColumns.CONFIRM_SEND, Integer.class)
.put(AccountColumns.SettingsColumns.ADD_ATTACHMENT, Integer.class)
+ .put(AccountColumns.SettingsColumns.SELECT_RECIPIENTS, Integer.class)
.put(AccountColumns.SettingsColumns.DEFAULT_INBOX, String.class)
.put(AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME, String.class)
.put(AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT, Integer.class)
@@ -574,6 +575,13 @@ public class UIProvider {
public static final String ADD_ATTACHMENT = "add_attachment";
/**
+ * Integer column containing the user's specified select recipients preference value.
+ * A non zero value indicates that the user has indicated that the select recipients
+ * button will be shown to let the user could pick the contacts from Contact.
+ */
+ public static final String SELECT_RECIPIENTS = "select_recipients";
+
+ /**
* String containing the URI for the default inbox for this account.
*/
public static final String DEFAULT_INBOX = "default_inbox";
diff --git a/src/com/android/mail/providers/protos/mock/MockUiProvider.java b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
index 817f0f27b..70731b981 100644
--- a/src/com/android/mail/providers/protos/mock/MockUiProvider.java
+++ b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
@@ -376,6 +376,7 @@ public final class MockUiProvider extends ContentProvider {
accountMap.put(SettingsColumns.CONFIRM_ARCHIVE, 1);
accountMap.put(SettingsColumns.CONFIRM_SEND, 1);
accountMap.put(SettingsColumns.ADD_ATTACHMENT, 1);
+ accountMap.put(SettingsColumns.SELECT_RECIPIENTS, 1);
accountMap.put(SettingsColumns.DEFAULT_INBOX, defaultInbox);
accountMap.put(SettingsColumns.DEFAULT_INBOX_NAME, "Inbox");
accountMap.put(SettingsColumns.FORCE_REPLY_FROM_DEFAULT, 1);