Contact add/edit improvements

pull/184/head
M66B 4 years ago
parent 5e4d3ab5e8
commit 2c88095ea3

@ -3418,6 +3418,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onInsertContact(String name, String email) {
if (TextUtils.isEmpty(name)) {
int at = email.indexOf('@');
if (at > 0)
name = email.substring(0, at);
}
// https://developer.android.com/training/contacts-provider/modify-data
Intent insert = new Intent();
insert.putExtra(ContactsContract.Intents.Insert.EMAIL, email);
@ -3432,8 +3438,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// https://developer.android.com/training/contacts-provider/modify-data
Intent edit = new Intent();
edit.putExtra(ContactsContract.Intents.Insert.EMAIL, email);
if (!TextUtils.isEmpty(name))
edit.putExtra(ContactsContract.Intents.Insert.NAME, name);
edit.setAction(Intent.ACTION_EDIT);
edit.setDataAndTypeAndNormalize(lookupUri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
context.startActivity(edit);

@ -7155,7 +7155,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onPickContact(Uri contactUri) {
String name = kv.get("name");
String email = kv.get("email");
// This requires contacts permission
@ -7164,8 +7163,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Intent edit = new Intent();
edit.putExtra(ContactsContract.Intents.Insert.EMAIL, email);
if (!TextUtils.isEmpty(name))
edit.putExtra(ContactsContract.Intents.Insert.NAME, name);
edit.setAction(Intent.ACTION_EDIT);
edit.setDataAndTypeAndNormalize(lookupUri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
startActivity(edit);

Loading…
Cancel
Save