Show name and address for custom from sender entries.
Fixes b/6319552 Custom from addresses don't show email address (just name)
Change-Id: Ia988ec2685b039242ca345e3299a148fb52c0ac1
diff --git a/src/com/android/mail/compose/FromAddressSpinnerAdapter.java b/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
index e5d0b81..9a6bacb 100644
--- a/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
+++ b/src/com/android/mail/compose/FromAddressSpinnerAdapter.java
@@ -23,7 +23,6 @@
import android.widget.TextView;
import com.android.mail.R;
-import com.android.mail.providers.Account;
import com.android.mail.providers.ReplyFromAccount;
import java.util.List;
@@ -35,6 +34,9 @@
* @author mindyp@google.com
*/
public class FromAddressSpinnerAdapter extends ArrayAdapter<ReplyFromAccount> {
+ private static final int FROM = 0;
+ private static final int CUSTOM_FROM = 1;
+
public static int REAL_ACCOUNT = 2;
public static int ACCOUNT_DISPLAY = 0;
@@ -56,11 +58,26 @@
}
@Override
+ public int getViewTypeCount() {
+ // FROM and CUSTOM_FROM
+ return 2;
+ }
+
+ @Override
+ public int getItemViewType(int pos) {
+ return getItem(pos).isCustomFrom ? CUSTOM_FROM : FROM;
+ }
+
+ @Override
public View getView(int position, View convertView, ViewGroup parent) {
ReplyFromAccount fromItem = getItem(position);
int res = fromItem.isCustomFrom ? R.layout.custom_from_item : R.layout.from_item;
- View fromEntry = getInflater().inflate(res, null);
+ View fromEntry = convertView == null ? getInflater().inflate(res, null) : convertView;
((TextView) fromEntry.findViewById(R.id.spinner_account_name)).setText(fromItem.name);
+ if (fromItem.isCustomFrom) {
+ ((TextView) fromEntry.findViewById(R.id.spinner_account_address))
+ .setText(fromItem.address);
+ }
return fromEntry;
}
@@ -72,6 +89,10 @@
View fromEntry = getInflater().inflate(res, null);
TextView acctName = ((TextView) fromEntry.findViewById(R.id.spinner_account_name));
acctName.setText(fromItem.name);
+ if (fromItem.isCustomFrom) {
+ ((TextView) fromEntry.findViewById(R.id.spinner_account_address))
+ .setText(fromItem.address);
+ }
return fromEntry;
}