blob: aa52d914fdc0757b9e1ca5793d93d0f03d17514a [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
Flavio Lerdad1333a22011-08-11 16:19:47 +010019import com.android.contacts.BackScrollManager.ScrollableHeader;
Flavio Lerda9a208cc2011-07-12 21:05:47 +010020import com.android.contacts.calllog.CallDetailHistoryAdapter;
21import com.android.contacts.calllog.CallTypeHelper;
Flavio Lerda178eeeb2011-07-11 19:51:40 +010022import com.android.contacts.calllog.PhoneNumberHelper;
Hugo Hudson51ada362011-08-05 14:36:14 +010023import com.android.contacts.util.AbstractBackgroundTask;
24import com.android.contacts.util.BackgroundTask;
25import com.android.contacts.util.BackgroundTaskService;
Hugo Hudsonb002f512011-07-15 17:41:12 +010026import com.android.contacts.voicemail.VoicemailPlaybackFragment;
Debashish Chatterjee0cb82242011-07-19 19:29:37 +010027import com.android.contacts.voicemail.VoicemailStatusHelper;
28import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
29import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
Amith Yamasani8bbe2f22009-03-24 21:24:12 -070030
Flavio Lerdad44e83a2011-07-24 23:10:17 +010031import android.app.ActionBar;
Flavio Lerdab184ed62011-08-10 18:17:55 +010032import android.app.Activity;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080033import android.content.ContentResolver;
34import android.content.ContentUris;
Debashish Chatterjee0a139002011-08-02 18:27:11 +010035import android.content.ContentValues;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080036import android.content.Context;
37import android.content.Intent;
38import android.content.res.Resources;
39import android.database.Cursor;
40import android.net.Uri;
Hugo Hudsona2625e42011-08-10 21:13:23 +010041import android.os.AsyncTask;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080042import android.os.Bundle;
43import android.provider.CallLog;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080044import android.provider.CallLog.Calls;
Flavio Lerda9cafe472011-06-08 14:06:13 +010045import android.provider.Contacts.Intents.Insert;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +010046import android.provider.ContactsContract.CommonDataKinds.Phone;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070047import android.provider.ContactsContract.Contacts;
48import android.provider.ContactsContract.PhoneLookup;
Debashish Chatterjee0a139002011-08-02 18:27:11 +010049import android.provider.VoicemailContract.Voicemails;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080050import android.telephony.PhoneNumberUtils;
51import android.telephony.TelephonyManager;
52import android.text.TextUtils;
Flavio Lerda178eeeb2011-07-11 19:51:40 +010053import android.util.Log;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080054import android.view.KeyEvent;
55import android.view.LayoutInflater;
Flavio Lerda94d7bab2011-07-22 16:52:34 +010056import android.view.Menu;
57import android.view.MenuItem;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080058import android.view.View;
Daniel Lehmannd260de42011-08-01 18:08:38 -070059import android.widget.ImageButton;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080060import android.widget.ImageView;
Flavio Lerda9a208cc2011-07-12 21:05:47 +010061import android.widget.ListView;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080062import android.widget.TextView;
63import android.widget.Toast;
64
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080065import java.util.List;
66
67/**
68 * Displays the details of a specific call log entry.
Flavio Lerda178eeeb2011-07-11 19:51:40 +010069 * <p>
70 * This activity can be either started with the URI of a single call log entry, or with the
71 * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries.
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080072 */
Flavio Lerdab184ed62011-08-10 18:17:55 +010073public class CallDetailActivity extends Activity {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080074 private static final String TAG = "CallDetail";
75
Flavio Lerda178eeeb2011-07-11 19:51:40 +010076 /** A long array extra containing ids of call log entries to display. */
Hugo Hudsonb002f512011-07-15 17:41:12 +010077 public static final String EXTRA_CALL_LOG_IDS = "EXTRA_CALL_LOG_IDS";
78 /** If we are started with a voicemail, we'll find the uri to play with this extra. */
79 public static final String EXTRA_VOICEMAIL_URI = "EXTRA_VOICEMAIL_URI";
80 /** If we should immediately start playback of the voicemail, this extra will be set to true. */
81 public static final String EXTRA_VOICEMAIL_START_PLAYBACK = "EXTRA_VOICEMAIL_START_PLAYBACK";
Flavio Lerda178eeeb2011-07-11 19:51:40 +010082
Flavio Lerda9a208cc2011-07-12 21:05:47 +010083 private CallTypeHelper mCallTypeHelper;
Flavio Lerda178eeeb2011-07-11 19:51:40 +010084 private PhoneNumberHelper mPhoneNumberHelper;
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010085 private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
Flavio Lerdab88abaa2011-08-02 23:38:36 +010086 private TextView mHeaderTextView;
Flavio Lerdafb63c432011-07-07 17:16:53 +010087 private ImageView mMainActionView;
Daniel Lehmannd260de42011-08-01 18:08:38 -070088 private ImageButton mMainActionPushLayerView;
Flavio Lerda9cafe472011-06-08 14:06:13 +010089 private ImageView mContactBackgroundView;
Hugo Hudson51ada362011-08-05 14:36:14 +010090 private BackgroundTaskService mBackgroundTaskService;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080091
92 private String mNumber = null;
Bai Tao09eb04f2010-09-01 15:34:16 +080093 private String mDefaultCountryIso;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070094
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080095 /* package */ LayoutInflater mInflater;
96 /* package */ Resources mResources;
Flavio Lerda9cafe472011-06-08 14:06:13 +010097 /** Helper to load contact photos. */
98 private ContactPhotoManager mContactPhotoManager;
Debashish Chatterjee0cb82242011-07-19 19:29:37 +010099 /** Helper to make async queries to content resolver. */
100 private CallDetailActivityQueryHandler mAsyncQueryHandler;
101 /** Helper to get voicemail status messages. */
102 private VoicemailStatusHelper mVoicemailStatusHelper;
103 // Views related to voicemail status message.
104 private View mStatusMessageView;
105 private TextView mStatusMessageText;
106 private TextView mStatusMessageAction;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700107
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100108 /** Whether we should show "edit number before call" in the options menu. */
109 private boolean mHasEditNumberBeforeCall;
110
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800111 static final String[] CALL_LOG_PROJECTION = new String[] {
112 CallLog.Calls.DATE,
113 CallLog.Calls.DURATION,
114 CallLog.Calls.NUMBER,
115 CallLog.Calls.TYPE,
Bai Tao09eb04f2010-09-01 15:34:16 +0800116 CallLog.Calls.COUNTRY_ISO,
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100117 CallLog.Calls.GEOCODED_LOCATION,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800118 };
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700119
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800120 static final int DATE_COLUMN_INDEX = 0;
121 static final int DURATION_COLUMN_INDEX = 1;
122 static final int NUMBER_COLUMN_INDEX = 2;
123 static final int CALL_TYPE_COLUMN_INDEX = 3;
Bai Tao09eb04f2010-09-01 15:34:16 +0800124 static final int COUNTRY_ISO_COLUMN_INDEX = 4;
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100125 static final int GEOCODED_LOCATION_COLUMN_INDEX = 5;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700126
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800127 static final String[] PHONES_PROJECTION = new String[] {
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700128 PhoneLookup._ID,
129 PhoneLookup.DISPLAY_NAME,
130 PhoneLookup.TYPE,
131 PhoneLookup.LABEL,
132 PhoneLookup.NUMBER,
Bai Tao09eb04f2010-09-01 15:34:16 +0800133 PhoneLookup.NORMALIZED_NUMBER,
Daniel Lehmann362654a2011-07-17 14:16:47 -0700134 PhoneLookup.PHOTO_URI,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800135 };
136 static final int COLUMN_INDEX_ID = 0;
137 static final int COLUMN_INDEX_NAME = 1;
138 static final int COLUMN_INDEX_TYPE = 2;
139 static final int COLUMN_INDEX_LABEL = 3;
140 static final int COLUMN_INDEX_NUMBER = 4;
Bai Tao09eb04f2010-09-01 15:34:16 +0800141 static final int COLUMN_INDEX_NORMALIZED_NUMBER = 5;
Daniel Lehmann362654a2011-07-17 14:16:47 -0700142 static final int COLUMN_INDEX_PHOTO_URI = 6;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800143
Flavio Lerdab184ed62011-08-10 18:17:55 +0100144 private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() {
145 @Override
146 public void onClick(View view) {
147 startActivity(((ViewEntry) view.getTag()).primaryIntent);
148 }
149 };
150
151 private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() {
152 @Override
153 public void onClick(View view) {
154 startActivity(((ViewEntry) view.getTag()).secondaryIntent);
155 }
156 };
157
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800158 @Override
159 protected void onCreate(Bundle icicle) {
160 super.onCreate(icicle);
161
162 setContentView(R.layout.call_detail);
163
Hugo Hudson51ada362011-08-05 14:36:14 +0100164 mBackgroundTaskService = (BackgroundTaskService) getApplicationContext().getSystemService(
165 BackgroundTaskService.BACKGROUND_TASK_SERVICE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800166 mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
167 mResources = getResources();
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700168
Daniel Lehmann6ecb7322011-08-01 21:39:29 -0700169 mCallTypeHelper = new CallTypeHelper(getResources());
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100170 mPhoneNumberHelper = new PhoneNumberHelper(mResources, getVoicemailNumber());
Flavio Lerda40569562011-07-22 21:51:29 +0100171 mPhoneCallDetailsHelper = new PhoneCallDetailsHelper(mResources, mCallTypeHelper,
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100172 mPhoneNumberHelper);
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100173 mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
174 mAsyncQueryHandler = new CallDetailActivityQueryHandler(this);
Flavio Lerdab88abaa2011-08-02 23:38:36 +0100175 mHeaderTextView = (TextView) findViewById(R.id.header_text);
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100176 mStatusMessageView = findViewById(R.id.voicemail_status);
177 mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
178 mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
Flavio Lerdafb63c432011-07-07 17:16:53 +0100179 mMainActionView = (ImageView) findViewById(R.id.main_action);
Daniel Lehmannd260de42011-08-01 18:08:38 -0700180 mMainActionPushLayerView = (ImageButton) findViewById(R.id.main_action_push_layer);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100181 mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
Bai Tao09eb04f2010-09-01 15:34:16 +0800182 mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100183 mContactPhotoManager = ContactPhotoManager.getInstance(this);
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100184 configureActionBar();
Hugo Hudson51ada362011-08-05 14:36:14 +0100185 optionallyHandleVoicemail();
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800186 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700187
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800188 @Override
189 public void onResume() {
190 super.onResume();
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100191 updateData(getCallLogEntryUris());
Hugo Hudsonb002f512011-07-15 17:41:12 +0100192 }
193
194 /**
195 * Handle voicemail playback or hide voicemail ui.
196 * <p>
197 * If the Intent used to start this Activity contains the suitable extras, then start voicemail
198 * playback. If it doesn't, then hide the voicemail ui.
199 */
Hugo Hudson757aa552011-07-20 01:15:25 +0100200 private void optionallyHandleVoicemail() {
Hugo Hudson157dde12011-07-21 23:28:13 +0100201 if (hasVoicemail()) {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100202 // Has voicemail: add the voicemail fragment. Add suitable arguments to set the uri
203 // to play and optionally start the playback.
Hugo Hudson757aa552011-07-20 01:15:25 +0100204 // Do a query to fetch the voicemail status messages.
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100205 VoicemailPlaybackFragment playbackFragment = new VoicemailPlaybackFragment();
206 Bundle fragmentArguments = new Bundle();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100207 fragmentArguments.putParcelable(EXTRA_VOICEMAIL_URI, getVoicemailUri());
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100208 if (getIntent().getBooleanExtra(EXTRA_VOICEMAIL_START_PLAYBACK, false)) {
209 fragmentArguments.putBoolean(EXTRA_VOICEMAIL_START_PLAYBACK, true);
210 }
211 playbackFragment.setArguments(fragmentArguments);
212 getFragmentManager().beginTransaction()
213 .add(R.id.voicemail_container, playbackFragment).commit();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100214 mAsyncQueryHandler.startVoicemailStatusQuery(getVoicemailUri());
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100215 markVoicemailAsRead(getVoicemailUri());
Hugo Hudson757aa552011-07-20 01:15:25 +0100216 } else {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100217 // No voicemail uri: hide the status view.
Hugo Hudson757aa552011-07-20 01:15:25 +0100218 mStatusMessageView.setVisibility(View.GONE);
Hugo Hudsonb002f512011-07-15 17:41:12 +0100219 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100220 }
221
Hugo Hudson157dde12011-07-21 23:28:13 +0100222 private boolean hasVoicemail() {
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100223 return getVoicemailUri() != null;
224 }
225
226 private Uri getVoicemailUri() {
227 return getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
Hugo Hudson157dde12011-07-21 23:28:13 +0100228 }
229
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100230 private void markVoicemailAsRead(final Uri voicemailUri) {
Hugo Hudson51ada362011-08-05 14:36:14 +0100231 mBackgroundTaskService.submit(new AbstractBackgroundTask() {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100232 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100233 public void doInBackground() {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100234 ContentValues values = new ContentValues();
235 values.put(Voicemails.IS_READ, true);
236 getContentResolver().update(voicemailUri, values, null, null);
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100237 }
Hugo Hudsona2625e42011-08-10 21:13:23 +0100238 }, AsyncTask.THREAD_POOL_EXECUTOR);
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100239 }
240
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100241 /**
242 * Returns the list of URIs to show.
243 * <p>
244 * There are two ways the URIs can be provided to the activity: as the data on the intent, or as
245 * a list of ids in the call log added as an extra on the URI.
246 * <p>
247 * If both are available, the data on the intent takes precedence.
248 */
249 private Uri[] getCallLogEntryUris() {
250 Uri uri = getIntent().getData();
251 if (uri != null) {
252 // If there is a data on the intent, it takes precedence over the extra.
253 return new Uri[]{ uri };
254 }
255 long[] ids = getIntent().getLongArrayExtra(EXTRA_CALL_LOG_IDS);
256 Uri[] uris = new Uri[ids.length];
257 for (int index = 0; index < ids.length; ++index) {
258 uris[index] = ContentUris.withAppendedId(Calls.CONTENT_URI_WITH_VOICEMAIL, ids[index]);
259 }
260 return uris;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800261 }
262
263 @Override
264 public boolean onKeyDown(int keyCode, KeyEvent event) {
265 switch (keyCode) {
266 case KeyEvent.KEYCODE_CALL: {
267 // Make sure phone isn't already busy before starting direct call
268 TelephonyManager tm = (TelephonyManager)
269 getSystemService(Context.TELEPHONY_SERVICE);
270 if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
271 Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
272 Uri.fromParts("tel", mNumber, null));
273 startActivity(callIntent);
274 return true;
275 }
276 }
277 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700278
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800279 return super.onKeyDown(keyCode, event);
280 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700281
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800282 /**
283 * Update user interface with details of given call.
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700284 *
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100285 * @param callUris URIs into {@link CallLog.Calls} of the calls to be displayed
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800286 */
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100287 private void updateData(final Uri... callUris) {
Flavio Lerda12592e82011-08-10 15:36:32 +0100288 mBackgroundTaskService.submit(new BackgroundTask() {
289 private PhoneCallDetails[] details;
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100290
Flavio Lerda12592e82011-08-10 15:36:32 +0100291 @Override
292 public void doInBackground() {
293 // TODO: All phone calls correspond to the same person, so we can make a single
294 // lookup.
295 final int numCalls = callUris.length;
296 details = new PhoneCallDetails[numCalls];
297 try {
298 for (int index = 0; index < numCalls; ++index) {
299 details[index] = getPhoneCallDetailsForUri(callUris[index]);
300 }
301 } catch (IllegalArgumentException e) {
302 // Something went wrong reading in our primary data.
303 Log.w(TAG, "invalid URI starting call details", e);
304 details = null;
Flavio Lerdacfff16d2011-07-12 23:54:40 +0100305 }
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100306 }
307
Flavio Lerda12592e82011-08-10 15:36:32 +0100308 @Override
309 public void onPostExecute() {
310 if (details == null) {
311 // Somewhere went wrong: we're going to bail out and show error to users.
312 Toast.makeText(CallDetailActivity.this, R.string.toast_call_detail_error,
313 Toast.LENGTH_SHORT).show();
314 finish();
315 return;
316 }
317
318 // We know that all calls are from the same number and the same contact, so pick the
319 // first.
320 PhoneCallDetails firstDetails = details[0];
321 mNumber = firstDetails.number.toString();
322 final long personId = firstDetails.personId;
323 final Uri photoUri = firstDetails.photoUri;
324
325 // Set the details header, based on the first phone call.
326 mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, firstDetails);
327
328 // Cache the details about the phone number.
329 final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
330 final boolean canPlaceCallsTo = mPhoneNumberHelper.canPlaceCallsTo(mNumber);
331 final boolean isVoicemailNumber = mPhoneNumberHelper.isVoicemailNumber(mNumber);
332 final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);
333
334 // Let user view contact details if they exist, otherwise add option to create new
335 // contact from this number.
336 final Intent mainActionIntent;
337 final int mainActionIcon;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100338 final String mainActionDescription;
339
340 final CharSequence nameOrNumber;
341 if (!TextUtils.isEmpty(firstDetails.name)) {
342 nameOrNumber = firstDetails.name;
343 } else {
344 nameOrNumber = firstDetails.number;
345 }
Flavio Lerda12592e82011-08-10 15:36:32 +0100346
347 if (firstDetails.personId != -1) {
348 Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, personId);
349 mainActionIntent = new Intent(Intent.ACTION_VIEW, personUri);
350 mainActionIcon = R.drawable.ic_contacts_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100351 mainActionDescription =
352 getString(R.string.description_view_contact, nameOrNumber);
Flavio Lerda12592e82011-08-10 15:36:32 +0100353 } else if (isVoicemailNumber) {
354 mainActionIntent = null;
355 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100356 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100357 } else if (isSipNumber) {
358 // TODO: This item is currently disabled for SIP addresses, because
359 // the Insert.PHONE extra only works correctly for PSTN numbers.
360 //
361 // To fix this for SIP addresses, we need to:
362 // - define ContactsContract.Intents.Insert.SIP_ADDRESS, and use it here if
363 // the current number is a SIP address
364 // - update the contacts UI code to handle Insert.SIP_ADDRESS by
365 // updating the SipAddress field
366 // and then we can remove the "!isSipNumber" check above.
367 mainActionIntent = null;
368 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100369 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100370 } else if (canPlaceCallsTo) {
371 mainActionIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
372 mainActionIntent.setType(Contacts.CONTENT_ITEM_TYPE);
373 mainActionIntent.putExtra(Insert.PHONE, mNumber);
374 mainActionIcon = R.drawable.ic_add_contact_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100375 mainActionDescription = getString(R.string.description_add_contact);
Flavio Lerda12592e82011-08-10 15:36:32 +0100376 } else {
377 // If we cannot call the number, when we probably cannot add it as a contact either.
378 // This is usually the case of private, unknown, or payphone numbers.
379 mainActionIntent = null;
380 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100381 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100382 }
383
384 if (mainActionIntent == null) {
385 mMainActionView.setVisibility(View.INVISIBLE);
386 mMainActionPushLayerView.setVisibility(View.GONE);
387 } else {
388 mMainActionView.setVisibility(View.VISIBLE);
389 mMainActionView.setImageResource(mainActionIcon);
390 mMainActionPushLayerView.setVisibility(View.VISIBLE);
391 mMainActionPushLayerView.setOnClickListener(new View.OnClickListener() {
392 @Override
393 public void onClick(View v) {
394 startActivity(mainActionIntent);
395 }
396 });
Flavio Lerdab184ed62011-08-10 18:17:55 +0100397 mMainActionPushLayerView.setContentDescription(mainActionDescription);
Flavio Lerda12592e82011-08-10 15:36:32 +0100398 }
399
Flavio Lerda12592e82011-08-10 15:36:32 +0100400 // This action allows to call the number that places the call.
401 if (canPlaceCallsTo) {
402 final CharSequence displayNumber =
403 mPhoneNumberHelper.getDisplayNumber(
404 firstDetails.number, firstDetails.formattedNumber);
405
406 ViewEntry entry = new ViewEntry(
407 getString(R.string.menu_callNumber, displayNumber),
Flavio Lerdab184ed62011-08-10 18:17:55 +0100408 new Intent(Intent.ACTION_CALL_PRIVILEGED, numberCallUri),
409 getString(R.string.description_call, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100410
411 // Only show a label if the number is shown and it is not a SIP address.
412 if (!TextUtils.isEmpty(firstDetails.number)
413 && !PhoneNumberUtils.isUriNumber(firstDetails.number.toString())) {
414 entry.label = Phone.getTypeLabel(mResources, firstDetails.numberType,
415 firstDetails.numberLabel);
416 }
417
418 // The secondary action allows to send an SMS to the number that placed the
419 // call.
420 if (mPhoneNumberHelper.canSendSmsTo(mNumber)) {
Flavio Lerdab184ed62011-08-10 18:17:55 +0100421 entry.setSecondaryAction(
422 R.drawable.ic_text_holo_dark,
Flavio Lerda12592e82011-08-10 15:36:32 +0100423 new Intent(Intent.ACTION_SENDTO,
Flavio Lerdab184ed62011-08-10 18:17:55 +0100424 Uri.fromParts("sms", mNumber, null)),
425 getString(R.string.description_send_text_message, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100426 }
427
Flavio Lerdab184ed62011-08-10 18:17:55 +0100428 configureCallButton(entry);
429 } else {
430 disableCallButton();
Flavio Lerda12592e82011-08-10 15:36:32 +0100431 }
432
433 mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
434
Flavio Lerda12592e82011-08-10 15:36:32 +0100435 ListView historyList = (ListView) findViewById(R.id.history);
436 historyList.setAdapter(
437 new CallDetailHistoryAdapter(CallDetailActivity.this, mInflater,
Flavio Lerdad1333a22011-08-11 16:19:47 +0100438 mCallTypeHelper, details, hasVoicemail(), canPlaceCallsTo));
439 BackScrollManager.bind(
440 new ScrollableHeader() {
441 private View controls = findViewById(R.id.controls);
442 private View photo = findViewById(R.id.contact_background_sizer);
443 private View nameHeader = findViewById(R.id.photo_text_bar);
444
445 @Override
446 public void setOffset(int offset) {
447 controls.setY(-offset);
448 }
449
450 @Override
451 public int getMaximumScrollableHeaderOffset() {
452 // We can scroll the photo out, but we should keep the header.
453 return photo.getHeight() - nameHeader.getHeight();
454 }
455 },
456 historyList);
Flavio Lerda12592e82011-08-10 15:36:32 +0100457 loadContactPhotos(photoUri);
Flavio Lerda4e63bab2011-08-10 18:26:46 +0100458 findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100459 }
Flavio Lerda12592e82011-08-10 15:36:32 +0100460 });
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100461 }
462
463 /** Return the phone call details for a given call log URI. */
464 private PhoneCallDetails getPhoneCallDetailsForUri(Uri callUri) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800465 ContentResolver resolver = getContentResolver();
466 Cursor callCursor = resolver.query(callUri, CALL_LOG_PROJECTION, null, null, null);
467 try {
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100468 if (callCursor == null || !callCursor.moveToFirst()) {
469 throw new IllegalArgumentException("Cannot find content: " + callUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800470 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100471
472 // Read call log specifics.
473 String number = callCursor.getString(NUMBER_COLUMN_INDEX);
474 long date = callCursor.getLong(DATE_COLUMN_INDEX);
475 long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
476 int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
477 String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100478 final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
479
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100480 if (TextUtils.isEmpty(countryIso)) {
481 countryIso = mDefaultCountryIso;
482 }
483
484 // Formatted phone number.
485 final CharSequence numberText;
486 // Read contact specifics.
487 CharSequence nameText = "";
488 int numberType = 0;
489 CharSequence numberLabel = "";
490 long personId = -1L;
Daniel Lehmann362654a2011-07-17 14:16:47 -0700491 Uri photoUri = null;
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100492 // If this is not a regular number, there is no point in looking it up in the contacts.
493 if (!mPhoneNumberHelper.canPlaceCallsTo(number)) {
494 numberText = mPhoneNumberHelper.getDisplayNumber(number, null);
495 } else {
496 // Perform a reverse-phonebook lookup to find the contact details.
497 Uri phoneUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
498 Uri.encode(number));
499 Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
500 String candidateNumberText = number;
501 try {
502 if (phonesCursor != null && phonesCursor.moveToFirst()) {
503 personId = phonesCursor.getLong(COLUMN_INDEX_ID);
504 nameText = phonesCursor.getString(COLUMN_INDEX_NAME);
Daniel Lehmann362654a2011-07-17 14:16:47 -0700505 String photoUriString = phonesCursor.getString(COLUMN_INDEX_PHOTO_URI);
506 photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100507 candidateNumberText = PhoneNumberUtils.formatNumber(
508 phonesCursor.getString(COLUMN_INDEX_NUMBER),
509 phonesCursor.getString(COLUMN_INDEX_NORMALIZED_NUMBER),
510 countryIso);
511 numberType = phonesCursor.getInt(COLUMN_INDEX_TYPE);
512 numberLabel = phonesCursor.getString(COLUMN_INDEX_LABEL);
513 } else {
514 // We could not find this contact in the contacts, just format the phone
515 // number as best as we can. All the other fields will have their default
516 // values.
517 candidateNumberText =
518 PhoneNumberUtils.formatNumber(number, countryIso);
519 }
520 } finally {
521 if (phonesCursor != null) phonesCursor.close();
522 numberText = candidateNumberText;
523 }
524 }
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100525 return new PhoneCallDetails(number, numberText, countryIso, geocode,
Flavio Lerdacb805e82011-07-18 10:31:44 +0100526 new int[]{ callType }, date, duration,
Daniel Lehmann362654a2011-07-17 14:16:47 -0700527 nameText, numberType, numberLabel, personId, photoUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800528 } finally {
529 if (callCursor != null) {
530 callCursor.close();
531 }
532 }
533 }
534
Flavio Lerda9cafe472011-06-08 14:06:13 +0100535 /** Load the contact photos and places them in the corresponding views. */
Daniel Lehmann362654a2011-07-17 14:16:47 -0700536 private void loadContactPhotos(Uri photoUri) {
537 mContactPhotoManager.loadPhoto(mContactBackgroundView, photoUri);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100538 }
539
Flavio Lerda696e8132011-07-05 19:00:23 +0100540 private String getVoicemailNumber() {
541 TelephonyManager telephonyManager =
542 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
543 return telephonyManager.getVoiceMailNumber();
544 }
545
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800546 static final class ViewEntry {
Flavio Lerdaa8956882011-07-09 21:34:38 +0100547 public final String text;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100548 public final Intent primaryIntent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100549 /** The description for accessibility of the primary action. */
550 public final String primaryDescription;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100551
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100552 public CharSequence label = null;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800553 public String number = null;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100554 /** Icon for the secondary action. */
555 public int secondaryIcon = 0;
556 /** Intent for the secondary action. If not null, an icon must be defined. */
557 public Intent secondaryIntent = null;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100558 /** The description for accessibility of the secondary action. */
559 public String secondaryDescription = null;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700560
Flavio Lerdab184ed62011-08-10 18:17:55 +0100561 public ViewEntry(String text, Intent intent, String description) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800562 this.text = text;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100563 primaryIntent = intent;
564 primaryDescription = description;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100565 }
566
Flavio Lerdab184ed62011-08-10 18:17:55 +0100567 public void setSecondaryAction(int icon, Intent intent, String description) {
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100568 secondaryIcon = icon;
569 secondaryIntent = intent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100570 secondaryDescription = description;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800571 }
572 }
573
Flavio Lerdab184ed62011-08-10 18:17:55 +0100574 /** Disables the call button area, e.g., for private numbers. */
575 private void disableCallButton() {
576 findViewById(R.id.call_and_sms).setVisibility(View.GONE);
577 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700578
Flavio Lerdab184ed62011-08-10 18:17:55 +0100579 /** Configures the call button area using the given entry. */
580 private void configureCallButton(ViewEntry entry) {
581 View convertView = findViewById(R.id.call_and_sms);
582 convertView.setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100583
Flavio Lerdab184ed62011-08-10 18:17:55 +0100584 ImageView icon = (ImageView) convertView.findViewById(R.id.call_and_sms_icon);
585 View divider = convertView.findViewById(R.id.call_and_sms_divider);
586 TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text1);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100587
Flavio Lerdab184ed62011-08-10 18:17:55 +0100588 View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
589 mainAction.setOnClickListener(mPrimaryActionListener);
590 mainAction.setTag(entry);
591 mainAction.setContentDescription(entry.primaryDescription);
592
593 if (entry.secondaryIntent != null) {
594 icon.setOnClickListener(mSecondaryActionListener);
595 icon.setImageResource(entry.secondaryIcon);
596 icon.setVisibility(View.VISIBLE);
597 icon.setTag(entry);
598 icon.setContentDescription(entry.secondaryDescription);
599 divider.setVisibility(View.VISIBLE);
600 } else {
601 icon.setVisibility(View.GONE);
602 divider.setVisibility(View.GONE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800603 }
Flavio Lerdab184ed62011-08-10 18:17:55 +0100604 text.setText(entry.text);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700605
Flavio Lerdab184ed62011-08-10 18:17:55 +0100606 View line2 = convertView.findViewById(R.id.call_and_sms_line2);
607 boolean numberEmpty = TextUtils.isEmpty(entry.number);
608 boolean labelEmpty = TextUtils.isEmpty(entry.label) || numberEmpty;
609 if (labelEmpty && numberEmpty) {
610 line2.setVisibility(View.GONE);
611 } else {
612 line2.setVisibility(View.VISIBLE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800613
Flavio Lerdab184ed62011-08-10 18:17:55 +0100614 TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
615 if (labelEmpty) {
616 label.setVisibility(View.GONE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100617 } else {
Flavio Lerdab184ed62011-08-10 18:17:55 +0100618 label.setText(entry.label);
619 label.setVisibility(View.VISIBLE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800620 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700621
Flavio Lerdab184ed62011-08-10 18:17:55 +0100622 TextView number = (TextView) convertView.findViewById(R.id.call_and_sms_number);
623 number.setText(entry.number);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800624 }
625 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700626
Flavio Lerda9cafe472011-06-08 14:06:13 +0100627 @Override
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800628 public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
629 boolean globalSearch) {
630 if (globalSearch) {
631 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
632 } else {
633 ContactsSearchManager.startSearch(this, initialQuery);
634 }
635 }
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100636
637 protected void updateVoicemailStatusMessage(Cursor statusCursor) {
638 if (statusCursor == null) {
639 mStatusMessageView.setVisibility(View.GONE);
640 return;
641 }
642 final StatusMessage message = getStatusMessage(statusCursor);
643 if (message == null || !message.showInCallDetails()) {
644 mStatusMessageView.setVisibility(View.GONE);
645 return;
646 }
647
648 mStatusMessageView.setVisibility(View.VISIBLE);
649 mStatusMessageText.setText(message.callDetailsMessageId);
650 if (message.actionMessageId != -1) {
651 mStatusMessageAction.setText(message.actionMessageId);
652 }
653 if (message.actionUri != null) {
654 mStatusMessageAction.setClickable(true);
655 mStatusMessageAction.setOnClickListener(new View.OnClickListener() {
656 @Override
657 public void onClick(View v) {
658 startActivity(new Intent(Intent.ACTION_VIEW, message.actionUri));
659 }
660 });
661 } else {
662 mStatusMessageAction.setClickable(false);
663 }
664 }
665
666 private StatusMessage getStatusMessage(Cursor statusCursor) {
667 List<StatusMessage> messages = mVoicemailStatusHelper.getStatusMessages(statusCursor);
668 Log.d(TAG, "Num status messages: " + messages.size());
669 if (messages.size() == 0) {
670 return null;
671 }
672 // There can only be a single status message per source package, so num of messages can
673 // at most be 1.
674 if (messages.size() > 1) {
675 Log.w(TAG, String.format("Expected 1, found (%d) num of status messages." +
676 " Will use the first one.", messages.size()));
677 }
678 return messages.get(0);
679 }
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100680
681 @Override
682 public boolean onCreateOptionsMenu(Menu menu) {
683 getMenuInflater().inflate(R.menu.call_details_options, menu);
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100684 return super.onCreateOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100685 }
686
687 @Override
688 public boolean onPrepareOptionsMenu(Menu menu) {
689 // This action deletes all elements in the group from the call log.
690 // We don't have this action for voicemails, because you can just use the trash button.
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100691 menu.findItem(R.id.menu_remove_from_call_log).setVisible(!hasVoicemail());
692 menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCall);
693 menu.findItem(R.id.menu_trash).setVisible(hasVoicemail());
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100694 return super.onPrepareOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100695 }
696
697 @Override
698 public boolean onMenuItemSelected(int featureId, MenuItem item) {
699 switch (item.getItemId()) {
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100700 case android.R.id.home: {
701 onHomeSelected();
702 return true;
703 }
704
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100705 // All the options menu items are handled by onMenu... methods.
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100706 default:
707 throw new IllegalArgumentException();
708 }
709 }
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100710
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100711 public void onMenuRemoveFromCallLog(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100712 final StringBuilder callIds = new StringBuilder();
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100713 for (Uri callUri : getCallLogEntryUris()) {
714 if (callIds.length() != 0) {
715 callIds.append(",");
716 }
717 callIds.append(ContentUris.parseId(callUri));
718 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100719 mBackgroundTaskService.submit(new BackgroundTask() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100720 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100721 public void doInBackground() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100722 getContentResolver().delete(Calls.CONTENT_URI_WITH_VOICEMAIL,
723 Calls._ID + " IN (" + callIds + ")", null);
724 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100725 @Override
726 public void onPostExecute() {
727 finish();
728 }
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100729 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100730 }
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100731 public void onMenuEditNumberBeforeCall(MenuItem menuItem) {
732 startActivity(new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
733 }
734
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100735 public void onMenuTrashVoicemail(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100736 final Uri voicemailUri = getVoicemailUri();
Hugo Hudson51ada362011-08-05 14:36:14 +0100737 mBackgroundTaskService.submit(new BackgroundTask() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100738 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100739 public void doInBackground() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100740 getContentResolver().delete(voicemailUri, null, null);
741 }
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100742 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100743 public void onPostExecute() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100744 finish();
745 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100746 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100747 }
748
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100749 private void configureActionBar() {
750 ActionBar actionBar = getActionBar();
751 if (actionBar != null) {
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100752 actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100753 }
754 }
755
756 /** Invoked when the user presses the home button in the action bar. */
757 private void onHomeSelected() {
758 Intent intent = new Intent(Intent.ACTION_VIEW, Calls.CONTENT_URI);
759 // This will open the call log even if the detail view has been opened directly.
760 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
761 startActivity(intent);
762 finish();
763 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800764}