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.LogTag; 38import com.android.mms.R; 39 40/** 41 * A simplified view of slide in the slides list. 42 */ 43public 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 51 public SlideListItemView(Context context) { 52 super(context); 53 } 54 55 public SlideListItemView(Context context, AttributeSet attrs) { 56 super(context, attrs); 57 } 58 59 @Override 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 68 public void startAudio() { 69 // Playing audio is not needed in this view. 70 } 71 72 public void startVideo() { 73 // Playing audio is not needed in this view. 74 } 75 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 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 98 public void setImageRegionFit(String fit) { 99 // TODO Auto-generated method stub 100 } 101 102 public void setImageVisibility(boolean visible) { 103 // TODO Auto-generated method stub 104 } 105 106 public void setText(String name, String text) { 107 mTextPreview.setText(text); 108 mTextPreview.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE); 109 } 110 111 public void setTextVisibility(boolean visible) { 112 // TODO Auto-generated method stub 113 } 114 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 128 public void setVideoThumbnail(String name, Bitmap thumbnail) { 129 } 130 131 public void setVideoVisibility(boolean visible) { 132 // TODO Auto-generated method stub 133 } 134 135 public void stopAudio() { 136 // Stopping audio is not needed in this view. 137 } 138 139 public void stopVideo() { 140 // Stopping video is not needed in this view. 141 } 142 143 public void reset() { 144 // TODO Auto-generated method stub 145 } 146 147 public void setVisibility(boolean visible) { 148 // TODO Auto-generated method stub 149 } 150 151 public void pauseAudio() { 152 // TODO Auto-generated method stub 153 154 } 155 156 public void pauseVideo() { 157 // TODO Auto-generated method stub 158 159 } 160 161 public void seekAudio(int seekTo) { 162 // TODO Auto-generated method stub 163 164 } 165 166 public void seekVideo(int seekTo) { 167 // TODO Auto-generated method stub 168 169 } 170} 171