Search in sources :

Example 11 with Contact

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();
    }
}
Also used : SpannableString(android.text.SpannableString) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver) Contact(com.android.mms.data.Contact)

Example 12 with Contact

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);
    }
}
Also used : Intent(android.content.Intent) ContactList(com.android.mms.data.ContactList) Contact(com.android.mms.data.Contact) QuickContact(android.provider.ContactsContract.QuickContact)

Example 13 with Contact

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();
    }
}
Also used : SpannableString(android.text.SpannableString) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver) Contact(com.android.mms.data.Contact)

Example 14 with Contact

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;
}
Also used : SpannableString(android.text.SpannableString) Spanned(android.text.Spanned) Contact(com.android.mms.data.Contact)

Aggregations

Contact (com.android.mms.data.Contact)14 SpannableString (android.text.SpannableString)7 ContentResolver (android.content.ContentResolver)6 Uri (android.net.Uri)6 Cursor (android.database.Cursor)5 Intent (android.content.Intent)4 QuickContact (android.provider.ContactsContract.QuickContact)3 ContactList (com.android.mms.data.ContactList)3 ContentValues (android.content.ContentValues)2 Drawable (android.graphics.drawable.Drawable)2 ActionBar (android.app.ActionBar)1 AsyncQueryHandler (android.content.AsyncQueryHandler)1 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 SearchRecentSuggestions (android.provider.SearchRecentSuggestions)1 SmsMessage (android.telephony.SmsMessage)1 Spanned (android.text.Spanned)1 TextPaint (android.text.TextPaint)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1