Skip to content

Commit

Permalink
Add company name and title
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixsm committed May 17, 2017
1 parent b04d9a4 commit 41cde83
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion contacts/src/main/java/com/github/tamir7/contacts/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public final class Contact {
private String displayName;
private String givenName;
private String familyName;

private final Set<PhoneNumber> phoneNumbers = new HashSet<>();
private String photoUri;
private final Set<Email> emails = new HashSet<>();
private final Set<Event> events = new HashSet<>();
private String companyName;
private String companyTitle;

interface AbstractField {
String getMimeType();
Expand Down Expand Up @@ -69,7 +72,11 @@ public enum Field implements AbstractField {
EventType(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE,
ContactsContract.CommonDataKinds.Event.TYPE),
EventLabel(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE,
ContactsContract.CommonDataKinds.Event.LABEL);
ContactsContract.CommonDataKinds.Event.LABEL),
CompanyName(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE,
ContactsContract.CommonDataKinds.Organization.COMPANY),
CompanyTitle(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE,
ContactsContract.CommonDataKinds.Organization.TITLE);

private final String column;
private final String mimeType;
Expand Down Expand Up @@ -154,6 +161,16 @@ Contact addEvent(Event event) {
return this;
}

Contact addCompanyName(String companyName) {
this.companyName = companyName;
return this;
}

Contact addCompanyTitle(String companyTitle) {
this.companyTitle = companyTitle;
return this;
}

/**
* Gets a the phone contact id.
*
Expand Down Expand Up @@ -245,6 +262,24 @@ public Event getAnniversary() {

}

/**
* Gets the name of the company the contact works on
*
* @return the company name
*/
public String getCompanyName() {
return companyName;
}

/**
* Gets the job title of the contact
*
* @return the job title
*/
public String getCompanyTitle() {
return companyTitle;
}

private Event getEvent(Event.Type type) {
for (Event event: events) {
if (type.equals(event.getType())) {
Expand Down

0 comments on commit 41cde83

Please sign in to comment.