Search in sources :

Example 1 with TimelineSummaryItem

use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem in project 360-Engine-for-Android by 360.

the class DatabaseHelper method deleteTimelineActivity.

/**
 * Removes the selected timeline activity from the database.
 *
 * @param application The MainApplication
 * @param timelineItem TimelineSummaryItem to be deleted
 * @return SUCCESS or a suitable error code
 */
public ServiceStatus deleteTimelineActivity(MainApplication application, TimelineSummaryItem timelineItem, boolean isTimelineAll) {
    if (Settings.ENABLED_DATABASE_TRACE)
        trace(false, "DatabaseHelper.deleteTimelineActivity()");
    ServiceStatus status = ServiceStatus.SUCCESS;
    if (isTimelineAll) {
        status = ActivitiesTable.deleteTimelineActivities(mContext, timelineItem, getWritableDatabase(), getReadableDatabase());
    } else {
        status = ActivitiesTable.deleteTimelineActivity(mContext, timelineItem, getWritableDatabase(), getReadableDatabase());
    }
    if (status == ServiceStatus.SUCCESS) {
        // Update Notifications in the Notification Bar
        IPeopleService peopleService = application.getServiceInterface();
        long localContactId = 0L;
        if (timelineItem.mLocalContactId != null) {
            localContactId = timelineItem.mLocalContactId;
        }
        peopleService.updateChatNotification(localContactId);
    }
    fireDatabaseChangedEvent(DatabaseChangeType.ACTIVITIES, true);
    return status;
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) IPeopleService(com.vodafone360.people.service.interfaces.IPeopleService)

Example 2 with TimelineSummaryItem

use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem in project 360-Engine-for-Android by 360.

the class MmsDecoder method getMmsData.

/**
 * Get the MMS data for the message at current Cursor position and use it to
 * populate a TimelineSummaryItem. We initially check if the MMS is an Inbox
 * or sent item returning false if this is not the case.
 *
 * @param context Context.
 * @param cr ContentResolver.
 * @param mmsCursor Cursor pointing to MMS message entry in native message
 *            log.
 * @param item TimeLineSummaryItem to populate using MMS message details
 * @param db Handle to People database.
 * @param maxDescLength maximum length of the description.
 * @return true if we have created the TimelineSummaryItem false if we
 *         haven't (because the MMS is not of a valid type).
 */
protected static boolean getMmsData(Context context, ContentResolver cr, Cursor mmsCursor, TimelineSummaryItem item, DatabaseHelper db, int maxDescLength) {
    int msgId = mmsCursor.getInt(COLUMN_MMS_ID);
    Uri msgUri = MMS_CONTENT_URI.buildUpon().appendPath(Long.toString(msgId)).build();
    ActivityItem.Type type = nativeToNpMessageType(mmsCursor.getInt(COLUMN_MSG_BOX));
    if (type == null) {
        return false;
    }
    String address = getToOrFrom(cr, type, msgUri);
    String sub = mmsCursor.getString(COLUMN_SUBJECT);
    int subcs = mmsCursor.getInt(COLUMN_SUBJECT_CS);
    String subject = TextUtils.isEmpty(sub) ? "" : decodeString(subcs, getMmsBytes(sub));
    item.mTimestamp = mmsCursor.getLong(COLUMN_DATE) * MS_IN_SECONDS;
    item.mNativeItemId = msgId;
    item.mNativeItemType = TimelineNativeTypes.MmsLog.ordinal();
    item.mType = type;
    item.mNativeThreadId = mmsCursor.getInt(COLUMN_MSG_THREAD_ID);
    item.mContactAddress = address;
    if (subject.length() > 0) {
        if (subject.length() <= maxDescLength) {
            item.mDescription = subject;
        } else {
            item.mDescription = subject.substring(0, maxDescLength) + ELLIPSIZE;
        }
    } else {
        item.mDescription = getMmsText(cr, msgId, maxDescLength);
    }
    item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
    Contact c = new Contact();
    ContactDetail phoneDetail = new ContactDetail();
    ServiceStatus status = db.fetchContactInfo(address, c, phoneDetail);
    if (ServiceStatus.SUCCESS == status) {
        item.mContactId = c.contactID;
        item.mLocalContactId = c.localContactID;
        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 = d.getName().toString();
                    }
                    break;
                case VCARD_IMADDRESS:
                    item.mContactNetwork = d.alt;
                    break;
                default:
                    // do nothing.
                    break;
            }
        }
    } else {
        item.mContactName = address;
    }
    return true;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) Uri(android.net.Uri) ActivityItem(com.vodafone360.people.datatypes.ActivityItem) Date(java.util.Date) Contact(com.vodafone360.people.datatypes.Contact)

Example 3 with TimelineSummaryItem

use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem in project 360-Engine-for-Android by 360.

the class FetchCallLogEvents method updateTimeStamps.

/**
 * This method goes through the event list and updates the current newest
 * and oldest phone call timestamps.
 */
private void updateTimeStamps() {
    if (mSyncItemList.size() > 0) {
        long max = ((TimelineSummaryItem) mSyncItemList.get(0)).mTimestamp;
        long min = max;
        for (TimelineSummaryItem item : mSyncItemList) {
            if (item.mTimestamp > max) {
                max = item.mTimestamp;
            }
            if (item.mTimestamp < min) {
                min = item.mTimestamp;
            }
        }
        if (mNewestPhoneCall < max) {
            mNewestPhoneCall = max;
        }
        if (mOldestPhoneCall > min) {
            mOldestPhoneCall = min;
        }
    }
}
Also used : TimelineSummaryItem(com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)

Example 4 with TimelineSummaryItem

use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem in project 360-Engine-for-Android by 360.

the class FetchSmsLogEvents method addSmsData.

/**
 * Create TimelineSummaryItem from Native message-log item.
 *
 * @param id ID of item from Native log.
 */
private void addSmsData(int id) {
    ActivityItem.Type type = nativeToNpTypeConvert(mSmsCursor.getInt(COLUMN_SMS_TYPE));
    if (type == null) {
        return;
    }
    TimelineSummaryItem item = new TimelineSummaryItem();
    String address = null;
    /* Francisco: Unknown contact SMS sending bug resolved here
         * I am keeping previous case SN_MESSAGE_RECEIVED besides MESSAGE_SMS_RECEIVED just to be safe.
         */
    if (type == ActivityItem.Type.SN_MESSAGE_RECEIVED || type == ActivityItem.Type.MESSAGE_SMS_RECEIVED) {
        item.mIncoming = TimelineSummaryItem.Type.INCOMING;
    } else {
        item.mIncoming = TimelineSummaryItem.Type.OUTGOING;
    }
    item.mNativeItemId = id;
    item.mNativeItemType = ActivitiesTable.TimelineNativeTypes.SmsLog.ordinal();
    item.mType = type;
    item.mTimestamp = mSmsCursor.getLong(COLUMN_SMS_DATE);
    item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
    item.mNativeThreadId = mSmsCursor.getInt(COLUMN_SMS_THREAD_ID);
    item.mDescription = null;
    if (!mSmsCursor.isNull(COLUMN_SMS_SUBJECT)) {
        item.mDescription = mSmsCursor.getString(COLUMN_SMS_SUBJECT);
    }
    if (item.mDescription == null || item.mDescription.length() == 0) {
        if (!mSmsCursor.isNull(COLUMN_SMS_BODY)) {
            item.mDescription = mSmsCursor.getString(COLUMN_SMS_BODY);
        }
    }
    if (!mSmsCursor.isNull(COLUMN_SMS_ADDRESS)) {
        address = mSmsCursor.getString(COLUMN_SMS_ADDRESS);
    }
    item.mContactName = address;
    item.mContactAddress = address;
    Contact c = new Contact();
    ContactDetail phoneDetail = new ContactDetail();
    ServiceStatus status = mDb.fetchContactInfo(address, 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 = d.getName().toString();
                    }
                    break;
                case VCARD_IMADDRESS:
                    item.mContactNetwork = d.alt;
                    break;
                default:
                    // do nothing
                    break;
            }
        }
    }
    if (item.mContactId == null) {
        LogUtils.logI("FetchSmsLogEvents.addSmsData: id " + item.mNativeItemId + ", time " + item.mTitle + ", description " + item.mDescription);
    } else {
        LogUtils.logI("FetchSmsLogEvents.addSmsData: id " + item.mNativeItemId + ", name = " + item.mContactName + ", time " + item.mTitle + ", description " + 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) ActivityItem(com.vodafone360.people.datatypes.ActivityItem) Date(java.util.Date) Contact(com.vodafone360.people.datatypes.Contact)

Example 5 with TimelineSummaryItem

use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem in project 360-Engine-for-Android by 360.

the class FetchSmsLogEvents method updateTimestamps.

/**
 * This method goes through the event list and updates the current newest
 * and oldest message timestamps.
 */
private void updateTimestamps() {
    if (mSyncItemList.size() > 0) {
        long max = ((TimelineSummaryItem) mSyncItemList.get(0)).mTimestamp;
        long min = max;
        for (TimelineSummaryItem item : mSyncItemList) {
            if (item.mTimestamp > max) {
                max = item.mTimestamp;
            }
            if (item.mTimestamp < min) {
                min = item.mTimestamp;
            }
        }
        if (mNewestMessage < max) {
            mNewestMessage = max;
        }
        if (mOldestMessage > min) {
            mOldestMessage = min;
        }
    }
}
Also used : TimelineSummaryItem(com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)

Aggregations

TimelineSummaryItem (com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)12 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)7 ServiceStatus (com.vodafone360.people.service.ServiceStatus)7 Cursor (android.database.Cursor)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)4 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)4 Suppress (android.test.suitebuilder.annotation.Suppress)3 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)3 Contact (com.vodafone360.people.datatypes.Contact)3 TimelineNativeTypes (com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes)2 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)1 IPeopleService (com.vodafone360.people.service.interfaces.IPeopleService)1