From 5b20ee25b2b7b73b2d6280ab560905b60b58c0dc Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 7 Dec 2018 16:28:24 +0100 Subject: [PATCH] Fixed missing action in native contact app --- app/build.gradle | 12 ++ app/{src/main/res/xml => }/contacts.xml | 6 +- .../org/linphone/contacts/AndroidContact.java | 112 +++++++++--------- 3 files changed, 71 insertions(+), 59 deletions(-) rename app/{src/main/res/xml => }/contacts.xml (59%) diff --git a/app/build.gradle b/app/build.gradle index 053fe98a1..988997b48 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -131,6 +131,18 @@ if (firebaseEnabled()) { apply plugin: 'com.google.gms.google-services' } +task generateContactsXml(type: Copy) { + from 'contacts.xml' + into "src/main/res/xml/" + filter { + line -> line + .replaceAll('%%AUTO_GENERATED%%', 'This file has been automatically generated, do not edit or commit !') + .replaceAll('%%PACKAGE_NAME%%', getPackageName()) + + } +} +project.tasks['preBuild'].dependsOn 'generateContactsXml' + apply plugin: "com.diffplug.gradle.spotless" spotless { java { diff --git a/app/src/main/res/xml/contacts.xml b/app/contacts.xml similarity index 59% rename from app/src/main/res/xml/contacts.xml rename to app/contacts.xml index dc6fcc3b7..7836193c0 100644 --- a/app/src/main/res/xml/contacts.xml +++ b/app/contacts.xml @@ -1,11 +1,11 @@ - + - + diff --git a/app/src/main/java/org/linphone/contacts/AndroidContact.java b/app/src/main/java/org/linphone/contacts/AndroidContact.java index 55f11ffd2..367160c2c 100644 --- a/app/src/main/java/org/linphone/contacts/AndroidContact.java +++ b/app/src/main/java/org/linphone/contacts/AndroidContact.java @@ -200,62 +200,6 @@ class AndroidContact implements Serializable { } } - protected void setOrganization(String org) { - if (org == null || org.isEmpty()) { - if (mAndroidId == null) { - Log.e("[Contact] Can't set organization to null or empty for new contact"); - return; - } - } - if (mAndroidId == null) { - Log.i("[Contact] Setting organization " + org + " to new contact."); - addChangesToCommit( - ContentProviderOperation.newInsert(Data.CONTENT_URI) - .withValueBackReference(Data.RAW_CONTACT_ID, 0) - .withValue( - Data.MIMETYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE) - .withValue(CommonDataKinds.Organization.COMPANY, org) - .build()); - } else { - Log.i("[Contact] Setting organization " + org + " to existing contact " + mAndroidId); - // TODO - } - } - - protected void setPhoto(byte[] photo) { - if (photo == null) { - Log.e("[Contact] Can't set null picture."); - return; - } - - if (mAndroidId == null) { - Log.i("[Contact] Setting picture to new contact."); - // TODO - } else { - Log.i("[Contact] Setting picture to existing contact " + mAndroidId); - // TODO - } - } - - protected void removeNumberOrAddress(String noa) { - if (noa == null || noa.isEmpty()) { - Log.e("[Contact] Can't remove null or empty number or address."); - return; - } - - if (mAndroidId == null) { - Log.i("[Contact] Removing number or address " + noa + " from new contact."); - // TODO - } else { - Log.i( - "[Contact] Removing number or address " - + noa - + " from existing contact " - + mAndroidId); - // TODO - } - } - protected void addNumberOrAddress(String value, String oldValueToReplace, boolean isSIP) { if (value == null || value.isEmpty()) { Log.e("[Contact] Can't add null or empty number or address"); @@ -317,6 +261,62 @@ class AndroidContact implements Serializable { } } + protected void removeNumberOrAddress(String noa) { + if (noa == null || noa.isEmpty()) { + Log.e("[Contact] Can't remove null or empty number or address."); + return; + } + + if (mAndroidId == null) { + Log.i("[Contact] Removing number or address " + noa + " from new contact."); + // TODO + } else { + Log.i( + "[Contact] Removing number or address " + + noa + + " from existing contact " + + mAndroidId); + // TODO + } + } + + protected void setOrganization(String org) { + if (org == null || org.isEmpty()) { + if (mAndroidId == null) { + Log.e("[Contact] Can't set organization to null or empty for new contact"); + return; + } + } + if (mAndroidId == null) { + Log.i("[Contact] Setting organization " + org + " to new contact."); + addChangesToCommit( + ContentProviderOperation.newInsert(Data.CONTENT_URI) + .withValueBackReference(Data.RAW_CONTACT_ID, 0) + .withValue( + Data.MIMETYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE) + .withValue(CommonDataKinds.Organization.COMPANY, org) + .build()); + } else { + Log.i("[Contact] Setting organization " + org + " to existing contact " + mAndroidId); + // TODO + } + } + + protected void setPhoto(byte[] photo) { + if (photo == null) { + Log.e("[Contact] Can't set null picture."); + return; + } + + if (mAndroidId == null) { + Log.i("[Contact] Setting picture to new contact."); + // TODO + } else { + Log.i("[Contact] Setting picture to existing contact " + mAndroidId); + // TODO + } + } + protected void getAndroidIds() { mAndroidRawId = findRawContactID(); if (LinphoneManager.getInstance()