Search in sources :

Example 6 with SlideshowModel

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

the class ComposeMessageActivity method handleSendIntent.

// Handle send actions, where we're told to send a picture(s) or text.
private boolean handleSendIntent() {
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras == null) {
        return false;
    }
    final String mimeType = intent.getType();
    String action = intent.getAction();
    if (Intent.ACTION_SEND.equals(action)) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            getAsyncDialog().runAsync(new Runnable() {

                @Override
                public void run() {
                    addAttachment(mimeType, uri, false);
                }
            }, null, R.string.adding_attachments_title);
            return true;
        } else if (extras.containsKey(Intent.EXTRA_TEXT)) {
            mWorkingMessage.setText(extras.getString(Intent.EXTRA_TEXT));
            return true;
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && extras.containsKey(Intent.EXTRA_STREAM)) {
        SlideshowModel slideShow = mWorkingMessage.getSlideshow();
        final ArrayList<Parcelable> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
        int currentSlideCount = slideShow != null ? slideShow.size() : 0;
        int importCount = uris.size();
        if (importCount + currentSlideCount > SlideshowEditor.MAX_SLIDE_NUM) {
            importCount = Math.min(SlideshowEditor.MAX_SLIDE_NUM - currentSlideCount, importCount);
            Toast.makeText(ComposeMessageActivity.this, getString(R.string.too_many_attachments, SlideshowEditor.MAX_SLIDE_NUM, importCount), Toast.LENGTH_LONG).show();
        }
        // Attach all the pictures/videos asynchronously off of the UI thread.
        // Show a progress dialog if adding all the slides hasn't finished
        // within half a second.
        final int numberToImport = importCount;
        getAsyncDialog().runAsync(new Runnable() {

            @Override
            public void run() {
                for (int i = 0; i < numberToImport; i++) {
                    Parcelable uri = uris.get(i);
                    addAttachment(mimeType, (Uri) uri, true);
                }
            }
        }, null, R.string.adding_attachments_title);
        return true;
    }
    return false;
}
Also used : SlideshowModel(com.android.mms.model.SlideshowModel) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Parcelable(android.os.Parcelable) SpannableString(android.text.SpannableString) Uri(android.net.Uri)

Example 7 with SlideshowModel

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

the class SlideshowActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mHandler = new Handler();
    // Play slide-show in full-screen mode.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.slideshow);
    Intent intent = getIntent();
    Uri msg = intent.getData();
    final SlideshowModel model;
    try {
        model = SlideshowModel.createFromMessageUri(this, msg);
        mSlideCount = model.size();
    } catch (MmsException e) {
        Log.e(TAG, "Cannot present the slide show.", e);
        finish();
        return;
    }
    mSlideView = (SlideView) findViewById(R.id.slide_view);
    PresenterFactory.getPresenter("SlideshowPresenter", this, mSlideView, model);
    mHandler.post(new Runnable() {

        private boolean isRotating() {
            return mSmilPlayer.isPausedState() || mSmilPlayer.isPlayingState() || mSmilPlayer.isPlayedState();
        }

        public void run() {
            mSmilPlayer = SmilPlayer.getPlayer();
            if (mSlideCount > 1) {
                // Only show the slideshow controller if we have more than a single slide.
                // Otherwise, when we play a sound on a single slide, it appears like
                // the slide controller should control the sound (seeking, ff'ing, etc).
                initMediaController();
                mSlideView.setMediaController(mMediaController);
            }
            // Use SmilHelper.getDocument() to ensure rebuilding the
            // entire SMIL document.
            mSmilDoc = SmilHelper.getDocument(model);
            if (isMMSConformance(mSmilDoc)) {
                int imageLeft = 0;
                int imageTop = 0;
                int textLeft = 0;
                int textTop = 0;
                LayoutModel layout = model.getLayout();
                if (layout != null) {
                    RegionModel imageRegion = layout.getImageRegion();
                    if (imageRegion != null) {
                        imageLeft = imageRegion.getLeft();
                        imageTop = imageRegion.getTop();
                    }
                    RegionModel textRegion = layout.getTextRegion();
                    if (textRegion != null) {
                        textLeft = textRegion.getLeft();
                        textTop = textRegion.getTop();
                    }
                }
                mSlideView.enableMMSConformanceMode(textLeft, textTop, imageLeft, imageTop);
            }
            if (DEBUG) {
                ByteArrayOutputStream ostream = new ByteArrayOutputStream();
                SmilXmlSerializer.serialize(mSmilDoc, ostream);
                if (LOCAL_LOGV) {
                    Log.v(TAG, ostream.toString());
                }
            }
            // Add event listener.
            ((EventTarget) mSmilDoc).addEventListener(SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);
            mSmilPlayer.init(mSmilDoc);
            if (isRotating()) {
                mSmilPlayer.reload();
            } else {
                mSmilPlayer.play();
            }
        }
    });
}
Also used : MmsException(com.google.android.mms.MmsException) SlideshowModel(com.android.mms.model.SlideshowModel) Handler(android.os.Handler) Intent(android.content.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) RegionModel(com.android.mms.model.RegionModel) LayoutModel(com.android.mms.model.LayoutModel)

Example 8 with SlideshowModel

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

the class PduLoaderManager method getPdu.

public ItemLoadedFuture getPdu(Uri uri, boolean requestSlideshow, final ItemLoadedCallback<PduLoaded> callback) {
    if (uri == null) {
        throw new NullPointerException();
    }
    PduCacheEntry cacheEntry = null;
    synchronized (mPduCache) {
        if (!mPduCache.isUpdating(uri)) {
            cacheEntry = mPduCache.get(uri);
        }
    }
    final SlideshowModel slideshow = (requestSlideshow && !DEBUG_DISABLE_CACHE) ? mSlideshowCache.get(uri) : null;
    final boolean slideshowExists = (!requestSlideshow || slideshow != null);
    final boolean pduExists = (cacheEntry != null && cacheEntry.getPdu() != null);
    final boolean taskExists = mPendingTaskUris.contains(uri);
    final boolean newTaskRequired = (!pduExists || !slideshowExists) && !taskExists;
    final boolean callbackRequired = (callback != null);
    if (pduExists && slideshowExists) {
        if (callbackRequired) {
            PduLoaded pduLoaded = new PduLoaded(cacheEntry.getPdu(), slideshow);
            callback.onItemLoaded(pduLoaded, null);
        }
        return new NullItemLoadedFuture();
    }
    if (callbackRequired) {
        addCallback(uri, callback);
    }
    if (newTaskRequired) {
        mPendingTaskUris.add(uri);
        Runnable task = new PduTask(uri, requestSlideshow);
        mExecutor.execute(task);
    }
    return new ItemLoadedFuture() {

        private boolean mIsDone;

        public void cancel(Uri uri) {
            cancelCallback(callback);
            // the pdu and/or slideshow might be half loaded. Make sure
            removePdu(uri);
        // we load fresh the next time this uri is requested.
        }

        public void setIsDone(boolean done) {
            mIsDone = done;
        }

        public boolean isDone() {
            return mIsDone;
        }
    };
}
Also used : SlideshowModel(com.android.mms.model.SlideshowModel) PduCacheEntry(com.google.android.mms.util.PduCacheEntry) Uri(android.net.Uri)

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