1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.mms.ui; 18 19 import android.content.Context; 20 import android.text.ClipboardManager; 21 import android.util.AttributeSet; 22 import android.view.KeyEvent; 23 import android.widget.ListView; 24 25 public final class MessageListView extends ListView { 26 public MessageListView(Context context) { 27 super(context); 28 } 29 30 public MessageListView(Context context, AttributeSet attrs) { 31 super(context, attrs); 32 } 33 34 @Override 35 public boolean onKeyShortcut(int keyCode, KeyEvent event) { 36 switch (keyCode) { 37 case KeyEvent.KEYCODE_C: 38 MessageListItem view = (MessageListItem)getSelectedView(); 39 if (view == null) { 40 break; 41 } 42 MessageItem item = view.getMessageItem(); 43 if (item != null && item.isSms()) { 44 ClipboardManager clip = 45 (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE); 46 clip.setText(item.mBody); 47 return true; 48 } 49 break; 50 } 51 52 return super.onKeyShortcut(keyCode, event); 53 } 54 55 } 56 57