Search in sources :

Example 11 with SlideModel

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

the class WorkingMessage method syncTextFromSlideshow.

/**
 * Sets the message text out of the slideshow.  Should be called any time
 * a slideshow is loaded from disk.
 */
private void syncTextFromSlideshow() {
    // Don't sync text for real slideshows.
    if (mSlideshow.size() != 1) {
        return;
    }
    SlideModel slide = mSlideshow.get(0);
    if (slide == null || !slide.hasText()) {
        return;
    }
    mText = slide.getText().getText();
}
Also used : SlideModel(com.android.mms.model.SlideModel)

Example 12 with SlideModel

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

the class AttachmentEditor method createView.

private SlideViewInterface createView() {
    boolean inPortrait = inPortraitMode();
    if (mSlideshow.size() > 1) {
        return createSlideshowView(inPortrait);
    }
    SlideModel slide = mSlideshow.get(0);
    if (slide.hasImage()) {
        return createMediaView(R.id.image_attachment_view_stub, R.id.image_attachment_view, R.id.view_image_button, R.id.replace_image_button, R.id.remove_image_button, MSG_VIEW_IMAGE, MSG_REPLACE_IMAGE, MSG_REMOVE_ATTACHMENT);
    } else if (slide.hasVideo()) {
        return createMediaView(R.id.video_attachment_view_stub, R.id.video_attachment_view, R.id.view_video_button, R.id.replace_video_button, R.id.remove_video_button, MSG_PLAY_VIDEO, MSG_REPLACE_VIDEO, MSG_REMOVE_ATTACHMENT);
    } else if (slide.hasAudio()) {
        return createMediaView(R.id.audio_attachment_view_stub, R.id.audio_attachment_view, R.id.play_audio_button, R.id.replace_audio_button, R.id.remove_audio_button, MSG_PLAY_AUDIO, MSG_REPLACE_AUDIO, MSG_REMOVE_ATTACHMENT);
    } else {
        throw new IllegalArgumentException();
    }
}
Also used : SlideModel(com.android.mms.model.SlideModel)

Example 13 with SlideModel

use of com.android.mms.model.SlideModel 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)

Example 14 with SlideModel

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

the class MessageListItem method bindCommonMessage.

private void bindCommonMessage(final boolean sameItem) {
    if (mDownloadButton != null) {
        mDownloadButton.setVisibility(View.GONE);
        mDownloadingLabel.setVisibility(View.GONE);
    }
    // Since the message text should be concatenated with the sender's
    // address(or name), I have to display it here instead of
    // displaying it by the Presenter.
    mBodyTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    boolean haveLoadedPdu = mMessageItem.isSms() || mMessageItem.mSlideshow != null;
    // from onPduLoaded, it will reset to the real avatar. This test is to avoid that flash.
    if (!sameItem || haveLoadedPdu) {
        boolean isSelf = Sms.isOutgoingFolder(mMessageItem.mBoxId);
        String addr = isSelf ? null : mMessageItem.mAddress;
        updateAvatarView(addr, isSelf);
    }
    // Get and/or lazily set the formatted message from/on the
    // MessageItem.  Because the MessageItem instances come from a
    // cache (currently of size ~50), the hit rate on avoiding the
    // expensive formatMessage() call is very high.
    CharSequence formattedMessage = mMessageItem.getCachedFormattedMessage();
    if (formattedMessage == null) {
        formattedMessage = formatMessage(mMessageItem, mMessageItem.mBody, mMessageItem.mSubject, mMessageItem.mHighlight, mMessageItem.mTextContentType);
        mMessageItem.setCachedFormattedMessage(formattedMessage);
    }
    if (!sameItem || haveLoadedPdu) {
        mBodyTextView.setText(formattedMessage);
    }
    // Debugging code to put the URI of the image attachment in the body of the list item.
    if (DEBUG) {
        String debugText = null;
        if (mMessageItem.mSlideshow == null) {
            debugText = "NULL slideshow";
        } else {
            SlideModel slide = mMessageItem.mSlideshow.get(0);
            if (slide == null) {
                debugText = "NULL first slide";
            } else if (!slide.hasImage()) {
                debugText = "Not an image";
            } else {
                debugText = slide.getImage().getUri().toString();
            }
        }
        mBodyTextView.setText(mPosition + ": " + debugText);
    }
    // string in place of the timestamp.
    if (!sameItem || haveLoadedPdu) {
        mDateView.setText(buildTimestampLine(mMessageItem.isSending() ? mContext.getResources().getString(R.string.sending_message) : mMessageItem.mTimestamp));
    }
    if (mMessageItem.isSms()) {
        showMmsView(false);
        mMessageItem.setOnPduLoaded(null);
    } else {
        if (DEBUG) {
            Log.v(TAG, "bindCommonMessage for item: " + mPosition + " " + mMessageItem.toString() + " mMessageItem.mAttachmentType: " + mMessageItem.mAttachmentType + " sameItem: " + sameItem);
        }
        if (mMessageItem.mAttachmentType != WorkingMessage.TEXT) {
            if (!sameItem) {
                setImage(null, null);
            }
            setOnClickListener(mMessageItem);
            drawPlaybackButton(mMessageItem);
        } else {
            showMmsView(false);
        }
        if (mMessageItem.mSlideshow == null) {
            mMessageItem.setOnPduLoaded(new MessageItem.PduLoadedCallback() {

                public void onPduLoaded(MessageItem messageItem) {
                    if (DEBUG) {
                        Log.v(TAG, "PduLoadedCallback in MessageListItem for item: " + mPosition + " " + (mMessageItem == null ? "NULL" : mMessageItem.toString()) + " passed in item: " + (messageItem == null ? "NULL" : messageItem.toString()));
                    }
                    if (messageItem != null && mMessageItem != null && messageItem.getMessageId() == mMessageItem.getMessageId()) {
                        mMessageItem.setCachedFormattedMessage(null);
                        bindCommonMessage(true);
                    }
                }
            });
        } else {
            if (mPresenter == null) {
                mPresenter = PresenterFactory.getPresenter("MmsThumbnailPresenter", mContext, this, mMessageItem.mSlideshow);
            } else {
                mPresenter.setModel(mMessageItem.mSlideshow);
                mPresenter.setView(this);
            }
            if (mImageLoadedCallback == null) {
                mImageLoadedCallback = new ImageLoadedCallback(this);
            } else {
                mImageLoadedCallback.reset(this);
            }
            mPresenter.present(mImageLoadedCallback);
        }
    }
    drawRightStatusIndicator(mMessageItem);
    requestLayout();
}
Also used : SlideModel(com.android.mms.model.SlideModel)

Example 15 with SlideModel

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

the class MessageUtils method viewSimpleSlideshow.

public static void viewSimpleSlideshow(Context context, SlideshowModel slideshow) {
    if (!slideshow.isSimple()) {
        throw new IllegalArgumentException("viewSimpleSlideshow() called on a non-simple slideshow");
    }
    SlideModel slide = slideshow.get(0);
    MediaModel mm = null;
    if (slide.hasImage()) {
        mm = slide.getImage();
    } else if (slide.hasVideo()) {
        mm = slide.getVideo();
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    // So we don't see "surrounding" images in Gallery
    intent.putExtra("SingleItemOnly", true);
    String contentType;
    contentType = mm.getContentType();
    intent.setDataAndType(mm.getUri(), contentType);
    context.startActivity(intent);
}
Also used : MediaModel(com.android.mms.model.MediaModel) Intent(android.content.Intent) SlideModel(com.android.mms.model.SlideModel)

Aggregations

SlideModel (com.android.mms.model.SlideModel)17 SlideshowModel (com.android.mms.model.SlideshowModel)4 TextModel (com.android.mms.model.TextModel)3 Intent (android.content.Intent)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 SpannableString (android.text.SpannableString)1 SubMenu (android.view.SubMenu)1 Contact (com.android.mms.data.Contact)1 AudioModel (com.android.mms.model.AudioModel)1 MediaModel (com.android.mms.model.MediaModel)1 VideoModel (com.android.mms.model.VideoModel)1 ThumbnailManager (com.android.mms.util.ThumbnailManager)1 MmsException (com.google.android.mms.MmsException)1 GenericPdu (com.google.android.mms.pdu.GenericPdu)1 MultimediaMessagePdu (com.google.android.mms.pdu.MultimediaMessagePdu)1