use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class MessagingNotification method addSmsNotificationInfos.
private static final void addSmsNotificationInfos(Context context, Set<Long> threads, SortedSet<NotificationInfo> notificationSet) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = SqliteWrapper.query(context, resolver, Sms.CONTENT_URI, SMS_STATUS_PROJECTION, NEW_INCOMING_SM_CONSTRAINT, null, Sms.DATE + " desc");
if (cursor == null) {
return;
}
try {
while (cursor.moveToNext()) {
String address = cursor.getString(COLUMN_SMS_ADDRESS);
Contact contact = Contact.get(address, false);
if (contact.getSendToVoicemail()) {
// don't notify, skip this one
continue;
}
String message = cursor.getString(COLUMN_SMS_BODY);
long threadId = cursor.getLong(COLUMN_THREAD_ID);
long timeMillis = cursor.getLong(COLUMN_DATE);
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "addSmsNotificationInfos: count=" + cursor.getCount() + ", addr=" + address + ", thread_id=" + threadId);
}
NotificationInfo info = getNewMessageNotificationInfo(context, true, /* isSms */
address, message, null, /* subject */
threadId, timeMillis, null, /* attachmentBitmap */
contact, WorkingMessage.TEXT);
notificationSet.add(info);
threads.add(threadId);
threads.add(cursor.getLong(COLUMN_THREAD_ID));
}
} finally {
cursor.close();
}
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class ComposeMessageActivity method buildAddAddressToContactMenuItem.
private void buildAddAddressToContactMenuItem(Menu menu) {
// bug #7087793: for group of recipients, remove "Add to People" action. Rely on
// individually creating contacts for unknown phone numbers by touching the individual
// sender's avatars, one at a time
ContactList contacts = getRecipients();
if (contacts.size() != 1) {
return;
}
// if we don't have a contact for the recipient, create a menu item to add the number
// to contacts.
Contact c = contacts.get(0);
if (!c.existsInDatabase() && canAddToContacts(c)) {
Intent intent = ConversationList.createAddContactIntent(c.getNumber());
menu.add(0, MENU_ADD_ADDRESS_TO_CONTACTS, 0, R.string.menu_add_to_contacts).setIcon(android.R.drawable.ic_menu_add).setIntent(intent);
}
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class MessagingNotification method getSmsNewDeliveryInfo.
private static final MmsSmsDeliveryInfo getSmsNewDeliveryInfo(Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = SqliteWrapper.query(context, resolver, Sms.CONTENT_URI, SMS_STATUS_PROJECTION, NEW_DELIVERY_SM_CONSTRAINT, null, Sms.DATE);
if (cursor == null) {
return null;
}
try {
if (!cursor.moveToLast()) {
return null;
}
String address = cursor.getString(COLUMN_SMS_ADDRESS);
long timeMillis = 3000;
Contact contact = Contact.get(address, false);
String name = contact.getNameAndNumber();
return new MmsSmsDeliveryInfo(context.getString(R.string.delivery_toast_body, name), timeMillis);
} finally {
cursor.close();
}
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class RecipientsEditor method getContextMenuInfo.
@Override
protected ContextMenuInfo getContextMenuInfo() {
if ((mLongPressedPosition >= 0)) {
Spanned text = getText();
if (mLongPressedPosition <= text.length()) {
int start = mTokenizer.findTokenStart(text, mLongPressedPosition);
int end = mTokenizer.findTokenEnd(text, start);
if (end != start) {
String number = getNumberAt(getText(), start, end, getContext());
Contact c = Contact.get(number, false);
return new RecipientContextMenuInfo(c);
}
}
}
return null;
}
Aggregations