Search in sources :

Example 96 with ContactDetail

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, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 97 with ContactDetail

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, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) NativeIdInfo(com.vodafone360.people.database.tables.ContactDetailsTable.NativeIdInfo) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 98 with ContactDetail

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));
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 99 with ContactDetail

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);
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) TimelineSummaryItem(com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem) Date(java.util.Date) Contact(com.vodafone360.people.datatypes.Contact)

Example 100 with ContactDetail

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;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

ContactDetail (com.vodafone360.people.datatypes.ContactDetail)109 Contact (com.vodafone360.people.datatypes.Contact)60 ServiceStatus (com.vodafone360.people.service.ServiceStatus)57 ArrayList (java.util.ArrayList)33 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)24 MediumTest (android.test.suitebuilder.annotation.MediumTest)24 Cursor (android.database.Cursor)20 Suppress (android.test.suitebuilder.annotation.Suppress)16 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)15 ContentValues (android.content.ContentValues)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)10 SQLException (android.database.SQLException)8 Uri (android.net.Uri)7 SQLiteException (android.database.sqlite.SQLiteException)6 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)6 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)6 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)4 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)4 Date (java.util.Date)4