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