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();
}
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();
}
}
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;
}
}
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();
}
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);
}
Aggregations