SlideshowAttachmentView.java revision 6f53960f9a27fe76ba11735ede0778456d3f6930
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            bitmap = BitmapFactory.decodeResource(getResources(),
76                    R.drawable.ic_missing_thumbnail_picture);
77        }
78        mImageView.setImageBitmap(bitmap);
79    }
80
81    public void setImageRegionFit(String fit) {
82        // TODO Auto-generated method stub
83    }
84
85    public void setImageVisibility(boolean visible) {
86        mImageView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
87    }
88
89    public void setText(String name, String text) {
90        mTextView.setText(text);
91    }
92
93    public void setTextVisibility(boolean visible) {
94        mTextView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
95    }
96
97    public void setVideo(String name, Uri video) {
98        MediaPlayer mp = new MediaPlayer();
99        try {
100            mp.setDataSource(mContext, video);
101            mImageView.setImageBitmap(mp.getFrameAt(1000));
102        } catch (IOException e) {
103            Log.e(TAG, "Unexpected IOException.", e);
104        } finally {
105            mp.release();
106        }
107    }
108
109    public void setVideoVisibility(boolean visible) {
110        // TODO Auto-generated method stub
111    }
112
113    public void stopAudio() {
114        // TODO Auto-generated method stub
115    }
116
117    public void stopVideo() {
118        // TODO Auto-generated method stub
119    }
120
121    public void reset() {
122        mImageView.setImageURI(null);
123        mTextView.setText("");
124    }
125
126    public void setVisibility(boolean visible) {
127        // TODO Auto-generated method stub
128    }
129
130    public void pauseAudio() {
131        // TODO Auto-generated method stub
132
133    }
134
135    public void pauseVideo() {
136        // TODO Auto-generated method stub
137
138    }
139
140    public void seekAudio(int seekTo) {
141        // TODO Auto-generated method stub
142
143    }
144
145    public void seekVideo(int seekTo) {
146        // TODO Auto-generated method stub
147
148    }
149}
150