1/*
2 * Copyright (C) 2008 Esmertec AG.
3 * Copyright (C) 2008 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.mms.ui;
19
20import com.android.mms.R;
21
22import android.content.Context;
23import android.graphics.Bitmap;
24import android.graphics.BitmapFactory;
25import android.media.MediaPlayer;
26import android.net.Uri;
27import android.util.AttributeSet;
28import android.util.Log;
29import android.view.View;
30import android.widget.ImageView;
31import android.widget.LinearLayout;
32import android.widget.TextView;
33
34import java.io.IOException;
35import java.util.Map;
36
37/**
38 * This class provides an embedded editor/viewer of slide-show attachment.
39 */
40public class SlideshowAttachmentView extends LinearLayout implements
41        SlideViewInterface {
42    private static final String TAG = "SlideshowAttachmentView";
43
44    private ImageView mImageView;
45    private TextView mTextView;
46
47    public SlideshowAttachmentView(Context context) {
48        super(context);
49    }
50
51    public SlideshowAttachmentView(Context context, AttributeSet attrs) {
52        super(context, attrs);
53    }
54
55    @Override
56    protected void onFinishInflate() {
57        mImageView = (ImageView) findViewById(R.id.slideshow_image);
58        mTextView = (TextView) findViewById(R.id.slideshow_text);
59    }
60
61    public void startAudio() {
62        // TODO Auto-generated method stub
63    }
64
65    public void startVideo() {
66        // TODO Auto-generated method stub
67    }
68
69    public void setAudio(Uri audio, String name, Map<String, ?> extras) {
70        // TODO Auto-generated method stub
71    }
72
73    public void setImage(String name, Bitmap bitmap) {
74        if (null == bitmap) {
75            try {
76                bitmap = BitmapFactory.decodeResource(getResources(),
77                        R.drawable.ic_missing_thumbnail_picture);
78            } catch (java.lang.OutOfMemoryError e) {
79                // We don't even have enough memory to load the "missing thumbnail" image
80            }
81        }
82        if (bitmap != null) {
83            mImageView.setImageBitmap(bitmap);      // implementation doesn't appear to be null-safe
84        }
85    }
86
87    public void setImageRegionFit(String fit) {
88        // TODO Auto-generated method stub
89    }
90
91    public void setImageVisibility(boolean visible) {
92        mImageView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
93    }
94
95    public void setText(String name, String text) {
96        mTextView.setText(text);
97    }
98
99    public void setTextVisibility(boolean visible) {
100        mTextView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
101    }
102
103    public void setVideo(String name, Uri video) {
104        MediaPlayer mp = new MediaPlayer();
105        try {
106            mp.setDataSource(mContext, video);
107            mImageView.setImageBitmap(mp.getFrameAt(1000));
108        } catch (IOException e) {
109            Log.e(TAG, "Unexpected IOException.", e);
110        } finally {
111            mp.release();
112        }
113    }
114
115    public void setVideoVisibility(boolean visible) {
116        // TODO Auto-generated method stub
117    }
118
119    public void stopAudio() {
120        // TODO Auto-generated method stub
121    }
122
123    public void stopVideo() {
124        // TODO Auto-generated method stub
125    }
126
127    public void reset() {
128        mImageView.setImageURI(null);
129        mTextView.setText("");
130    }
131
132    public void setVisibility(boolean visible) {
133        // TODO Auto-generated method stub
134    }
135
136    public void pauseAudio() {
137        // TODO Auto-generated method stub
138
139    }
140
141    public void pauseVideo() {
142        // TODO Auto-generated method stub
143
144    }
145
146    public void seekAudio(int seekTo) {
147        // TODO Auto-generated method stub
148
149    }
150
151    public void seekVideo(int seekTo) {
152        // TODO Auto-generated method stub
153
154    }
155
156    public void setVideoThumbnail(String name, Bitmap bitmap) {
157    }
158}
159