Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 986ae46a authored by Chad Wagner's avatar Chad Wagner
Browse files

Allow SIP calls to be added as a contact from call log (1/2)

Change-Id: I5932a0afb55040dc716a3438cb36555301485cae
parent 158a12fe
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -1300,20 +1300,14 @@ public class RecentCallsListActivity extends ListActivity
        }

        // "Add to contacts" item, if this entry isn't already associated with a contact
        if (!contactInfoPresent && numberUri != null && !isVoicemail && !isSipNumber) {
            // TODO: This item is currently disabled for SIP addresses, because
            // the Insert.PHONE extra only works correctly for PSTN numbers.
            //
            // To fix this for SIP addresses, we need to:
            // - define ContactsContract.Intents.Insert.SIP_ADDRESS, and use it here if
            //   the current number is a SIP address
            // - update the contacts UI code to handle Insert.SIP_ADDRESS by
            //   updating the SipAddress field
            // and then we can remove the "!isSipNumber" check above.

        if (!contactInfoPresent && numberUri != null && !isVoicemail) {
            Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
            intent.setType(Contacts.CONTENT_ITEM_TYPE);
            if (isSipNumber) {
                intent.putExtra(Insert.SIP_ADDRESS, number);
            } else {
                intent.putExtra(Insert.PHONE, number);
            }
            menu.add(0, 0, 0, R.string.recentCalls_addToContact)
                    .setIntent(intent);
	    menu.add(0, MENU_ITEM_BLACKLIST, 0, R.string.recentCalls_addToBlacklist);
+13 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.Intents.Insert;
import android.text.TextUtils;
import android.util.Log;
@@ -469,6 +470,18 @@ public class EntityModifier {
                    Phone.NUMBER);
        }

        // SipAddress
        final boolean hasSipAddress = extras.containsKey(Insert.SIP_ADDRESS);
        final DataKind kindSipAddress = source.getKindForMimetype(SipAddress.CONTENT_ITEM_TYPE);

        if (hasSipAddress && EntityModifier.canInsert(state, kindSipAddress))
        {
            final String sipAddress = extras.getString(Insert.SIP_ADDRESS);
            final ValuesDelta child = EntityModifier.insertChild(state, kindSipAddress);

            child.put(SipAddress.SIP_ADDRESS, sipAddress);
        }

        {
            // Email
            final DataKind kind = source.getKindForMimetype(Email.CONTENT_ITEM_TYPE);