From ca2e159eac6c39abc7d31f1d3e10674fcfd0a5d4 Mon Sep 17 00:00:00 2001 From: Conner Simmons Date: Sun, 21 May 2017 15:50:52 -0400 Subject: [PATCH 1/2] Added Note field to Contact --- build.gradle | 2 +- contacts/build.gradle | 52 ------------------- .../com/github/tamir7/contacts/Contact.java | 17 ++++++ .../github/tamir7/contacts/CursorHelper.java | 4 ++ .../com/github/tamir7/contacts/Query.java | 5 ++ 5 files changed, 27 insertions(+), 53 deletions(-) diff --git a/build.gradle b/build.gradle index 98c4c47..e0c1567 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.3.2' } } diff --git a/contacts/build.gradle b/contacts/build.gradle index f6287b4..9e0e23e 100644 --- a/contacts/build.gradle +++ b/contacts/build.gradle @@ -1,6 +1,5 @@ buildscript { repositories { - jcenter() } dependencies { @@ -8,8 +7,6 @@ buildscript { } plugins { - id "com.jfrog.bintray" version "1.7" - id "com.github.dcendents.android-maven" version "1.5" } apply plugin: 'com.android.library' @@ -35,36 +32,6 @@ android { } } -install { - repositories.mavenInstaller { - pom.project { - packaging 'aar' - name NAME - description DESCRIPTION - url SITE_URL - - licenses { - license { - name LICENCE_NAME - url LICENCE_URL - } - } - developers { - developer { - id DEVELOPER_ID - name DEVELOPER_NAME - email DEVELOPER_EMAIL - } - } - scm { - connection GIT_URL - developerConnection GIT_URL - url SITE_URL - } - } - } - } - task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' @@ -84,24 +51,5 @@ artifacts { archives sourcesJar } -bintray { - user = BINTRAY_USER - key = BINTRAY_API_KEY - - configurations = ['archives'] - pkg { - repo = 'maven' - name = NAME - desc = DESCRIPTION - websiteUrl = SITE_URL - vcsUrl = GIT_URL - issueTrackerUrl = ISSUE_TRACKER_URL - licenses = ['Apache-2.0'] - labels = ['Android', 'Contacts'] - publicDownloadNumbers = true - publish = true - } -} - dependencies { } diff --git a/contacts/src/main/java/com/github/tamir7/contacts/Contact.java b/contacts/src/main/java/com/github/tamir7/contacts/Contact.java index 66d329a..03c8ae5 100644 --- a/contacts/src/main/java/com/github/tamir7/contacts/Contact.java +++ b/contacts/src/main/java/com/github/tamir7/contacts/Contact.java @@ -41,6 +41,7 @@ public final class Contact { private String companyTitle; private final Set websites = new HashSet<>(); private final Set
addresses = new HashSet<>(); + private String note; interface AbstractField { String getMimeType(); @@ -82,6 +83,8 @@ public enum Field implements AbstractField { ContactsContract.CommonDataKinds.Organization.TITLE), Website(ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.Website.URL), + Note(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE, + ContactsContract.CommonDataKinds.Note.NOTE), Address(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS), AddressType(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE, @@ -197,6 +200,11 @@ Contact addWebsite(String website) { return this; } + Contact addNote(String note) { + this.note = note; + return this; + } + Contact addAddress(Address address) { addresses.add(address); return this; @@ -319,6 +327,15 @@ public String getCompanyTitle() { public List getWebsites() { return Arrays.asList(websites.toArray(new String[websites.size()])); } + + /** + * Gets the note of the contact + * + * @return the note + */ + public String getNote() { + return note; + } /** * Gets the list of addresses diff --git a/contacts/src/main/java/com/github/tamir7/contacts/CursorHelper.java b/contacts/src/main/java/com/github/tamir7/contacts/CursorHelper.java index 4b0542d..2fd957d 100644 --- a/contacts/src/main/java/com/github/tamir7/contacts/CursorHelper.java +++ b/contacts/src/main/java/com/github/tamir7/contacts/CursorHelper.java @@ -58,6 +58,10 @@ String getWebsite() { return getString(c, ContactsContract.CommonDataKinds.Website.URL); } + String getNote() { + return getString(c, ContactsContract.CommonDataKinds.Note.NOTE); + } + Address getAddress() { String address = getString(c, ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS); if (address == null) { diff --git a/contacts/src/main/java/com/github/tamir7/contacts/Query.java b/contacts/src/main/java/com/github/tamir7/contacts/Query.java index 77e5deb..cad8535 100644 --- a/contacts/src/main/java/com/github/tamir7/contacts/Query.java +++ b/contacts/src/main/java/com/github/tamir7/contacts/Query.java @@ -318,6 +318,11 @@ private void updateContact(Contact contact, CursorHelper helper) { if (website != null) { contact.addWebsite(website); } + } else if (mimeType.equals(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE)) { + String note = helper.getNote(); + if (note != null) { + contact.addNote(note); + } } else if (mimeType.equals(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE)) { Address address = helper.getAddress(); if (address != null) { From 296f4af29bd500e7361728ab37bfb7eca5b83cf5 Mon Sep 17 00:00:00 2001 From: Conner Simmons Date: Sun, 21 May 2017 15:55:10 -0400 Subject: [PATCH 2/2] contacts/build.gradle back to original --- build.gradle | 2 +- contacts/build.gradle | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e0c1567..98c4c47 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.android.tools.build:gradle:2.3.1' } } diff --git a/contacts/build.gradle b/contacts/build.gradle index 9e0e23e..f6287b4 100644 --- a/contacts/build.gradle +++ b/contacts/build.gradle @@ -1,5 +1,6 @@ buildscript { repositories { + jcenter() } dependencies { @@ -7,6 +8,8 @@ buildscript { } plugins { + id "com.jfrog.bintray" version "1.7" + id "com.github.dcendents.android-maven" version "1.5" } apply plugin: 'com.android.library' @@ -32,6 +35,36 @@ android { } } +install { + repositories.mavenInstaller { + pom.project { + packaging 'aar' + name NAME + description DESCRIPTION + url SITE_URL + + licenses { + license { + name LICENCE_NAME + url LICENCE_URL + } + } + developers { + developer { + id DEVELOPER_ID + name DEVELOPER_NAME + email DEVELOPER_EMAIL + } + } + scm { + connection GIT_URL + developerConnection GIT_URL + url SITE_URL + } + } + } + } + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' @@ -51,5 +84,24 @@ artifacts { archives sourcesJar } +bintray { + user = BINTRAY_USER + key = BINTRAY_API_KEY + + configurations = ['archives'] + pkg { + repo = 'maven' + name = NAME + desc = DESCRIPTION + websiteUrl = SITE_URL + vcsUrl = GIT_URL + issueTrackerUrl = ISSUE_TRACKER_URL + licenses = ['Apache-2.0'] + labels = ['Android', 'Contacts'] + publicDownloadNumbers = true + publish = true + } +} + dependencies { }