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 com.android.mms.R; 21 22 import android.content.Context; 23 import android.graphics.Bitmap; 24 import android.graphics.BitmapFactory; 25 import android.media.MediaPlayer; 26 import android.net.Uri; 27 import android.text.Editable; 28 import android.text.TextWatcher; 29 import android.util.AttributeSet; 30 import android.util.Log; 31 import android.view.View; 32 import android.widget.EditText; 33 import android.widget.ImageView; 34 import android.widget.LinearLayout; 35 import android.widget.TextView; 36 37 import java.io.IOException; 38 import java.util.Map; 39 40 /** 41 * This is a basic view to show and edit a slide. 42 */ 43 public class BasicSlideEditorView extends LinearLayout implements 44 SlideViewInterface { 45 private static final String TAG = "BasicSlideEditorView"; 46 47 private ImageView mImageView; 48 private View mAudioView; 49 private TextView mAudioNameView; 50 private EditText mEditText; 51 private boolean mOnTextChangedListenerEnabled = true; 52 private OnTextChangedListener mOnTextChangedListener; 53 BasicSlideEditorView(Context context)54 public BasicSlideEditorView(Context context) { 55 super(context); 56 } 57 BasicSlideEditorView(Context context, AttributeSet attrs)58 public BasicSlideEditorView(Context context, AttributeSet attrs) { 59 super(context, attrs); 60 } 61 62 @Override onFinishInflate()63 public void onFinishInflate() { 64 mImageView = (ImageView) findViewById(R.id.image); 65 mAudioView = findViewById(R.id.audio); 66 mAudioNameView = (TextView) findViewById(R.id.audio_name); 67 mEditText = (EditText) findViewById(R.id.text_message); 68 mEditText.addTextChangedListener(new TextWatcher() { 69 public void beforeTextChanged(CharSequence s, int start, int count, 70 int after) { 71 // TODO Auto-generated method stub 72 } 73 74 public void onTextChanged(CharSequence s, int start, int before, 75 int count) { 76 if (mOnTextChangedListenerEnabled && (mOnTextChangedListener != null)) { 77 mOnTextChangedListener.onTextChanged(s.toString()); 78 } 79 } 80 81 public void afterTextChanged(Editable s) { 82 // TODO Auto-generated method stub 83 } 84 }); 85 } 86 startAudio()87 public void startAudio() { 88 // TODO Auto-generated method stub 89 } 90 startVideo()91 public void startVideo() { 92 // TODO Auto-generated method stub 93 } 94 setAudio(Uri audio, String name, Map<String, ?> extras)95 public void setAudio(Uri audio, String name, Map<String, ?> extras) { 96 mAudioView.setVisibility(View.VISIBLE); 97 mAudioNameView.setText(name); 98 } 99 setImage(String name, Bitmap bitmap)100 public void setImage(String name, Bitmap bitmap) { 101 if (null == bitmap) { 102 bitmap = BitmapFactory.decodeResource(getResources(), 103 R.drawable.ic_missing_thumbnail_picture); 104 } 105 mImageView.setImageBitmap(bitmap); 106 } 107 setImageRegionFit(String fit)108 public void setImageRegionFit(String fit) { 109 // TODO Auto-generated method stub 110 } 111 setImageVisibility(boolean visible)112 public void setImageVisibility(boolean visible) { 113 // TODO Auto-generated method stub 114 } 115 setText(String name, String text)116 public void setText(String name, String text) { 117 mOnTextChangedListenerEnabled = false; 118 if ((text != null) && !text.equals(mEditText.getText().toString())) { 119 mEditText.setText(text); 120 mEditText.setSelection(text.length()); 121 } 122 mOnTextChangedListenerEnabled = true; 123 } 124 setTextVisibility(boolean visible)125 public void setTextVisibility(boolean visible) { 126 // TODO Auto-generated method stub 127 } 128 setVideo(String name, Uri video)129 public void setVideo(String name, Uri video) { 130 Bitmap bitmap = VideoAttachmentView.createVideoThumbnail(mContext, video); 131 if (null == bitmap) { 132 bitmap = BitmapFactory.decodeResource(getResources(), 133 R.drawable.ic_missing_thumbnail_video); 134 } 135 mImageView.setImageBitmap(bitmap); 136 } 137 setVideoVisibility(boolean visible)138 public void setVideoVisibility(boolean visible) { 139 // TODO Auto-generated method stub 140 } 141 stopAudio()142 public void stopAudio() { 143 // TODO Auto-generated method stub 144 } 145 stopVideo()146 public void stopVideo() { 147 // TODO Auto-generated method stub 148 } 149 reset()150 public void reset() { 151 mImageView.setImageDrawable(null); 152 mAudioView.setVisibility(View.GONE); 153 mOnTextChangedListenerEnabled = false; 154 mEditText.setText(""); 155 mOnTextChangedListenerEnabled = true; 156 } 157 setVisibility(boolean visible)158 public void setVisibility(boolean visible) { 159 // TODO Auto-generated method stub 160 } 161 setOnTextChangedListener(OnTextChangedListener l)162 public void setOnTextChangedListener(OnTextChangedListener l) { 163 mOnTextChangedListener = l; 164 } 165 166 public interface OnTextChangedListener { onTextChanged(String s)167 void onTextChanged(String s); 168 } 169 pauseAudio()170 public void pauseAudio() { 171 // TODO Auto-generated method stub 172 173 } 174 pauseVideo()175 public void pauseVideo() { 176 // TODO Auto-generated method stub 177 178 } 179 seekAudio(int seekTo)180 public void seekAudio(int seekTo) { 181 // TODO Auto-generated method stub 182 183 } 184 seekVideo(int seekTo)185 public void seekVideo(int seekTo) { 186 // TODO Auto-generated method stub 187 188 } 189 } 190