Improved code
This commit is contained in:
parent
0ef866c3e3
commit
fdefb77925
1 changed files with 9 additions and 11 deletions
|
@ -74,16 +74,17 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinphoneContact createContact() {
|
public static LinphoneContact createContact() {
|
||||||
if (ContactsManager.getInstance().hasContactsAccess()) {
|
|
||||||
return createAndroidContact();
|
|
||||||
}
|
|
||||||
return createFriend();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LinphoneContact createAndroidContact() {
|
|
||||||
LinphoneContact contact = new LinphoneContact();
|
LinphoneContact contact = new LinphoneContact();
|
||||||
|
if (ContactsManager.getInstance().hasContactsAccess()) {
|
||||||
|
contact.createAndroidContact();
|
||||||
|
} else {
|
||||||
|
contact.createFriend();
|
||||||
|
}
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
|
||||||
contact.mChangesToCommit.add(
|
private void createAndroidContact() {
|
||||||
|
mChangesToCommit.add(
|
||||||
ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
|
ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
|
||||||
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
|
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
|
||||||
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
|
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
|
||||||
|
@ -91,12 +92,10 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
ContactsContract.RawContacts.AGGREGATION_MODE,
|
ContactsContract.RawContacts.AGGREGATION_MODE,
|
||||||
ContactsContract.RawContacts.AGGREGATION_MODE_DEFAULT)
|
ContactsContract.RawContacts.AGGREGATION_MODE_DEFAULT)
|
||||||
.build());
|
.build());
|
||||||
contact.setAndroidId("0");
|
setAndroidId("0");
|
||||||
|
|
||||||
return contact;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinphoneContact createFriend() {
|
private void createFriend() {
|
||||||
LinphoneContact contact = new LinphoneContact();
|
LinphoneContact contact = new LinphoneContact();
|
||||||
Friend friend = LinphoneManager.getLc().createFriend();
|
Friend friend = LinphoneManager.getLc().createFriend();
|
||||||
// Disable subscribes for now
|
// Disable subscribes for now
|
||||||
|
@ -104,7 +103,6 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
friend.setIncSubscribePolicy(SubscribePolicy.SPDeny);
|
friend.setIncSubscribePolicy(SubscribePolicy.SPDeny);
|
||||||
contact.mFriend = friend;
|
contact.mFriend = friend;
|
||||||
friend.setUserData(contact);
|
friend.setUserData(contact);
|
||||||
return contact;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue