use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testfixPreferredDetail.
@MediumTest
public void testfixPreferredDetail() {
final String fnName = "testfixPreferredDetail";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Adds a contact details to the contacts details table, validating all the way");
startSubTest(fnName, "Creating table");
createTable();
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
ContactDetail detail = new ContactDetail();
detail.key = ContactDetail.DetailKeys.VCARD_PHONE;
detail.setTel("07967 123456", ContactDetail.DetailKeyTypes.CELL);
// not preferred detail
detail.order = 50;
detail.localContactID = TestModule.generateRandomLong();
ServiceStatus status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
status = ContactDetailsTable.fixPreferredValues(detail.localContactID, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
// fetch deleted detail (should be null)
ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(detail.localDetailID, readableDb);
// detail is now preferred
assertEquals(0, fetchedDetail.order.intValue());
Log.i(LOG_TAG, "***********************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "***********************************************");
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testContactsMatch.
@MediumTest
public void testContactsMatch() {
final String fnName = "testContactsMatch";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates doContactsMatch method");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
Contact contact = mTestModule.createDummyContactData();
contact.localContactID = TestModule.generateRandomLong();
startSubTest(fnName, "Creating table");
createTable();
List<NativeIdInfo> detailIdList = new ArrayList<NativeIdInfo>();
assertFalse(ContactDetailsTable.doContactsMatch(contact, contact.localContactID, detailIdList, readableDb));
ServiceStatus status;
for (ContactDetail cd : contact.details) {
cd.localContactID = contact.localContactID;
status = ContactDetailsTable.addContactDetail(cd, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
}
// assertTrue(ContactDetailsTable.doContactsMatch(contact,
// contact.localContactID, detailIdList, readableDb));
Log.i(LOG_TAG, "***********************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "***********************************************");
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testDeletingContactDetails.
/**
* Tests deleting a contact detail of an existing contact.
*/
@SmallTest
public void testDeletingContactDetails() {
Log.i(LOG_TAG, "***** EXECUTING testDeletingContactDetails *****");
Log.i(LOG_TAG, "Create ContactSummaryTable");
ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Create also a ContactDetailsTable");
ContactDetailsTable.create(mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
final Contact contact = new Contact();
contact.localContactID = new Long(10);
contact.nativeContactId = new Integer(11);
ServiceStatus serviceStatus = ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
Log.i(LOG_TAG, "Add a contact detail to the previous contact");
ContactDetail contactDetail = new ContactDetail();
contactDetail.localContactID = contact.localContactID;
final String eMail = "toto@mail.co.uk";
contactDetail.setEmail(eMail, ContactDetail.DetailKeyTypes.HOME);
boolean isMe = false;
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
Log.i(LOG_TAG, "Delete a contact detail from the previous contact");
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class FetchCallLogEvents method addCallLogData.
/**
* Create TimelineSummaryItem from Native call-log item.
*
* @param id ID of item from Native log.
*/
private void addCallLogData(int id) {
TimelineSummaryItem item = new TimelineSummaryItem();
final String phoneNo = mNativeCursor.getString(COLUMN_CALLLOG_PHONE);
item.mNativeItemId = id;
item.mNativeItemType = ActivitiesTable.TimelineNativeTypes.CallLog.ordinal();
item.mType = nativeTypeToNpType(mNativeCursor.getInt(COLUMN_CALLLOG_TYPE));
item.mTimestamp = mNativeCursor.getLong(COLUMN_CALLLOG_DATE);
item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
item.mDescription = null;
if (phoneNo.compareToIgnoreCase(NATIVE_NUMBER_UNKNOWN_STRING) != 0 && phoneNo.compareToIgnoreCase(NATIVE_NUMBER_PRIVATE_STRING) != 0) {
item.mContactName = PhoneNumberUtils.formatNumber(phoneNo);
item.mContactAddress = phoneNo;
} else {
item.mContactName = null;
item.mContactAddress = null;
}
Contact c = new Contact();
ContactDetail phoneDetail = new ContactDetail();
ServiceStatus status = mDb.fetchContactInfo(phoneNo, c, phoneDetail);
if (ServiceStatus.SUCCESS == status) {
item.mLocalContactId = c.localContactID;
item.mContactId = c.contactID;
item.mUserId = c.userID;
item.mContactName = null;
for (ContactDetail d : c.details) {
switch(d.key) {
case VCARD_NAME:
final VCardHelper.Name name = d.getName();
if (name != null) {
item.mContactName = name.toString();
}
break;
case VCARD_IMADDRESS:
item.mContactNetwork = d.alt;
break;
default:
// do nothing
break;
}
}
item.mDescription = ServiceUtils.getDetailTypeString(mContext.getResources(), phoneDetail.keyType) + " " + phoneNo;
}
if (item.mContactId == null) {
LogUtils.logI("FetchCallLogEvents.addCallLogData: id " + item.mNativeItemId + ", time " + item.mTitle + ", number " + item.mContactName);
} else {
LogUtils.logI("FetchCallLogEvents.addCallLogData: id " + item.mNativeItemId + ", name = " + item.mContactName + ", time " + item.mTitle + ", number " + item.mDescription);
}
mSyncItemList.add(item);
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class DownloadServerContacts method syncContactChangesPage.
/**
* Processes the response from the server. First separates new contacts from
* existing ones, this is to optimise adding new contacts during first time
* sync.
*
* @param changes The contact change information received from the server
* @return SUCCESS or a suitable error code
*/
private ServiceStatus syncContactChangesPage(ContactChanges changes) {
mContactsChangedList.clear();
int i = 0;
for (Contact contact : changes.mContacts) {
i += 1;
updateProgressUi(contact, i);
if (Settings.ENABLED_CONTACTS_SYNC_TRACE) {
if (contact.details.size() == 0 || contact.deleted != null) {
LogUtils.logD("Contact In: " + contact.contactID + ", Del: " + contact.deleted + ", details: " + contact.details.size());
}
for (ContactDetail detail : contact.details) {
LogUtils.logD("Contact In: " + contact.contactID + ", Detail: " + detail.key + ", " + detail.unique_id + ", " + detail.keyType + " = " + detail.value + ", del = " + detail.deleted);
}
}
if (mServerIdSet.contains(contact.contactID)) {
mContactsChangedList.add(contact);
} else {
if (contact.deleted != null && contact.deleted.booleanValue()) {
if (EXTRA_DEBUG_TRACE) {
LogUtils.logD("DownloadServerContacts.syncDownContact() " + "Delete Contact (nothing to do) " + contact.contactID);
}
} else if (contact.details.size() > 0) {
if (EXTRA_DEBUG_TRACE) {
LogUtils.logD("DownloadServerContacts.syncDownContact() Adding " + contact.contactID);
}
mAddContactList.add(contact);
mSyncDataPending = true;
} else {
if (EXTRA_DEBUG_TRACE) {
LogUtils.logD("DownloadServerContacts.syncDownContact() Empty " + contact.contactID);
}
}
}
}
if (mSyncDataPending || mContactsChangedList.size() > 0) {
setTimeout(TIMEOUT_BETWEEN_PAGES_MS);
}
return ServiceStatus.SUCCESS;
}
Aggregations