Search in sources :

Example 1 with SlideModel

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

the class SlideEditorActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case MENU_PREVIEW_SLIDESHOW:
            previewSlideshow();
            break;
        case MENU_REMOVE_TEXT:
            SlideModel slide = mSlideshowModel.get(mPosition);
            if (slide != null) {
                slide.removeText();
            }
            break;
        case MENU_ADD_PICTURE:
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
            intent.setType(ContentType.IMAGE_UNSPECIFIED);
            startActivityForResult(intent, REQUEST_CODE_CHANGE_PICTURE);
            break;
        case MENU_TAKE_PICTURE:
            MessageUtils.capturePicture(this, REQUEST_CODE_TAKE_PICTURE);
            break;
        case MENU_DEL_PICTURE:
            mSlideshowEditor.removeImage(mPosition);
            setReplaceButtonText(R.string.add_picture);
            break;
        case MENU_ADD_AUDIO:
            MessageUtils.selectAudio(this, REQUEST_CODE_CHANGE_MUSIC);
            break;
        case MENU_RECORD_SOUND:
            slide = mSlideshowModel.get(mPosition);
            int currentSlideSize = slide.getSlideSize();
            long sizeLimit = ComposeMessageActivity.computeAttachmentSizeLimit(mSlideshowModel, currentSlideSize);
            MessageUtils.recordSound(this, REQUEST_CODE_RECORD_SOUND, sizeLimit);
            break;
        case MENU_DEL_AUDIO:
            mSlideshowEditor.removeAudio(mPosition);
            break;
        case MENU_ADD_VIDEO:
            intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType(ContentType.VIDEO_UNSPECIFIED);
            intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
            startActivityForResult(intent, REQUEST_CODE_CHANGE_VIDEO);
            break;
        case MENU_TAKE_VIDEO:
            slide = mSlideshowModel.get(mPosition);
            currentSlideSize = slide.getSlideSize();
            sizeLimit = ComposeMessageActivity.computeAttachmentSizeLimit(mSlideshowModel, 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 MENU_DEL_VIDEO:
            mSlideshowEditor.removeVideo(mPosition);
            break;
        case MENU_ADD_SLIDE:
            mPosition++;
            if (mSlideshowEditor.addNewSlide(mPosition)) {
                // add successfully
                showCurrentSlide();
            } else {
                // move position back
                mPosition--;
                Toast.makeText(this, R.string.cannot_add_slide_anymore, Toast.LENGTH_SHORT).show();
            }
            break;
        case MENU_LAYOUT:
            showLayoutSelectorDialog();
            break;
        case MENU_DURATION:
            showDurationDialog();
            break;
    }
    return true;
}
Also used : Intent(android.content.Intent) SlideModel(com.android.mms.model.SlideModel)

Example 2 with SlideModel

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

the class SlideEditorActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (isFinishing()) {
        return false;
    }
    menu.clear();
    SlideModel slide = mSlideshowModel.get(mPosition);
    if (slide == null) {
        return false;
    }
    // Preview slideshow.
    menu.add(0, MENU_PREVIEW_SLIDESHOW, 0, R.string.preview_slideshow).setIcon(this.getResources().getSystem().getIdentifier("ic_menu_play_clip", "drawable", "android"));
    // Text
    if (slide.hasText() && !TextUtils.isEmpty(slide.getText().getText())) {
        // "Change text" if text is set.
        menu.add(0, MENU_REMOVE_TEXT, 0, R.string.remove_text).setIcon(R.drawable.ic_menu_remove_text);
    }
    // Picture
    if (slide.hasImage()) {
        menu.add(0, MENU_DEL_PICTURE, 0, R.string.remove_picture).setIcon(R.drawable.ic_menu_remove_picture);
    } else if (!slide.hasVideo()) {
        menu.add(0, MENU_ADD_PICTURE, 0, R.string.add_picture).setIcon(R.drawable.ic_menu_picture);
        menu.add(0, MENU_TAKE_PICTURE, 0, R.string.attach_take_photo).setIcon(R.drawable.ic_menu_picture);
    }
    // Music
    if (slide.hasAudio()) {
        menu.add(0, MENU_DEL_AUDIO, 0, R.string.remove_music).setIcon(R.drawable.ic_menu_remove_sound);
    } else if (!slide.hasVideo()) {
        if (MmsConfig.getAllowAttachAudio()) {
            SubMenu subMenu = menu.addSubMenu(0, MENU_SUB_AUDIO, 0, R.string.add_music).setIcon(R.drawable.ic_menu_add_sound);
            subMenu.add(0, MENU_ADD_AUDIO, 0, R.string.attach_sound);
            subMenu.add(0, MENU_RECORD_SOUND, 0, R.string.attach_record_sound);
        } else {
            menu.add(0, MENU_RECORD_SOUND, 0, R.string.attach_record_sound).setIcon(R.drawable.ic_menu_add_sound);
        }
    }
    // Video
    if (slide.hasVideo()) {
        menu.add(0, MENU_DEL_VIDEO, 0, R.string.remove_video).setIcon(R.drawable.ic_menu_remove_video);
    } else if (!slide.hasAudio() && !slide.hasImage()) {
        menu.add(0, MENU_ADD_VIDEO, 0, R.string.add_video).setIcon(R.drawable.ic_menu_movie);
        menu.add(0, MENU_TAKE_VIDEO, 0, R.string.attach_record_video).setIcon(R.drawable.ic_menu_movie);
    }
    // Add slide
    menu.add(0, MENU_ADD_SLIDE, 0, R.string.add_slide).setIcon(R.drawable.ic_menu_add_slide);
    // Slide duration
    String duration = getResources().getString(R.string.duration_sec);
    menu.add(0, MENU_DURATION, 0, duration.replace("%s", String.valueOf(slide.getDuration() / 1000))).setIcon(R.drawable.ic_menu_duration);
    // Slide layout
    int resId;
    if (mSlideshowModel.getLayout().getLayoutType() == LayoutModel.LAYOUT_TOP_TEXT) {
        resId = R.string.layout_top;
    } else {
        resId = R.string.layout_bottom;
    }
    // FIXME: set correct icon when layout icon is available.
    menu.add(0, MENU_LAYOUT, 0, resId).setIcon(R.drawable.ic_menu_picture);
    return true;
}
Also used : SubMenu(android.view.SubMenu) SlideModel(com.android.mms.model.SlideModel)

Example 3 with SlideModel

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

the class SlideshowEditor method addNewSlide.

/**
 * Add a new slide at the specified position in the message.
 *
 * @return true if success, false if reach the max slide number.
 * @throws IndexOutOfBoundsException - if position is out of range
 *         (position < 0 || position > size()).
 */
public boolean addNewSlide(int position) {
    int size = mModel.size();
    if (size < MAX_SLIDE_NUM) {
        SlideModel slide = new SlideModel(mModel);
        TextModel text = new TextModel(mContext, ContentType.TEXT_PLAIN, "text_" + size + ".txt", mModel.getLayout().getTextRegion());
        slide.add(text);
        mModel.add(position, slide);
        return true;
    } else {
        Log.w(TAG, "The limitation of the number of slides is reached.");
        return false;
    }
}
Also used : TextModel(com.android.mms.model.TextModel) SlideModel(com.android.mms.model.SlideModel)

Example 4 with SlideModel

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

the class SlideshowEditor method changeVideo.

public void changeVideo(int position, Uri newVideo) throws MmsException {
    VideoModel video = new VideoModel(mContext, newVideo, mModel.getLayout().getImageRegion());
    SlideModel slide = mModel.get(position);
    slide.add(video);
    slide.updateDuration(video.getDuration());
}
Also used : SlideModel(com.android.mms.model.SlideModel) VideoModel(com.android.mms.model.VideoModel)

Example 5 with SlideModel

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

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