172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project/*
272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Copyright (C) 2008 Esmertec AG.
372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * you may not use this file except in compliance with the License.
772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * You may obtain a copy of the License at
872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
1072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
1172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
1272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
1372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * See the License for the specific language governing permissions and
1572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * limitations under the License.
1672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project */
1772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
1872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectpackage com.android.mms.ui;
1972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
2072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport com.android.mms.R;
21b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrickimport com.android.mms.data.WorkingMessage;
2272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport com.android.mms.model.SlideModel;
2372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport com.android.mms.model.SlideshowModel;
2472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
2572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.content.Context;
26fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylorimport android.content.res.Configuration;
2772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.os.Handler;
2872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.os.Message;
29b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrickimport android.util.AttributeSet;
30b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrickimport android.util.Log;
3172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.view.View;
3272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.view.ViewStub;
3372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.widget.Button;
3472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.widget.ImageButton;
3572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectimport android.widget.LinearLayout;
3672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
3772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project/**
3872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * This is an embedded editor/view to add photos and sound/video clips
3972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * into a multimedia message.
4072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project */
41b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrickpublic class AttachmentEditor extends LinearLayout {
4272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private static final String TAG = "AttachmentEditor";
43fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
4472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_EDIT_SLIDESHOW   = 1;
4572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_SEND_SLIDESHOW   = 2;
4672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_PLAY_SLIDESHOW   = 3;
4772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_REPLACE_IMAGE    = 4;
4872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_REPLACE_VIDEO    = 5;
4972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_REPLACE_AUDIO    = 6;
5072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_PLAY_VIDEO       = 7;
5172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_PLAY_AUDIO       = 8;
5272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    static final int MSG_VIEW_IMAGE       = 9;
53b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    static final int MSG_REMOVE_ATTACHMENT = 10;
54fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
5572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private final Context mContext;
56b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    private Handler mHandler;
5772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
5872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private SlideViewInterface mView;
5972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private SlideshowModel mSlideshow;
6072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private Presenter mPresenter;
6172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private boolean mCanSend;
6272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private Button mSendButton;
6372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
64b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    public AttachmentEditor(Context context, AttributeSet attr) {
65b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        super(context, attr);
6672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        mContext = context;
6772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
6872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
69b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    public void update(WorkingMessage msg) {
70b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        hideView();
71b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        mView = null;
72fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
73b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        // If there's no attachment, we have nothing to do.
74b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        if (!msg.hasAttachment()) {
75b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick            return;
76b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        }
77fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
78b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        // Get the slideshow from the message.
79b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        mSlideshow = msg.getSlideshow();
80fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
81b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        mView = createView();
82b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick
83b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        if ((mPresenter == null) || !mSlideshow.equals(mPresenter.getModel())) {
84b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick            mPresenter = PresenterFactory.getPresenter(
85b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick                    "MmsThumbnailPresenter", mContext, mView, mSlideshow);
86b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        } else {
87b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick            mPresenter.setView(mView);
88b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        }
89b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick
90b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        mPresenter.present();
91b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    }
92fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
93b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    public void setHandler(Handler handler) {
94b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        mHandler = handler;
95b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick    }
96fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
9772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    public void setCanSend(boolean enable) {
9872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        if (mCanSend != enable) {
9972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            mCanSend = enable;
10072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            updateSendButton();
10172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
10272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
10372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
10472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private void updateSendButton() {
10572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        if (null != mSendButton) {
10672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            mSendButton.setEnabled(mCanSend);
10772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            mSendButton.setFocusable(mCanSend);
10872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
10972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
11072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
11172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    public void hideView() {
11272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        if (mView != null) {
11372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            ((View)mView).setVisibility(View.GONE);
11472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
11572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
11672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
11772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private View getStubView(int stubId, int viewId) {
118b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        View view = findViewById(viewId);
11972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        if (view == null) {
120b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick            ViewStub stub = (ViewStub) findViewById(stubId);
12172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            view = stub.inflate();
12272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
12372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
12472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        return view;
12572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
12672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
12772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private class MessageOnClick implements OnClickListener {
12872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        private int mWhat;
129fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
13072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        public MessageOnClick(int what) {
13172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            mWhat = what;
13272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
133fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
13472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        public void onClick(View v) {
13572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            Message msg = Message.obtain(mHandler, mWhat);
13672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            msg.sendToTarget();
13772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
13872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
13972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
14072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private SlideViewInterface createView() {
141fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor        boolean inPortrait = inPortraitMode();
142b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        if (mSlideshow.size() > 1) {
143fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor            return createSlideshowView(inPortrait);
144b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        }
145fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
146b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        SlideModel slide = mSlideshow.get(0);
147b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        if (slide.hasImage()) {
14872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            return createMediaView(
149fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.image_attachment_view_portrait_stub :
150fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.image_attachment_view_landscape_stub,
151fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.image_attachment_view_portrait :
152fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.image_attachment_view_landscape,
15372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project                    R.id.view_image_button, R.id.replace_image_button, R.id.remove_image_button,
154b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick                    MSG_VIEW_IMAGE, MSG_REPLACE_IMAGE, MSG_REMOVE_ATTACHMENT);
155b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        } else if (slide.hasVideo()) {
15672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            return createMediaView(
157fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.video_attachment_view_portrait_stub :
158fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.video_attachment_view_landscape_stub,
159fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.video_attachment_view_portrait :
160fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.video_attachment_view_landscape,
16172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project                    R.id.view_video_button, R.id.replace_video_button, R.id.remove_video_button,
162b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick                    MSG_PLAY_VIDEO, MSG_REPLACE_VIDEO, MSG_REMOVE_ATTACHMENT);
163b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        } else if (slide.hasAudio()) {
16472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            return createMediaView(
165fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.audio_attachment_view_portrait_stub :
166fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.audio_attachment_view_landscape_stub,
167fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    inPortrait ? R.id.audio_attachment_view_portrait :
168fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                        R.id.audio_attachment_view_landscape,
16972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project                    R.id.play_audio_button, R.id.replace_audio_button, R.id.remove_audio_button,
170b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick                    MSG_PLAY_AUDIO, MSG_REPLACE_AUDIO, MSG_REMOVE_ATTACHMENT);
171b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        } else {
17272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            throw new IllegalArgumentException();
17372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        }
17472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
17572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
176fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor    /**
177fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor     * What is the current orientation?
178fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor     */
179fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor    private boolean inPortraitMode() {
180fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor        final Configuration configuration = mContext.getResources().getConfiguration();
181fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor        return configuration.orientation == Configuration.ORIENTATION_PORTRAIT;
182fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor    }
183fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
18472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    private SlideViewInterface createMediaView(
18572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            int stub_view_id, int real_view_id,
18672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project            int view_button_id, int replace_button_id, int remove_button_id,
187b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick            int view_message, int replace_message, int remove_message) {
18872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        LinearLayout view = (LinearLayout)getStubView(stub_view_id, real_view_id);
18972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        view.setVisibility(View.VISIBLE);
19072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
19172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        Button viewButton = (Button) view.findViewById(view_button_id);
19272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        Button replaceButton = (Button) view.findViewById(replace_button_id);
19372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        Button removeButton = (Button) view.findViewById(remove_button_id);
19472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
19572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        viewButton.setOnClickListener(new MessageOnClick(view_message));
19672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        replaceButton.setOnClickListener(new MessageOnClick(replace_message));
197b9bcfdd226bbb6f5b265f925343375192963d58aFicus Kirkpatrick        removeButton.setOnClickListener(new MessageOnClick(remove_message));
19872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
19972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        return (SlideViewInterface) view;
20072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
201fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor
202fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor    private SlideViewInterface createSlideshowView(boolean inPortrait) {
203fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor        LinearLayout view =(LinearLayout) getStubView(inPortrait ?
204fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                R.id.slideshow_attachment_view_portrait_stub :
205fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                R.id.slideshow_attachment_view_landscape_stub,
206fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                inPortrait ? R.id.slideshow_attachment_view_portrait :
207fa1c08f58afd8246b223c2a55a4ba0a6dac39526Tom Taylor                    R.id.slideshow_attachment_view_landscape);
20872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        view.setVisibility(View.VISIBLE);
20972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
21072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        Button editBtn = (Button) view.findViewById(R.id.edit_slideshow_button);
21172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        mSendButton = (Button) view.findViewById(R.id.send_slideshow_button);
21272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        updateSendButton();
21372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        final ImageButton playBtn = (ImageButton) view.findViewById(
21472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project                R.id.play_slideshow_button);
21572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
21672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        editBtn.setOnClickListener(new MessageOnClick(MSG_EDIT_SLIDESHOW));
21772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        mSendButton.setOnClickListener(new MessageOnClick(MSG_SEND_SLIDESHOW));
21872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        playBtn.setOnClickListener(new MessageOnClick(MSG_PLAY_SLIDESHOW));
21972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
22072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project        return (SlideViewInterface) view;
22172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    }
22272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project}
223