blob: a4a578f470d37a0768a381cb50a1da8868d365d6 [file] [log] [blame]
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001/*
2 * Copyright (C) 2009 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
17package com.android.contacts;
18
Amith Yamasani8bbe2f22009-03-24 21:24:12 -070019import com.android.internal.telephony.CallerInfo;
20
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080021import android.app.ListActivity;
22import android.content.ContentResolver;
23import android.content.ContentUris;
24import android.content.Context;
25import android.content.Intent;
26import android.content.res.Resources;
27import android.database.Cursor;
28import android.net.Uri;
29import android.os.Bundle;
30import android.provider.CallLog;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080031import android.provider.CallLog.Calls;
Flavio Lerda9cafe472011-06-08 14:06:13 +010032import android.provider.Contacts.Intents.Insert;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070033import android.provider.ContactsContract.Contacts;
34import android.provider.ContactsContract.PhoneLookup;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080035import android.telephony.PhoneNumberUtils;
36import android.telephony.TelephonyManager;
37import android.text.TextUtils;
38import android.text.format.DateUtils;
39import android.view.KeyEvent;
40import android.view.LayoutInflater;
41import android.view.View;
42import android.view.ViewGroup;
43import android.widget.AdapterView;
44import android.widget.BaseAdapter;
45import android.widget.ImageView;
46import android.widget.TextView;
47import android.widget.Toast;
48
49import java.util.ArrayList;
50import java.util.List;
51
52/**
53 * Displays the details of a specific call log entry.
54 */
55public class CallDetailActivity extends ListActivity implements
56 AdapterView.OnItemClickListener {
57 private static final String TAG = "CallDetail";
58
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010059 /** The views representing the details of a phone call. */
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010060 private PhoneCallDetailsViews mPhoneCallDetailsViews;
61 private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
Flavio Lerda9cafe472011-06-08 14:06:13 +010062 private TextView mCallTimeView;
63 private TextView mCallDurationView;
Flavio Lerdafb63c432011-07-07 17:16:53 +010064 private View mHomeActionView;
65 private ImageView mMainActionView;
Flavio Lerda9cafe472011-06-08 14:06:13 +010066 private ImageView mContactBackgroundView;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080067
68 private String mNumber = null;
Bai Tao09eb04f2010-09-01 15:34:16 +080069 private String mDefaultCountryIso;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070070
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080071 /* package */ LayoutInflater mInflater;
72 /* package */ Resources mResources;
Flavio Lerda9cafe472011-06-08 14:06:13 +010073 /** Helper to load contact photos. */
74 private ContactPhotoManager mContactPhotoManager;
75 /** Attached to the call action button in the UI. */
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070076
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080077 static final String[] CALL_LOG_PROJECTION = new String[] {
78 CallLog.Calls.DATE,
79 CallLog.Calls.DURATION,
80 CallLog.Calls.NUMBER,
81 CallLog.Calls.TYPE,
Bai Tao09eb04f2010-09-01 15:34:16 +080082 CallLog.Calls.COUNTRY_ISO,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080083 };
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070084
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080085 static final int DATE_COLUMN_INDEX = 0;
86 static final int DURATION_COLUMN_INDEX = 1;
87 static final int NUMBER_COLUMN_INDEX = 2;
88 static final int CALL_TYPE_COLUMN_INDEX = 3;
Bai Tao09eb04f2010-09-01 15:34:16 +080089 static final int COUNTRY_ISO_COLUMN_INDEX = 4;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070090
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080091 static final String[] PHONES_PROJECTION = new String[] {
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070092 PhoneLookup._ID,
93 PhoneLookup.DISPLAY_NAME,
94 PhoneLookup.TYPE,
95 PhoneLookup.LABEL,
96 PhoneLookup.NUMBER,
Bai Tao09eb04f2010-09-01 15:34:16 +080097 PhoneLookup.NORMALIZED_NUMBER,
Flavio Lerda9cafe472011-06-08 14:06:13 +010098 PhoneLookup.PHOTO_ID,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080099 };
100 static final int COLUMN_INDEX_ID = 0;
101 static final int COLUMN_INDEX_NAME = 1;
102 static final int COLUMN_INDEX_TYPE = 2;
103 static final int COLUMN_INDEX_LABEL = 3;
104 static final int COLUMN_INDEX_NUMBER = 4;
Bai Tao09eb04f2010-09-01 15:34:16 +0800105 static final int COLUMN_INDEX_NORMALIZED_NUMBER = 5;
Flavio Lerda9cafe472011-06-08 14:06:13 +0100106 static final int COLUMN_INDEX_PHOTO_ID = 6;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800107
108 @Override
109 protected void onCreate(Bundle icicle) {
110 super.onCreate(icicle);
111
112 setContentView(R.layout.call_detail);
113
114 mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
115 mResources = getResources();
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700116
Flavio Lerda696e8132011-07-05 19:00:23 +0100117 mPhoneCallDetailsViews = PhoneCallDetailsViews.fromView(getWindow().getDecorView());
Flavio Lerda7d7473a2011-07-06 14:21:46 +0100118 mPhoneCallDetailsHelper = new PhoneCallDetailsHelper(this, getResources(),
119 getVoicemailNumber(),
120 getResources().getDrawable(R.drawable.ic_call_log_list_incoming_call),
121 getResources().getDrawable(R.drawable.ic_call_log_list_outgoing_call),
122 getResources().getDrawable(R.drawable.ic_call_log_list_missed_call),
123 getResources().getDrawable(R.drawable.ic_call_log_list_voicemail));
Flavio Lerdafb63c432011-07-07 17:16:53 +0100124 mHomeActionView = findViewById(R.id.action_bar_home);
125 mMainActionView = (ImageView) findViewById(R.id.main_action);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100126 mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
127 mCallTimeView = (TextView) findViewById(R.id.time);
128 mCallDurationView = (TextView) findViewById(R.id.duration);
Bai Tao09eb04f2010-09-01 15:34:16 +0800129 mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100130 mContactPhotoManager = ContactPhotoManager.getInstance(this);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800131 getListView().setOnItemClickListener(this);
Flavio Lerdafb63c432011-07-07 17:16:53 +0100132 mHomeActionView.setOnClickListener(new View.OnClickListener() {
133 @Override
134 public void onClick(View v) {
135 // We want this to start the call log if this activity was not started from the
136 // call log itself.
137 CallDetailActivity.this.finish();
138 }
139 });
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800140 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700141
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800142 @Override
143 public void onResume() {
144 super.onResume();
145 updateData(getIntent().getData());
146 }
147
148 @Override
149 public boolean onKeyDown(int keyCode, KeyEvent event) {
150 switch (keyCode) {
151 case KeyEvent.KEYCODE_CALL: {
152 // Make sure phone isn't already busy before starting direct call
153 TelephonyManager tm = (TelephonyManager)
154 getSystemService(Context.TELEPHONY_SERVICE);
155 if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
156 Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
157 Uri.fromParts("tel", mNumber, null));
158 startActivity(callIntent);
159 return true;
160 }
161 }
162 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700163
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800164 return super.onKeyDown(keyCode, event);
165 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700166
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800167 /**
168 * Update user interface with details of given call.
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700169 *
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800170 * @param callUri Uri into {@link CallLog.Calls}
171 */
172 private void updateData(Uri callUri) {
173 ContentResolver resolver = getContentResolver();
174 Cursor callCursor = resolver.query(callUri, CALL_LOG_PROJECTION, null, null, null);
175 try {
176 if (callCursor != null && callCursor.moveToFirst()) {
177 // Read call log specifics
178 mNumber = callCursor.getString(NUMBER_COLUMN_INDEX);
179 long date = callCursor.getLong(DATE_COLUMN_INDEX);
180 long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
181 int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
Bai Tao09eb04f2010-09-01 15:34:16 +0800182 String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
183 if (TextUtils.isEmpty(countryIso)) {
184 countryIso = mDefaultCountryIso;
185 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800186 // Pull out string in format [relative], [date]
187 CharSequence dateClause = DateUtils.formatDateRange(this, date, date,
188 DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
189 DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100190 mCallTimeView.setText(dateClause);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700191
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800192 // Set the duration
193 if (callType == Calls.MISSED_TYPE) {
Flavio Lerda9cafe472011-06-08 14:06:13 +0100194 mCallDurationView.setVisibility(View.GONE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800195 } else {
Flavio Lerda9cafe472011-06-08 14:06:13 +0100196 mCallDurationView.setVisibility(View.VISIBLE);
197 mCallDurationView.setText(formatDuration(duration));
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800198 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700199
Flavio Lerda9cafe472011-06-08 14:06:13 +0100200 long photoId = 0L;
201 CharSequence nameText = "";
Flavio Lerdaa024c3f2011-06-10 10:47:07 +0100202 final CharSequence numberText;
203 int numberType = 0;
204 CharSequence numberLabel = "";
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700205 if (mNumber.equals(CallerInfo.UNKNOWN_NUMBER) ||
206 mNumber.equals(CallerInfo.PRIVATE_NUMBER)) {
Flavio Lerdaa024c3f2011-06-10 10:47:07 +0100207 numberText = getString(mNumber.equals(CallerInfo.PRIVATE_NUMBER)
Flavio Lerda9cafe472011-06-08 14:06:13 +0100208 ? R.string.private_num : R.string.unknown);
Flavio Lerdafb63c432011-07-07 17:16:53 +0100209 mMainActionView.setVisibility(View.GONE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800210 } else {
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700211 // Perform a reverse-phonebook lookup to find the PERSON_ID
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700212 Uri personUri = null;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700213 Uri phoneUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
214 Uri.encode(mNumber));
Flavio Lerda9cafe472011-06-08 14:06:13 +0100215 Cursor phonesCursor = resolver.query(
216 phoneUri, PHONES_PROJECTION, null, null, null);
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700217 try {
218 if (phonesCursor != null && phonesCursor.moveToFirst()) {
219 long personId = phonesCursor.getLong(COLUMN_INDEX_ID);
220 personUri = ContentUris.withAppendedId(
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700221 Contacts.CONTENT_URI, personId);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100222 nameText = phonesCursor.getString(COLUMN_INDEX_NAME);
223 photoId = phonesCursor.getLong(COLUMN_INDEX_PHOTO_ID);
Sang-il, Lee177c77f2010-03-09 20:37:19 +0900224 mNumber = PhoneNumberUtils.formatNumber(
Bai Tao09eb04f2010-09-01 15:34:16 +0800225 phonesCursor.getString(COLUMN_INDEX_NUMBER),
226 phonesCursor.getString(COLUMN_INDEX_NORMALIZED_NUMBER),
227 countryIso);
Flavio Lerdaa024c3f2011-06-10 10:47:07 +0100228 numberType = phonesCursor.getInt(COLUMN_INDEX_TYPE);
229 numberLabel = phonesCursor.getString(COLUMN_INDEX_LABEL);
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700230 } else {
Bai Tao09eb04f2010-09-01 15:34:16 +0800231 mNumber = PhoneNumberUtils.formatNumber(mNumber, countryIso);
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700232 }
233 } finally {
Flavio Lerda9cafe472011-06-08 14:06:13 +0100234 if (phonesCursor != null) phonesCursor.close();
235 }
Flavio Lerdaa024c3f2011-06-10 10:47:07 +0100236 numberText = mNumber;
Flavio Lerda9cafe472011-06-08 14:06:13 +0100237
Flavio Lerdafb63c432011-07-07 17:16:53 +0100238 // Let user view contact details if they exist, otherwise add option
239 // to create new contact from this number.
240 final Intent mainActionIntent;
241 final int mainActionIcon;
242 if (personUri != null) {
243 mainActionIntent = new Intent(Intent.ACTION_VIEW, personUri);
244 mainActionIcon = R.drawable.sym_action_view_contact;
245 } else {
246 mainActionIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
247 mainActionIntent.setType(Contacts.CONTENT_ITEM_TYPE);
248 mainActionIntent.putExtra(Insert.PHONE, mNumber);
249 mainActionIcon = R.drawable.sym_action_add;
250 }
251
252 mMainActionView.setVisibility(View.VISIBLE);
253 mMainActionView.setImageResource(mainActionIcon);
254 mMainActionView.setOnClickListener(new View.OnClickListener() {
Flavio Lerda9cafe472011-06-08 14:06:13 +0100255 @Override
256 public void onClick(View v) {
Flavio Lerdafb63c432011-07-07 17:16:53 +0100257 startActivity(mainActionIntent);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100258 }
259 });
260
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700261 // Build list of various available actions
262 List<ViewEntry> actions = new ArrayList<ViewEntry>();
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700263
Flavio Lerdafb63c432011-07-07 17:16:53 +0100264 Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
265 Uri.fromParts("tel", mNumber, null));
266 actions.add(new ViewEntry(android.R.drawable.sym_action_call,
267 getString(R.string.menu_callNumber, mNumber), callIntent));
268
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700269 Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
270 Uri.fromParts("sms", mNumber, null));
271 actions.add(new ViewEntry(R.drawable.sym_action_sms,
272 getString(R.string.menu_sendTextMessage), smsIntent));
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700273
Amith Yamasani8bbe2f22009-03-24 21:24:12 -0700274 ViewAdapter adapter = new ViewAdapter(this, actions);
275 setListAdapter(adapter);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800276 }
Flavio Lerdad72bf8a2011-07-05 16:00:09 +0100277 mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews, date, callType,
278 nameText, numberText, numberType, numberLabel);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100279
280 loadContactPhotos(photoId);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800281 } else {
282 // Something went wrong reading in our primary data, so we're going to
283 // bail out and show error to users.
284 Toast.makeText(this, R.string.toast_call_detail_error,
285 Toast.LENGTH_SHORT).show();
286 finish();
287 }
288 } finally {
289 if (callCursor != null) {
290 callCursor.close();
291 }
292 }
293 }
294
Flavio Lerda9cafe472011-06-08 14:06:13 +0100295 /** Load the contact photos and places them in the corresponding views. */
296 private void loadContactPhotos(final long photoId) {
Flavio Lerdafb63c432011-07-07 17:16:53 +0100297 mContactPhotoManager.loadPhoto(mContactBackgroundView, photoId);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100298 }
299
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800300 private String formatDuration(long elapsedSeconds) {
301 long minutes = 0;
302 long seconds = 0;
303
304 if (elapsedSeconds >= 60) {
305 minutes = elapsedSeconds / 60;
306 elapsedSeconds -= minutes * 60;
307 }
308 seconds = elapsedSeconds;
309
310 return getString(R.string.callDetailsDurationFormat, minutes, seconds);
311 }
312
Flavio Lerda696e8132011-07-05 19:00:23 +0100313 private String getVoicemailNumber() {
314 TelephonyManager telephonyManager =
315 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
316 return telephonyManager.getVoiceMailNumber();
317 }
318
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800319 static final class ViewEntry {
320 public int icon = -1;
321 public String text = null;
322 public Intent intent = null;
323 public String label = null;
324 public String number = null;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700325
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800326 public ViewEntry(int icon, String text, Intent intent) {
327 this.icon = icon;
328 this.text = text;
329 this.intent = intent;
330 }
331 }
332
333 static final class ViewAdapter extends BaseAdapter {
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700334
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800335 private final List<ViewEntry> mActions;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700336
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800337 private final LayoutInflater mInflater;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700338
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800339 public ViewAdapter(Context context, List<ViewEntry> actions) {
340 mActions = actions;
341 mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
342 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700343
Flavio Lerda9cafe472011-06-08 14:06:13 +0100344 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800345 public int getCount() {
346 return mActions.size();
347 }
348
Flavio Lerda9cafe472011-06-08 14:06:13 +0100349 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800350 public Object getItem(int position) {
351 return mActions.get(position);
352 }
353
Flavio Lerda9cafe472011-06-08 14:06:13 +0100354 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800355 public long getItemId(int position) {
356 return position;
357 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700358
Flavio Lerda9cafe472011-06-08 14:06:13 +0100359 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800360 public View getView(int position, View convertView, ViewGroup parent) {
361 // Make sure we have a valid convertView to start with
362 if (convertView == null) {
363 convertView = mInflater.inflate(R.layout.call_detail_list_item, parent, false);
364 }
365
366 // Fill action with icon and text.
367 ViewEntry entry = mActions.get(position);
368 convertView.setTag(entry);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700369
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800370 ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
371 TextView text = (TextView) convertView.findViewById(android.R.id.text1);
372
373 icon.setImageResource(entry.icon);
374 text.setText(entry.text);
375
376 View line2 = convertView.findViewById(R.id.line2);
377 boolean numberEmpty = TextUtils.isEmpty(entry.number);
378 boolean labelEmpty = TextUtils.isEmpty(entry.label) || numberEmpty;
379 if (labelEmpty && numberEmpty) {
380 line2.setVisibility(View.GONE);
381 } else {
382 line2.setVisibility(View.VISIBLE);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700383
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800384 TextView label = (TextView) convertView.findViewById(R.id.label);
385 if (labelEmpty) {
386 label.setVisibility(View.GONE);
387 } else {
388 label.setText(entry.label);
389 label.setVisibility(View.VISIBLE);
390 }
391
392 TextView number = (TextView) convertView.findViewById(R.id.number);
393 number.setText(entry.number);
394 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700395
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800396 return convertView;
397 }
398 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700399
Flavio Lerda9cafe472011-06-08 14:06:13 +0100400 @Override
401 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800402 // Handle passing action off to correct handler.
403 if (view.getTag() instanceof ViewEntry) {
404 ViewEntry entry = (ViewEntry) view.getTag();
405 if (entry.intent != null) {
406 startActivity(entry.intent);
407 }
408 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700409 }
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800410
411 @Override
412 public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
413 boolean globalSearch) {
414 if (globalSearch) {
415 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
416 } else {
417 ContactsSearchManager.startSearch(this, initialQuery);
418 }
419 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800420}