Delete sip address fixed

This commit is contained in:
Margaux Clerc 2015-04-23 11:41:49 +02:00
parent 14c8510398
commit 1586eed0e9
2 changed files with 17 additions and 1 deletions

View file

@ -548,7 +548,7 @@ public class ContactsManager {
//Remove linphone contact tag if the contact has no sip address
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
if (removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact, contentResolver)) {
if (removeContactTagIsNeeded(contact) && findRawLinphoneContactID(contact.getID()) != null) {
removeLinphoneContactTag(contact);
}
}

View file

@ -102,6 +102,7 @@ public class EditContactFragment extends Fragment {
try {
getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
addLinphoneFriendIfNeeded();
removeLinphoneTagIfNeeded();
contactsManager.prepareContactsInBackground();
} catch (Exception e) {
e.printStackTrace();
@ -416,6 +417,21 @@ public class EditContactFragment extends Fragment {
}
}
private void removeLinphoneTagIfNeeded(){
if(!isNewContact) {
boolean areAllSipFielsEmpty = true;
for (NewOrUpdatedNumberOrAddress nounoa : numbersAndAddresses) {
if (!nounoa.isSipAddress && (nounoa.oldNumberOrAddress != null && !nounoa.oldNumberOrAddress.equals("") || nounoa.newNumberOrAddress != null && !nounoa.newNumberOrAddress.equals(""))) {
areAllSipFielsEmpty = false;
break;
}
}
if (areAllSipFielsEmpty && contactsManager.findRawLinphoneContactID(contact.getID()) != null) {
contactsManager.removeLinphoneContactTag(contact);
}
}
}
class NewOrUpdatedNumberOrAddress {
private String oldNumberOrAddress;
private String newNumberOrAddress;