|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.engine.contactsync.NativeContactsApi com.vodafone360.people.engine.contactsync.NativeContactsApi1
public class NativeContactsApi1
The implementation of the NativeContactsApi for the Android 1.X platform.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.vodafone360.people.engine.contactsync.NativeContactsApi |
---|
NativeContactsApi.Account, NativeContactsApi.ContactsObserver |
Field Summary | |
---|---|
private static int |
CONTACT_METHODS_KIND_ADDRESS
Contact methods table kind value for postal address. |
private static int |
CONTACT_METHODS_KIND_EMAIL
Contact methods table kind value for email. |
private static java.lang.String[] |
CONTACTID_PROJECTION
Convenience Contact ID Projection. |
private NativeContactsApi.ContactsObserver |
mContactsObserver
The registered ContactsObserver. |
private ContentObserver |
mNativeObserver
The observer for the native contacts. |
private ContentValues |
mValues
Values used for writing to NAB |
private static java.lang.String[] |
PEOPLE_PROJECTION
Convenience Projection for the NATE and NOTES from the People table |
private static SparseIntArray |
sSupportedKeys
Mapping of supported ContactChange Keys. |
Fields inherited from class com.vodafone360.people.engine.contactsync.NativeContactsApi |
---|
mContext, mCr, mHaveReadOrganization, mMarkedOrganizationIndex, mMarkedTitleIndex, PEOPLE_ACCOUNT_TYPE |
Constructor Summary | |
---|---|
NativeContactsApi1()
|
Method Summary | |
---|---|
ContactChange[] |
addContact(NativeContactsApi.Account account,
ContactChange[] ccList)
Adds a contact. |
boolean |
addPeopleAccount(java.lang.String username)
Adds the currently logged in user account to the NAB accounts. |
private boolean |
deleteDetail(int key,
long nabContactId,
long nabDetailId)
Deletes a detail from NAB |
NativeContactsApi.Account[] |
getAccounts()
Fetches all the existing Accounts on the device. |
NativeContactsApi.Account[] |
getAccountsByType(java.lang.String type)
Fetches all the existing Accounts on the device corresponding to the provided Type Only supported on 2.X. |
ContactChange[] |
getContact(long nabContactId)
Gets data for one Contact. |
long[] |
getContactIds(NativeContactsApi.Account account)
Retrieves a list of contact IDs for a specific account. |
protected void |
initialize()
Method meant to be called only just after createInstance() is invoked. |
private long |
insertDetail(ContactChange cc,
long nabContactId)
Inserts a new detail to NAB |
boolean |
isKeySupported(int key)
Checks whether or not a ContactChange key is supported. |
boolean |
isPeopleAccountCreated()
Checks if there is a People Account in the NAB Accounts. |
private static int |
mapFromNabContactMethodType(int nabType)
Maps a method type from the native value into the ContactChange flags |
private static int |
mapFromNabOrganizationType(int nabType)
Maps a organization type from the native value into the ContactChange flags |
private static int |
mapFromNabPhoneType(int nabType)
Maps a phone type from the native value to the ContactChange flags. |
private static int |
mapToNabContactMethodType(int flags)
Maps ContactChange flags into the native method type. |
private static int |
mapToNabOrganizationType(int flags)
Maps ContactChange flags into the native organization type. |
private static int |
mapToNabPhoneType(int flags)
Maps ContactChange flags into the native phone type. |
private static VCardHelper.PostalAddress |
parseRawAddress(java.lang.String rawAddress)
Utility method used to parse a raw display Address into a VCardHelper.PostalAddress object. |
private void |
preprocessContactToAdd(ContactChange[] ccList)
"Pre-processing" of ContactChange list before it can be added to NAB. |
private void |
processOrganization(ContactChange[] ccList,
ContactChange[] idChangeList,
long nabContactId)
Ugly method to process organization for writing to NAB |
private void |
putContactMethodValues(ContactChange cc,
int kind,
long nabContactId)
Put Contact Methods detail into the values |
private void |
putPhoneValues(ContactChange cc,
long nabContactId)
Put Phone detail into the values |
private ContactChange |
readContactMethod(Cursor cursor)
Reads one Contact Method Detail from the supplied cursor into a ContactChange |
private void |
readContactMethods(java.util.List<ContactChange> ccList,
long nabContactId)
Reads Contact Method details from a Contact into the provided ContactChange List |
private void |
readContactOrganization(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads one Organization Detail from the supplied cursor into a ContactChange
Note that this method may actually read up to 2 into Contact Changes. |
private void |
readContactOrganizations(java.util.List<ContactChange> ccList,
long nabContactId)
Reads Organization details from a Contact into the provided ContactChange List |
private ContactChange |
readContactPhoneNumber(Cursor cursor)
Reads one Phone Number Detail from the supplied cursor into a ContactChange |
private void |
readContactPhoneNumbers(java.util.List<ContactChange> ccList,
long nabContactId)
Reads Phone Number details from a Contact into the provided ContactChange List |
void |
registerObserver(NativeContactsApi.ContactsObserver observer)
Registers a content observer. |
void |
removeContact(long nabContactId)
Removes a contact |
void |
removePeopleAccount()
Removes the (first found) People Account from the NAB accounts. |
void |
unregisterObserver()
Unregister the previously registered content observer. |
ContactChange[] |
updateContact(ContactChange[] ccList)
Updates an existing contact. |
private boolean |
updateDetail(ContactChange cc)
Updates a detail. |
private long |
updateOrganization(ContactChange[] ccList,
long nabContactId)
Updates the Organization detail in the context of a Contact Update operation. |
private void |
writeDetails(ContactChange[] ccList,
ContactChange[] idChangeList,
long nabContactId)
Writes new details from a provided ContactChange list into the NAB. |
private long |
writeOrganization(ContactChange[] ccList,
long nabContactId)
Write Organization detail to NAB |
Methods inherited from class com.vodafone360.people.engine.contactsync.NativeContactsApi |
---|
createInstance, destroyInstance, getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String[] CONTACTID_PROJECTION
private static final java.lang.String[] PEOPLE_PROJECTION
private static final int CONTACT_METHODS_KIND_EMAIL
private static final int CONTACT_METHODS_KIND_ADDRESS
private static final SparseIntArray sSupportedKeys
ContactChange
Keys.
private final ContentValues mValues
private NativeContactsApi.ContactsObserver mContactsObserver
NativeContactsApi.registerObserver(ContactsObserver)
private ContentObserver mNativeObserver
Constructor Detail |
---|
public NativeContactsApi1()
Method Detail |
---|
protected void initialize()
NativeContactsApi
initialize
in class NativeContactsApi
NativeContactsApi.initialize()
public void registerObserver(NativeContactsApi.ContactsObserver observer)
NativeContactsApi
registerObserver
in class NativeContactsApi
observer
- ContactsObserver currently observing native address book changesNativeContactsApi.registerObserver(ContactsObserver)
public void unregisterObserver()
NativeContactsApi
unregisterObserver
in class NativeContactsApi
NativeContactsApi.unregisterObserver()
public NativeContactsApi.Account[] getAccounts()
NativeContactsApi
getAccounts
in class NativeContactsApi
NativeContactsApi.getAccounts()
public NativeContactsApi.Account[] getAccountsByType(java.lang.String type)
NativeContactsApi
getAccountsByType
in class NativeContactsApi
type
- The Type of Account to fetch
NativeContactsApi.getAccountsByType(String)
public boolean addPeopleAccount(java.lang.String username)
NativeContactsApi
addPeopleAccount
in class NativeContactsApi
NativeContactsApi.addPeopleAccount(String)
public boolean isPeopleAccountCreated()
NativeContactsApi
isPeopleAccountCreated
in class NativeContactsApi
NativeContactsApi.isPeopleAccountCreated()
public void removePeopleAccount()
NativeContactsApi
removePeopleAccount
in class NativeContactsApi
NativeContactsApi.removePeopleAccount()
public long[] getContactIds(NativeContactsApi.Account account)
NativeContactsApi
getContactIds
in class NativeContactsApi
account
- The account to get contact IDs from (may be null)
NativeContactsApi.getContactIds(Account)
public ContactChange[] getContact(long nabContactId)
NativeContactsApi
getContact
in class NativeContactsApi
nabContactId
- Native ID for the contact
ContactChange
array with contact's data or nullNativeContactsApi.getContact(long)
public ContactChange[] addContact(NativeContactsApi.Account account, ContactChange[] ccList)
NativeContactsApi
addContact
in class NativeContactsApi
account
- Account to be associated with the added contact (may be null).ccList
- The Contact data as a ContactChange
array
ContactChange
array with contact's new ID data or null in case of failure.NativeContactsApi.addContact(Account, ContactChange[])
public ContactChange[] updateContact(ContactChange[] ccList)
NativeContactsApi
updateContact
in class NativeContactsApi
ccList
- The Contact update data as a ContactChange
array
ContactChange
array with the contact's new ID data or nullNativeContactsApi.updateContact(ContactChange[])
public void removeContact(long nabContactId)
NativeContactsApi
removeContact
in class NativeContactsApi
nabContactId
- Native ID of the contact to removeNativeContactsApi.removeContact(long)
public boolean isKeySupported(int key)
NativeContactsApi
ContactChange
key is supported.
Results may vary in 1.X and 2.X
isKeySupported
in class NativeContactsApi
key
- Key to check for support
NativeContactsApi.isKeySupported(int)
private void readContactPhoneNumbers(java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
List
ccList
- ContactChange
list to add details intonabContactId
- ID of the NAB Contactprivate ContactChange readContactPhoneNumber(Cursor cursor)
ContactChange
cursor
- Cursor to read from
private void readContactMethods(java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
List
ccList
- ContactChange
list to add details intonabContactId
- ID of the NAB Contactprivate ContactChange readContactMethod(Cursor cursor)
ContactChange
cursor
- Cursor to read from
private void readContactOrganizations(java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
List
ccList
- ContactChange
list to add details intonabContactId
- ID of the NAB Contactprivate void readContactOrganization(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
Note that this method may actually read up to 2 into Contact Changes.
However, Organization and Title may only be read if a boolean flag is not set
cursor
- Cursor to read fromccList
- ContactChange
list to add details toprivate void preprocessContactToAdd(ContactChange[] ccList)
ContactChange
list before it can be added to NAB.
This needs to be done because of issues on the 1.X NAB and our CAB
In 1.X NAB: Name and Note which are stored differently from other details
In our CAB: Organization and Title are separate details contrary to the NAB
ccList
- ContactChange
list for the add operationprivate void writeDetails(ContactChange[] ccList, ContactChange[] idChangeList, long nabContactId)
ContactChange
list into the NAB.
The resulting detail IDs are put in another provided ContactChange
list.
ccList
- ContactChange
list to write fromidChangeList
- ContatChange
list where IDs for the written details are putnabContactId
- ID of the NAB Contactprivate long insertDetail(ContactChange cc, long nabContactId)
cc
- ContactChange
to read data fromnabContactId
- ID of the NAB Contact
private boolean updateDetail(ContactChange cc)
cc
- ContactChange
to read data fromnabContactId
- ID of the NAB Contact
private boolean deleteDetail(int key, long nabContactId, long nabDetailId)
key
- The detail keynabContactId
- ID of the NAB ContactnabDetailId
- ID of the NAB Detail
private void putPhoneValues(ContactChange cc, long nabContactId)
cc
- nabContactId
- ID of the NAB Contactprivate void putContactMethodValues(ContactChange cc, int kind, long nabContactId)
cc
- ContactChange
to read values fromkind
- The kind of contact method (email or address)nabContactId
- ID of the NAB Contactprivate void processOrganization(ContactChange[] ccList, ContactChange[] idChangeList, long nabContactId)
ccList
- ContactChange
list to fetch organization fromidChangeList
- ContatChange
list where IDs for the written organization are putnabContactId
- ID of the NAB Contactprivate long writeOrganization(ContactChange[] ccList, long nabContactId)
ccList
- ContactChange
list where Organization and Title are foundnabContactId
- ID of the NAB Contact
private long updateOrganization(ContactChange[] ccList, long nabContactId)
ccList
- ContactChange
list where Organization and Title may be foundnabContactId
- The NAB ID of the Contact
private static int mapFromNabPhoneType(int nabType)
ContactChange
flags.
nabType
- Given native phone number type
ContactChange
flagsprivate static int mapToNabPhoneType(int flags)
ContactChange
flags into the native phone type.
flags
- ContactChange
flags
private static int mapFromNabContactMethodType(int nabType)
ContactChange
flags
nabType
- Native method type
ContactChange
flagsprivate static int mapToNabContactMethodType(int flags)
ContactChange
flags into the native method type.
flags
- ContactChange
flags
private static int mapFromNabOrganizationType(int nabType)
ContactChange
flags
nabType
- Given native organization type
ContactChange
flagsprivate static int mapToNabOrganizationType(int flags)
ContactChange
flags into the native organization type.
flags
- ContactChange
flags
private static VCardHelper.PostalAddress parseRawAddress(java.lang.String rawAddress)
VCardHelper.PostalAddress
object.
The purpose of this method is simply to remove '\n' separators.
It does not aim to correctly map
address components to the right place, e.g. it is not guaranteed
that 'PostalAddress.Country' will really be the Country.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc