Skip to content

Commit

Permalink
Merge pull request #33 from csimmonsbluebook/master
Browse files Browse the repository at this point in the history
Fetch note from the contact
  • Loading branch information
tamir7 authored May 22, 2017
2 parents c21386a + 296f4af commit 7cfa0a7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions contacts/src/main/java/com/github/tamir7/contacts/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class Contact {
private String companyTitle;
private final Set<String> websites = new HashSet<>();
private final Set<Address> addresses = new HashSet<>();
private String note;

interface AbstractField {
String getMimeType();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -319,6 +327,15 @@ public String getCompanyTitle() {
public List<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions contacts/src/main/java/com/github/tamir7/contacts/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7cfa0a7

Please sign in to comment.