Contact edition allows to delete existing fields
This commit is contained in:
parent
83aa99b8f8
commit
427c64971d
1 changed files with 30 additions and 1 deletions
|
@ -147,6 +147,7 @@ public class EditContactFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
nounoa.delete();
|
nounoa.delete();
|
||||||
|
numbersAndAddresses.remove(nounoa);
|
||||||
view.setVisibility(View.GONE);
|
view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -279,7 +280,35 @@ public class EditContactFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
//TODO
|
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
|
||||||
|
|
||||||
|
if (isSipAddress) {
|
||||||
|
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
||||||
|
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE + "' AND "
|
||||||
|
+ ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS + "=?";
|
||||||
|
String[] args = new String[] { String.valueOf(contactID), oldNumberOrAddress };
|
||||||
|
|
||||||
|
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withSelection(select, args)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
||||||
|
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
|
||||||
|
+ ContactsContract.CommonDataKinds.Phone.NUMBER + "=?";
|
||||||
|
String[] args = new String[] { String.valueOf(contactID), oldNumberOrAddress };
|
||||||
|
|
||||||
|
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withSelection(select, args)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewNumber(ArrayList<ContentProviderOperation> ops) {
|
private void addNewNumber(ArrayList<ContentProviderOperation> ops) {
|
||||||
|
|
Loading…
Reference in a new issue