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;
}
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;
}
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;
}
}
}
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);
}
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;
}
}
}
Aggregations