Search in sources :

Example 1 with SlideshowModel

use of com.android.mms.model.SlideshowModel in project android-aosp-mms by slvn.

the class MmsThumbnailPresenter method present.

@Override
public void present(ItemLoadedCallback callback) {
    mOnLoadedCallback = callback;
    SlideModel slide = ((SlideshowModel) mModel).get(0);
    if (slide != null) {
        presentFirstSlide((SlideViewInterface) mView, slide);
    }
}
Also used : SlideshowModel(com.android.mms.model.SlideshowModel) SlideModel(com.android.mms.model.SlideModel)

Example 2 with SlideshowModel

use of com.android.mms.model.SlideshowModel in project android-aosp-mms by slvn.

the class MessagingNotification method addMmsNotificationInfos.

private static final void addMmsNotificationInfos(Context context, Set<Long> threads, SortedSet<NotificationInfo> notificationSet) {
    ContentResolver resolver = context.getContentResolver();
    // This query looks like this when logged:
    // I/Database(  147): elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/
    // mmssms.db|0.362 ms|SELECT thread_id, date, _id, sub, sub_cs FROM pdu WHERE ((msg_box=1
    // AND seen=0 AND (m_type=130 OR m_type=132))) ORDER BY date desc
    Cursor cursor = SqliteWrapper.query(context, resolver, Mms.CONTENT_URI, MMS_STATUS_PROJECTION, NEW_INCOMING_MM_CONSTRAINT, null, Mms.DATE + " desc");
    if (cursor == null) {
        return;
    }
    try {
        while (cursor.moveToNext()) {
            long msgId = cursor.getLong(COLUMN_MMS_ID);
            Uri msgUri = Mms.CONTENT_URI.buildUpon().appendPath(Long.toString(msgId)).build();
            String address = AddressUtils.getFrom(context, msgUri);
            Contact contact = Contact.get(address, false);
            if (contact.getSendToVoicemail()) {
                // don't notify, skip this one
                continue;
            }
            String subject = getMmsSubject(cursor.getString(COLUMN_SUBJECT), cursor.getInt(COLUMN_SUBJECT_CS));
            subject = MessageUtils.cleanseMmsSubject(context, subject);
            long threadId = cursor.getLong(COLUMN_THREAD_ID);
            long timeMillis = cursor.getLong(COLUMN_DATE) * 1000;
            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                Log.d(TAG, "addMmsNotificationInfos: count=" + cursor.getCount() + ", addr = " + address + ", thread_id=" + threadId);
            }
            // Extract the message and/or an attached picture from the first slide
            Bitmap attachedPicture = null;
            String messageBody = null;
            int attachmentType = WorkingMessage.TEXT;
            try {
                GenericPdu pdu = sPduPersister.load(msgUri);
                if (pdu != null && pdu instanceof MultimediaMessagePdu) {
                    SlideshowModel slideshow = SlideshowModel.createFromPduBody(context, ((MultimediaMessagePdu) pdu).getBody());
                    attachmentType = getAttachmentType(slideshow);
                    SlideModel firstSlide = slideshow.get(0);
                    if (firstSlide != null) {
                        if (firstSlide.hasImage()) {
                            int maxDim = dp2Pixels(MAX_BITMAP_DIMEN_DP);
                            attachedPicture = firstSlide.getImage().getBitmap(maxDim, maxDim);
                        }
                        if (firstSlide.hasText()) {
                            messageBody = firstSlide.getText().getText();
                        }
                    }
                }
            } catch (final MmsException e) {
                Log.e(TAG, "MmsException loading uri: " + msgUri, e);
                // skip this bad boy -- don't generate an empty notification
                continue;
            }
            NotificationInfo info = getNewMessageNotificationInfo(context, false, /* isSms */
            address, messageBody, subject, threadId, timeMillis, attachedPicture, contact, attachmentType);
            notificationSet.add(info);
            threads.add(threadId);
        }
    } finally {
        cursor.close();
    }
}
Also used : MultimediaMessagePdu(com.google.android.mms.pdu.MultimediaMessagePdu) SpannableString(android.text.SpannableString) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) Contact(com.android.mms.data.Contact) Bitmap(android.graphics.Bitmap) MmsException(com.google.android.mms.MmsException) SlideshowModel(com.android.mms.model.SlideshowModel) GenericPdu(com.google.android.mms.pdu.GenericPdu) SlideModel(com.android.mms.model.SlideModel)

Example 3 with SlideshowModel

use of com.android.mms.model.SlideshowModel in project android-aosp-mms by slvn.

the class WorkingMessage method ensureSlideshow.

/**
 * Makes sure mSlideshow is set up.
 */
private void ensureSlideshow() {
    if (mSlideshow != null) {
        return;
    }
    SlideshowModel slideshow = SlideshowModel.createNew(mActivity);
    SlideModel slide = new SlideModel(slideshow);
    slideshow.add(slide);
    mSlideshow = slideshow;
}
Also used : SlideshowModel(com.android.mms.model.SlideshowModel) SlideModel(com.android.mms.model.SlideModel)

Example 4 with SlideshowModel

use of com.android.mms.model.SlideshowModel in project android-aosp-mms by slvn.

the class WorkingMessage method send.

/**
 * Send this message over the network.  Will call back with onMessageSent() once
 * it has been dispatched to the telephony stack.  This WorkingMessage object is
 * no longer useful after this method has been called.
 *
 * @throws ContentRestrictionException if sending an MMS and uaProfUrl is not defined
 * in mms_config.xml.
 */
public void send(final String recipientsInUI) {
    long origThreadId = mConversation.getThreadId();
    if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
        LogTag.debug("send origThreadId: " + origThreadId);
    }
    removeSubjectIfEmpty(true);
    // Get ready to write to disk.
    prepareForSave(true);
    // We need the recipient list for both SMS and MMS.
    final Conversation conv = mConversation;
    String msgTxt = mText.toString();
    if (requiresMms() || addressContainsEmailToMms(conv, msgTxt)) {
        // However, SMS service will still work in the absence of a uaProfUrl address.
        if (MmsConfig.getUaProfUrl() == null) {
            String err = "WorkingMessage.send MMS sending failure. mms_config.xml is " + "missing uaProfUrl setting.  uaProfUrl is required for MMS service, " + "but can be absent for SMS.";
            RuntimeException ex = new NullPointerException(err);
            Log.e(TAG, err, ex);
            // now, let's just crash.
            throw ex;
        }
        // Make local copies of the bits we need for sending a message,
        // because we will be doing it off of the main thread, which will
        // immediately continue on to resetting some of this state.
        final Uri mmsUri = mMessageUri;
        final PduPersister persister = PduPersister.getPduPersister(mActivity);
        final SlideshowModel slideshow = mSlideshow;
        final CharSequence subject = mSubject;
        final boolean textOnly = mAttachmentType == TEXT;
        if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
            LogTag.debug("Send mmsUri: " + mmsUri);
        }
        // Do the dirty work of sending the message off of the main UI thread.
        new Thread(new Runnable() {

            @Override
            public void run() {
                final SendReq sendReq = makeSendReq(conv, subject);
                // Make sure the text in slide 0 is no longer holding onto a reference to
                // the text in the message text box.
                slideshow.prepareForSend();
                sendMmsWorker(conv, mmsUri, persister, slideshow, sendReq, textOnly);
                updateSendStats(conv);
            }
        }, "WorkingMessage.send MMS").start();
    } else {
        // Same rules apply as above.
        final String msgText = mText.toString();
        new Thread(new Runnable() {

            @Override
            public void run() {
                preSendSmsWorker(conv, msgText, recipientsInUI);
                updateSendStats(conv);
            }
        }, "WorkingMessage.send SMS").start();
    }
    // update the Recipient cache with the new to address, if it's different
    RecipientIdCache.updateNumbers(conv.getThreadId(), conv.getRecipients());
    // Mark the message as discarded because it is "off the market" after being sent.
    mDiscarded = true;
}
Also used : PduPersister(com.google.android.mms.pdu.PduPersister) Uri(android.net.Uri) SendReq(com.google.android.mms.pdu.SendReq) SlideshowModel(com.android.mms.model.SlideshowModel)

Example 5 with SlideshowModel

use of com.android.mms.model.SlideshowModel in project android-aosp-mms by slvn.

the class ComposeMessageActivity method addAttachment.

// static class SystemProperties { // TODO, temp class to get unbundling working
// static int getInt(String s, int value) {
// return value;       // just return the default value or now
// }
// }
private void addAttachment(int type, boolean replace) {
    // Calculate the size of the current slide if we're doing a replace so the
    // slide size can optionally be used in computing how much room is left for an attachment.
    int currentSlideSize = 0;
    SlideshowModel slideShow = mWorkingMessage.getSlideshow();
    if (replace && slideShow != null) {
        WorkingMessage.removeThumbnailsFromCache(slideShow);
        SlideModel slide = slideShow.get(0);
        currentSlideSize = slide.getSlideSize();
    }
    switch(type) {
        case AttachmentTypeSelectorAdapter.ADD_IMAGE:
            MessageUtils.selectImage(this, REQUEST_CODE_ATTACH_IMAGE);
            break;
        case AttachmentTypeSelectorAdapter.TAKE_PICTURE:
            {
                MessageUtils.capturePicture(this, REQUEST_CODE_TAKE_PICTURE);
                break;
            }
        case AttachmentTypeSelectorAdapter.ADD_VIDEO:
            MessageUtils.selectVideo(this, REQUEST_CODE_ATTACH_VIDEO);
            break;
        case AttachmentTypeSelectorAdapter.RECORD_VIDEO:
            {
                long sizeLimit = computeAttachmentSizeLimit(slideShow, currentSlideSize);
                if (sizeLimit > 0) {
                    MessageUtils.recordVideo(this, REQUEST_CODE_TAKE_VIDEO, sizeLimit);
                } else {
                    Toast.makeText(this, getString(R.string.message_too_big_for_video), Toast.LENGTH_SHORT).show();
                }
            }
            break;
        case AttachmentTypeSelectorAdapter.ADD_SOUND:
            MessageUtils.selectAudio(this, REQUEST_CODE_ATTACH_SOUND);
            break;
        case AttachmentTypeSelectorAdapter.RECORD_SOUND:
            long sizeLimit = computeAttachmentSizeLimit(slideShow, currentSlideSize);
            MessageUtils.recordSound(this, REQUEST_CODE_RECORD_SOUND, sizeLimit);
            break;
        case AttachmentTypeSelectorAdapter.ADD_SLIDESHOW:
            editSlideshow();
            break;
        default:
            break;
    }
}
Also used : SlideshowModel(com.android.mms.model.SlideshowModel) SlideModel(com.android.mms.model.SlideModel)

Aggregations

SlideshowModel (com.android.mms.model.SlideshowModel)8 Uri (android.net.Uri)5 SlideModel (com.android.mms.model.SlideModel)4 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)2 MmsException (com.google.android.mms.MmsException)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Parcelable (android.os.Parcelable)1 Contact (com.android.mms.data.Contact)1 LayoutModel (com.android.mms.model.LayoutModel)1 RegionModel (com.android.mms.model.RegionModel)1 GenericPdu (com.google.android.mms.pdu.GenericPdu)1 MultimediaMessagePdu (com.google.android.mms.pdu.MultimediaMessagePdu)1 PduPersister (com.google.android.mms.pdu.PduPersister)1 SendReq (com.google.android.mms.pdu.SendReq)1 PduCacheEntry (com.google.android.mms.util.PduCacheEntry)1