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 
18 package com.android.mms.ui;
19 
20 import java.io.IOException;
21 import java.util.Map;
22 
23 import android.content.Context;
24 import android.graphics.Bitmap;
25 import android.graphics.BitmapFactory;
26 import android.media.MediaPlayer;
27 import android.net.Uri;
28 import android.text.TextUtils;
29 import android.text.method.HideReturnsTransformationMethod;
30 import android.util.AttributeSet;
31 import android.util.Log;
32 import android.view.View;
33 import android.widget.ImageView;
34 import android.widget.LinearLayout;
35 import android.widget.TextView;
36 
37 import com.android.mms.LogTag;
38 import com.android.mms.R;
39 
40 /**
41  * A simplified view of slide in the slides list.
42  */
43 public class SlideListItemView extends LinearLayout implements SlideViewInterface {
44     private static final String TAG = LogTag.TAG;
45 
46     private TextView mTextPreview;
47     private ImageView mImagePreview;
48     private TextView mAttachmentName;
49     private ImageView mAttachmentIcon;
50 
SlideListItemView(Context context)51     public SlideListItemView(Context context) {
52         super(context);
53     }
54 
SlideListItemView(Context context, AttributeSet attrs)55     public SlideListItemView(Context context, AttributeSet attrs) {
56         super(context, attrs);
57     }
58 
59     @Override
onFinishInflate()60     protected void onFinishInflate() {
61         mTextPreview = (TextView) findViewById(R.id.text_preview);
62         mTextPreview.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
63         mImagePreview = (ImageView) findViewById(R.id.image_preview);
64         mAttachmentName = (TextView) findViewById(R.id.attachment_name);
65         mAttachmentIcon = (ImageView) findViewById(R.id.attachment_icon);
66     }
67 
startAudio()68     public void startAudio() {
69         // Playing audio is not needed in this view.
70     }
71 
startVideo()72     public void startVideo() {
73         // Playing audio is not needed in this view.
74     }
75 
setAudio(Uri audio, String name, Map<String, ?> extras)76     public void setAudio(Uri audio, String name, Map<String, ?> extras) {
77         if (name != null) {
78             mAttachmentName.setText(name);
79             mAttachmentIcon.setImageResource(R.drawable.ic_mms_music);
80         } else {
81             mAttachmentName.setText("");
82             mAttachmentIcon.setImageDrawable(null);
83         }
84     }
85 
setImage(String name, Bitmap bitmap)86     public void setImage(String name, Bitmap bitmap) {
87         try {
88             if (null == bitmap) {
89                 bitmap = BitmapFactory.decodeResource(getResources(),
90                         R.drawable.ic_missing_thumbnail_picture);
91             }
92             mImagePreview.setImageBitmap(bitmap);
93         } catch (java.lang.OutOfMemoryError e) {
94             Log.e(TAG, "setImage: out of memory: ", e);
95         }
96     }
97 
setImageRegionFit(String fit)98     public void setImageRegionFit(String fit) {
99         // TODO Auto-generated method stub
100     }
101 
setImageVisibility(boolean visible)102     public void setImageVisibility(boolean visible) {
103         // TODO Auto-generated method stub
104     }
105 
setText(String name, String text)106     public void setText(String name, String text) {
107         mTextPreview.setText(text);
108         mTextPreview.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE);
109     }
110 
setTextVisibility(boolean visible)111     public void setTextVisibility(boolean visible) {
112         // TODO Auto-generated method stub
113     }
114 
setVideo(String name, Uri video)115     public void setVideo(String name, Uri video) {
116         if (name != null) {
117             mAttachmentName.setText(name);
118             mAttachmentIcon.setImageResource(R.drawable.movie);
119         } else {
120             mAttachmentName.setText("");
121             mAttachmentIcon.setImageDrawable(null);
122         }
123 
124         // TODO: get a thumbnail from the video
125         mImagePreview.setImageBitmap(null);
126     }
127 
setVideoThumbnail(String name, Bitmap thumbnail)128     public void setVideoThumbnail(String name, Bitmap thumbnail) {
129     }
130 
setVideoVisibility(boolean visible)131     public void setVideoVisibility(boolean visible) {
132         // TODO Auto-generated method stub
133     }
134 
stopAudio()135     public void stopAudio() {
136         // Stopping audio is not needed in this view.
137     }
138 
stopVideo()139     public void stopVideo() {
140         // Stopping video is not needed in this view.
141     }
142 
reset()143     public void reset() {
144         // TODO Auto-generated method stub
145     }
146 
setVisibility(boolean visible)147     public void setVisibility(boolean visible) {
148         // TODO Auto-generated method stub
149     }
150 
pauseAudio()151     public void pauseAudio() {
152         // TODO Auto-generated method stub
153 
154     }
155 
pauseVideo()156     public void pauseVideo() {
157         // TODO Auto-generated method stub
158 
159     }
160 
seekAudio(int seekTo)161     public void seekAudio(int seekTo) {
162         // TODO Auto-generated method stub
163 
164     }
165 
seekVideo(int seekTo)166     public void seekVideo(int seekTo) {
167         // TODO Auto-generated method stub
168 
169     }
170 }
171