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 java.io.IOException; 21import java.util.Map; 22 23import android.content.Context; 24import android.graphics.Bitmap; 25import android.graphics.BitmapFactory; 26import android.media.MediaPlayer; 27import android.net.Uri; 28import android.text.TextUtils; 29import android.text.method.HideReturnsTransformationMethod; 30import android.util.AttributeSet; 31import android.util.Log; 32import android.view.View; 33import android.widget.ImageView; 34import android.widget.LinearLayout; 35import android.widget.TextView; 36 37import com.android.mms.R; 38 39/** 40 * A simplified view of slide in the slides list. 41 */ 42public 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 50 public SlideListItemView(Context context) { 51 super(context); 52 } 53 54 public SlideListItemView(Context context, AttributeSet attrs) { 55 super(context, attrs); 56 } 57 58 @Override 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 67 public void startAudio() { 68 // Playing audio is not needed in this view. 69 } 70 71 public void startVideo() { 72 // Playing audio is not needed in this view. 73 } 74 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 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 97 public void setImageRegionFit(String fit) { 98 // TODO Auto-generated method stub 99 } 100 101 public void setImageVisibility(boolean visible) { 102 // TODO Auto-generated method stub 103 } 104 105 public void setText(String name, String text) { 106 mTextPreview.setText(text); 107 mTextPreview.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE); 108 } 109 110 public void setTextVisibility(boolean visible) { 111 // TODO Auto-generated method stub 112 } 113 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 // TODO: get a thumbnail from the video 124 mImagePreview.setImageBitmap(null); 125 } 126 127 public void setVideoThumbnail(String name, Bitmap thumbnail) { 128 } 129 130 public void setVideoVisibility(boolean visible) { 131 // TODO Auto-generated method stub 132 } 133 134 public void stopAudio() { 135 // Stopping audio is not needed in this view. 136 } 137 138 public void stopVideo() { 139 // Stopping video is not needed in this view. 140 } 141 142 public void reset() { 143 // TODO Auto-generated method stub 144 } 145 146 public void setVisibility(boolean visible) { 147 // TODO Auto-generated method stub 148 } 149 150 public void pauseAudio() { 151 // TODO Auto-generated method stub 152 153 } 154 155 public void pauseVideo() { 156 // TODO Auto-generated method stub 157 158 } 159 160 public void seekAudio(int seekTo) { 161 // TODO Auto-generated method stub 162 163 } 164 165 public void seekVideo(int seekTo) { 166 // TODO Auto-generated method stub 167 168 } 169} 170