handle ahandle a new way of creating new contacts from numbers

This commit is contained in:
tibbi 2018-11-29 20:45:13 +01:00
parent ff0a08862c
commit b069d2c4b1

View file

@ -164,7 +164,7 @@ class EditContactActivity : ContactActivity() {
} }
val action = intent.action val action = intent.action
if ((contact!!.id == 0 && intent.extras != null && intent.extras.containsKey(KEY_PHONE) && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) { if ((contact!!.id == 0 && intent.extras != null && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) {
val phone = intent.extras.get(KEY_PHONE) val phone = intent.extras.get(KEY_PHONE)
if (phone != null) { if (phone != null) {
val phoneNumber = phone.toString() val phoneNumber = phone.toString()
@ -172,6 +172,20 @@ class EditContactActivity : ContactActivity() {
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) { if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true highlightLastPhoneNumber = true
} }
} else {
// sample contact number from Google Contacts:
// data: [data1=+123 456 789 mimetype=vnd.android.cursor.item/phone_v2 _id=-1 data2=0]
val data = intent.extras.get("data")
if (data != null) {
val contentValues = (data as? ArrayList<Any>)?.firstOrNull() as? ContentValues
if (contentValues != null && contentValues.containsKey("data1")) {
val phoneNumber = contentValues.getAsString("data1")
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "", phoneNumber.normalizeNumber()))
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true
}
}
}
} }
val firstName = intent.extras.get(KEY_NAME) val firstName = intent.extras.get(KEY_NAME)