|
|||||||||
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.NativeContactsApi2
public class NativeContactsApi2
The implementation of the NativeContactsApi for the Android 2.X platform.
Nested Class Summary | |
---|---|
private class |
NativeContactsApi2.BatchOperation
Inner class for applying batches. |
private class |
NativeContactsApi2.NativeContentObserver
This class holds a native content observer that will be notified in case of changes on the registered URI. |
private static interface |
NativeContactsApi2.PeopleProfileColumns
Convenience interface to map the generic DATA column names to the People profile detail column names. |
Nested classes/interfaces inherited from class com.vodafone360.people.engine.contactsync.NativeContactsApi |
---|
NativeContactsApi.Account, NativeContactsApi.ContactsObserver |
Field Summary | |
---|---|
private static java.lang.String[] |
CONTACTID_PROJECTION
Convenience Projection to fetch only a Raw Contact's ID and Native Account Type |
private static int |
CONTACTID_PROJECTION_ACCOUNT_TYPE
Account Type Column for the CONTACTID_PROJECTION Projection |
private static int |
CONTACTID_PROJECTION_RAW_ID
Raw ID Column for the CONTACTID_PROJECTION Projection |
private static java.lang.String[] |
GROUPID_PROJECTION
Group ID Projection |
private NativeContactsApi.ContactsObserver |
mAbstractedObserver
The observer registered by the upper layer. |
private NativeContactsApi2.BatchOperation |
mBatch
Batch used for Contact Writing operations. |
private ContentObserver[] |
mContentObservers
The content observers that listens for native contacts changes. |
private long |
mExistingOrganizationId
Arguably another example where Organization and Title force us into extra effort. |
private boolean |
mHaveReadBirthday
Flag to check if we have already read a Birthday detail |
private long[] |
mMyContactsGroupRowIds
Array of row ID in the groups table to the "My Contacts" System Group. |
private ContentValues |
mValues
Content values used for writing to NAB. |
private static java.lang.String |
MY_CONTACTS_GROUP_WHERE_CLAUSE
'My Contacts' System group where clause |
private static java.lang.String |
MY_CONTACTS_MULTI_GROUP_MEMBERSHIP
'My Contacts' System Group Membership where in clause (Multiple 'My Contacts' IDs) |
private boolean |
mYield
Yield value for our ContentProviderOperations. |
private static java.lang.String |
NULL_ACCOUNT_WHERE_CLAUSE
Selection where clause for a NULL Account |
private static java.lang.String |
ORGANIZATION_DETAIL_WHERE_CLAUSE
Selection where clause for an Organization detail. |
private static |
sFromKeyToNabContentTypeArray
Holds mapping from a VCard Key to a NAB type (MIME) |
private static java.util.HashMap<java.lang.String,java.lang.Integer> |
sFromNabContentTypeToKeyMap
Holds mapping from a NAB type (MIME) to a VCard Key |
private static Uri[] |
sUri
The list of Uri that need to be listened to for contacts changes on native side. |
Fields inherited from class com.vodafone360.people.engine.contactsync.NativeContactsApi |
---|
mContext, mCr, mHaveReadOrganization, mMarkedOrganizationIndex, mMarkedTitleIndex, PEOPLE_ACCOUNT_TYPE |
Constructor Summary | |
---|---|
NativeContactsApi2()
|
Method Summary | |
---|---|
private static Uri |
addCallerIsSyncAdapterParameter(Uri uri)
Static utility method that adds the Sync Adapter flag to the provided URI |
ContactChange[] |
addContact(NativeContactsApi.Account account,
ContactChange[] ccList)
Adds a contact. |
private void |
addDeleteDetailToBatch(long nabDetailId)
Adds a delete detail operation to the batch. |
boolean |
addPeopleAccount(java.lang.String username)
Adds the currently logged in user account to the NAB accounts. |
private void |
addProfileAction(long internalContactId)
Adds the profile action detail to a (assumed) pending new Contact Batch operation. |
private void |
addUpdateValuesToBatch(long nabDetailId)
Adds current update values to the batch. |
private void |
addValuesToBatch(long nabContactId)
Adds current values to the batch. |
private ContactChange[] |
executeNewContactBatch(ContactChange[] ccList)
Executes a pending Batch Operation related to adding a new Contact. |
private ContactChange[] |
executeUpdateContactBatch(ContactChange[] ccList)
Executes a pending Batch Operation related to updating a Contact. |
private void |
fetchMyContactsGroupRowIds()
Fetches the IDs corresponding to the "My Contacts" System Group The reason why we return an array is because there may be multiple "My Contacts" groups. |
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. |
private long[] |
getContactIds(java.lang.String selection)
Inner (private) method for getting contact ids. |
protected void |
initialize()
Method meant to be called only just after createInstance() is invoked. |
private boolean |
isContactInMyContactsGroup(long nabContactId)
Checks if a Contact is in the "My Contacts" System Group |
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 |
mapFromNabAddressType(int nabType)
Maps a address type from the native value into the ContactChange flags |
private static int |
mapFromNabEmailType(int nabType)
Maps a email 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 |
mapFromNabWebsiteType(int nabType)
Maps a Website type from the native value into the ContactChange flags |
private static int |
mapToNabAddressType(int flags)
Maps ContactChange flags into the native address type. |
private static int |
mapToNabEmailType(int flags)
Maps ContactChange flags into the native email 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 int |
mapToNabWebsiteType(int flags)
Maps ContactChange flags into the native Website type. |
private void |
putAddress(ContactChange cc)
Put Address detail into the values |
private void |
putBirthday(ContactChange cc)
Put Birthday detail into the values |
private void |
putDetail(ContactChange cc)
Put values for a detail from a ContactChange into pending values. |
private void |
putEmail(ContactChange cc)
Put Email detail into the values |
private void |
putName(ContactChange cc)
Put Name detail into the values |
private void |
putNickname(ContactChange cc)
Put Nickname detail into the values |
private void |
putNote(ContactChange cc)
Put Note detail into the values |
private void |
putOrganization(ContactChange[] ccList)
Put Organization detail into the values |
private void |
putPhone(ContactChange cc)
Put Phone detail into the values |
private void |
putWebsite(ContactChange cc)
Put Website detail into the values |
private void |
readAddress(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an address detail as a ContactChange from the provided cursor. |
void |
readBirthday(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an Birthday detail as a ContactChange from the provided cursor. |
private void |
readDetail(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads a Contact Detail from a Cursor into the supplied Contact Change List. |
private void |
readEmail(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an email detail as a ContactChange from the provided cursor. |
private void |
readName(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an name detail as a ContactChange from the provided cursor. |
private void |
readNickname(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an nickname detail as a ContactChange from the provided cursor. |
private void |
readOrganization(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an organization detail as a ContactChange from the provided cursor. |
private void |
readPhone(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an phone detail as a ContactChange from the provided cursor. |
private void |
readWebsite(Cursor cursor,
java.util.List<ContactChange> ccList,
long nabContactId)
Reads an Website detail as a ContactChange from the provided cursor. |
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 void |
updateOrganization(ContactChange[] ccList,
long nabContactId)
Updates the Organization detail in the context of a Contact Update operation. |
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 int CONTACTID_PROJECTION_RAW_ID
private static final int CONTACTID_PROJECTION_ACCOUNT_TYPE
private static final java.lang.String[] GROUPID_PROJECTION
private static final java.lang.String MY_CONTACTS_GROUP_WHERE_CLAUSE
private static final java.lang.String MY_CONTACTS_MULTI_GROUP_MEMBERSHIP
private static final java.lang.String NULL_ACCOUNT_WHERE_CLAUSE
private static final java.lang.String ORGANIZATION_DETAIL_WHERE_CLAUSE
private static final Uri[] sUri
private static final java.util.HashMap<java.lang.String,java.lang.Integer> sFromNabContentTypeToKeyMap
private static finalsFromKeyToNabContentTypeArray
private NativeContactsApi.ContactsObserver mAbstractedObserver
private final ContentValues mValues
private final ContentObserver[] mContentObservers
private long[] mMyContactsGroupRowIds
private long mExistingOrganizationId
private boolean mHaveReadBirthday
private boolean mYield
private NativeContactsApi2.BatchOperation mBatch
Constructor Detail |
---|
public NativeContactsApi2()
Method Detail |
---|
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(ContactsObserver)
protected void initialize()
NativeContactsApi
initialize
in class NativeContactsApi
NativeContactsApi.initialize()
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
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 long[] getContactIds(java.lang.String selection)
selection
- The where clause for the operation
private void fetchMyContactsGroupRowIds()
private boolean isContactInMyContactsGroup(long nabContactId)
nabContactId
- ID of the Contact to check
private void readDetail(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
cursor
- Cursor to read fromccList
- List of Contact Changes to read Detail intonabContactId
- NAB ID of the Contactprivate void readName(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
For this type of detail we need to use a VCARD (semicolon separated) value.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readNickname(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readPhone(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readEmail(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readAddress(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
For this type of detail we need to use a VCARD (semicolon separated) value.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readOrganization(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
For this type of detail we need to use a VCARD (semicolon separated) value.
In reality two different changes may be read if a title is also present.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void readWebsite(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactpublic void readBirthday(Cursor cursor, java.util.List<ContactChange> ccList, long nabContactId)
ContactChange
from the provided cursor.
Note that since the Android Type is the Generic "Event",
it may be the case that nothing is read if this is not actually a Birthday
cursor
- Cursor to read fromccList
- List of Contact Changes to add read detail datanabContactId
- ID of the NAB Contactprivate void addValuesToBatch(long nabContactId)
nabContactId
- The existing NAB Contact ID if it is an update or an invalid id if a new contactprivate void addUpdateValuesToBatch(long nabDetailId)
nabDetailId
- The NAB ID of the detail to updateprivate void addDeleteDetailToBatch(long nabDetailId)
nabDetailId
- The NAB Id of the detail to deleteprivate void addProfileAction(long internalContactId)
internalContactId
- The Internal Contact ID used as the Profile IDprivate void putDetail(ContactChange cc)
ContactChange
into pending values.
cc
- ContactChange
to read values fromprivate void putName(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putNickname(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putPhone(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putEmail(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putAddress(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putWebsite(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putNote(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putBirthday(ContactChange cc)
cc
- ContactChange
to read values fromprivate void putOrganization(ContactChange[] ccList)
cc
- ContactChange
to read values fromprivate void updateOrganization(ContactChange[] ccList, long nabContactId)
ccList
- ContactChange
list where Organization and Title may be foundnabContactId
- The NAB ID of the Contactprivate ContactChange[] executeNewContactBatch(ContactChange[] ccList)
ccList
- The original ContactChange
for the new Contact
ContactChange
array containing new IDs (may contain some null elements)private ContactChange[] executeUpdateContactBatch(ContactChange[] ccList)
ccList
- The original ContactChange
for the Contact update
ContactChange
array containing new IDs (may contain some null elements)private static Uri addCallerIsSyncAdapterParameter(Uri uri)
uri
- URI to add the flag to
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 mapFromNabEmailType(int nabType)
ContactChange
flags
nabType
- Native email type
ContactChange
flagsprivate static int mapToNabEmailType(int flags)
ContactChange
flags into the native email type.
flags
- ContactChange
flags
private static int mapFromNabAddressType(int nabType)
ContactChange
flags
nabType
- Native email type
ContactChange
flagsprivate static int mapToNabAddressType(int flags)
ContactChange
flags into the native address 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 int mapFromNabWebsiteType(int nabType)
ContactChange
flags
nabType
- Native email type
ContactChange
flagsprivate static int mapToNabWebsiteType(int flags)
ContactChange
flags into the native Website type.
flags
- ContactChange
flags
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc