Don't try to show invalid mail addresses in recipient selector

(fixes #1607)
This commit is contained in:
morckx 2016-09-09 22:32:46 +02:00
parent 82f5fc6b30
commit ca2e96eb45
2 changed files with 15 additions and 5 deletions

View file

@ -15,7 +15,9 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Contacts.Data;
import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.mail.Address;
import com.fsck.k9.view.RecipientSelectView.Recipient;
@ -238,12 +240,16 @@ public class RecipientLoader extends AsyncTaskLoader<List<Recipient>> {
}
}
Uri photoUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI));
Recipient recipient = new Recipient(name, email, addressLabel, contactId, lookupKey);
recipient.photoThumbnailUri = photoUri;
if(recipient.getAddress() != null) { // skip email addresses that could not be parsed
Uri photoUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI));
recipientMap.put(email, recipient);
recipients.add(recipient);
recipient.photoThumbnailUri = photoUri;
recipientMap.put(email, recipient);
recipients.add(recipient);
} else {
Log.w(K9.LOG_TAG, "Skipping invalid email address \"" + email + "\" of contact " + name + ".");
}
}
cursor.close();

View file

@ -550,7 +550,11 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
return address.getAddress();
}
public String getDisplayNameOrUnknown(Context context) {
public String getAddress() {
return address.getAddress();
}
public String getDisplayNameOrUnknown(Context context) {
String displayName = getDisplayName();
if (displayName != null) {
return displayName;