blob: 85e0ff7120475540be434c8fec917b192f5e57c1 [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() {
Flavio Lerda35be86e2011-08-12 14:13:22 +0100201 View voicemailContainer = findViewById(R.id.voicemail_container);
Hugo Hudson157dde12011-07-21 23:28:13 +0100202 if (hasVoicemail()) {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100203 // Has voicemail: add the voicemail fragment. Add suitable arguments to set the uri
204 // to play and optionally start the playback.
Hugo Hudson757aa552011-07-20 01:15:25 +0100205 // Do a query to fetch the voicemail status messages.
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100206 VoicemailPlaybackFragment playbackFragment = new VoicemailPlaybackFragment();
207 Bundle fragmentArguments = new Bundle();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100208 fragmentArguments.putParcelable(EXTRA_VOICEMAIL_URI, getVoicemailUri());
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100209 if (getIntent().getBooleanExtra(EXTRA_VOICEMAIL_START_PLAYBACK, false)) {
210 fragmentArguments.putBoolean(EXTRA_VOICEMAIL_START_PLAYBACK, true);
211 }
212 playbackFragment.setArguments(fragmentArguments);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100213 voicemailContainer.setVisibility(View.VISIBLE);
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100214 getFragmentManager().beginTransaction()
215 .add(R.id.voicemail_container, playbackFragment).commit();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100216 mAsyncQueryHandler.startVoicemailStatusQuery(getVoicemailUri());
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100217 markVoicemailAsRead(getVoicemailUri());
Hugo Hudson757aa552011-07-20 01:15:25 +0100218 } else {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100219 // No voicemail uri: hide the status view.
Hugo Hudson757aa552011-07-20 01:15:25 +0100220 mStatusMessageView.setVisibility(View.GONE);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100221 voicemailContainer.setVisibility(View.GONE);
Hugo Hudsonb002f512011-07-15 17:41:12 +0100222 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100223 }
224
Hugo Hudson157dde12011-07-21 23:28:13 +0100225 private boolean hasVoicemail() {
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100226 return getVoicemailUri() != null;
227 }
228
229 private Uri getVoicemailUri() {
230 return getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
Hugo Hudson157dde12011-07-21 23:28:13 +0100231 }
232
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100233 private void markVoicemailAsRead(final Uri voicemailUri) {
Hugo Hudson51ada362011-08-05 14:36:14 +0100234 mBackgroundTaskService.submit(new AbstractBackgroundTask() {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100235 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100236 public void doInBackground() {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100237 ContentValues values = new ContentValues();
238 values.put(Voicemails.IS_READ, true);
239 getContentResolver().update(voicemailUri, values, null, null);
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100240 }
Hugo Hudsona2625e42011-08-10 21:13:23 +0100241 }, AsyncTask.THREAD_POOL_EXECUTOR);
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100242 }
243
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100244 /**
245 * Returns the list of URIs to show.
246 * <p>
247 * There are two ways the URIs can be provided to the activity: as the data on the intent, or as
248 * a list of ids in the call log added as an extra on the URI.
249 * <p>
250 * If both are available, the data on the intent takes precedence.
251 */
252 private Uri[] getCallLogEntryUris() {
253 Uri uri = getIntent().getData();
254 if (uri != null) {
255 // If there is a data on the intent, it takes precedence over the extra.
256 return new Uri[]{ uri };
257 }
258 long[] ids = getIntent().getLongArrayExtra(EXTRA_CALL_LOG_IDS);
259 Uri[] uris = new Uri[ids.length];
260 for (int index = 0; index < ids.length; ++index) {
261 uris[index] = ContentUris.withAppendedId(Calls.CONTENT_URI_WITH_VOICEMAIL, ids[index]);
262 }
263 return uris;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800264 }
265
266 @Override
267 public boolean onKeyDown(int keyCode, KeyEvent event) {
268 switch (keyCode) {
269 case KeyEvent.KEYCODE_CALL: {
270 // Make sure phone isn't already busy before starting direct call
271 TelephonyManager tm = (TelephonyManager)
272 getSystemService(Context.TELEPHONY_SERVICE);
273 if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
274 Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
275 Uri.fromParts("tel", mNumber, null));
276 startActivity(callIntent);
277 return true;
278 }
279 }
280 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700281
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800282 return super.onKeyDown(keyCode, event);
283 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700284
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800285 /**
286 * Update user interface with details of given call.
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700287 *
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100288 * @param callUris URIs into {@link CallLog.Calls} of the calls to be displayed
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800289 */
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100290 private void updateData(final Uri... callUris) {
Flavio Lerda12592e82011-08-10 15:36:32 +0100291 mBackgroundTaskService.submit(new BackgroundTask() {
292 private PhoneCallDetails[] details;
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100293
Flavio Lerda12592e82011-08-10 15:36:32 +0100294 @Override
295 public void doInBackground() {
296 // TODO: All phone calls correspond to the same person, so we can make a single
297 // lookup.
298 final int numCalls = callUris.length;
299 details = new PhoneCallDetails[numCalls];
300 try {
301 for (int index = 0; index < numCalls; ++index) {
302 details[index] = getPhoneCallDetailsForUri(callUris[index]);
303 }
304 } catch (IllegalArgumentException e) {
305 // Something went wrong reading in our primary data.
306 Log.w(TAG, "invalid URI starting call details", e);
307 details = null;
Flavio Lerdacfff16d2011-07-12 23:54:40 +0100308 }
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100309 }
310
Flavio Lerda12592e82011-08-10 15:36:32 +0100311 @Override
312 public void onPostExecute() {
313 if (details == null) {
314 // Somewhere went wrong: we're going to bail out and show error to users.
315 Toast.makeText(CallDetailActivity.this, R.string.toast_call_detail_error,
316 Toast.LENGTH_SHORT).show();
317 finish();
318 return;
319 }
320
321 // We know that all calls are from the same number and the same contact, so pick the
322 // first.
323 PhoneCallDetails firstDetails = details[0];
324 mNumber = firstDetails.number.toString();
325 final long personId = firstDetails.personId;
326 final Uri photoUri = firstDetails.photoUri;
327
328 // Set the details header, based on the first phone call.
329 mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, firstDetails);
330
331 // Cache the details about the phone number.
332 final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
333 final boolean canPlaceCallsTo = mPhoneNumberHelper.canPlaceCallsTo(mNumber);
334 final boolean isVoicemailNumber = mPhoneNumberHelper.isVoicemailNumber(mNumber);
335 final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);
336
337 // Let user view contact details if they exist, otherwise add option to create new
338 // contact from this number.
339 final Intent mainActionIntent;
340 final int mainActionIcon;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100341 final String mainActionDescription;
342
343 final CharSequence nameOrNumber;
344 if (!TextUtils.isEmpty(firstDetails.name)) {
345 nameOrNumber = firstDetails.name;
346 } else {
347 nameOrNumber = firstDetails.number;
348 }
Flavio Lerda12592e82011-08-10 15:36:32 +0100349
350 if (firstDetails.personId != -1) {
351 Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, personId);
352 mainActionIntent = new Intent(Intent.ACTION_VIEW, personUri);
353 mainActionIcon = R.drawable.ic_contacts_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100354 mainActionDescription =
355 getString(R.string.description_view_contact, nameOrNumber);
Flavio Lerda12592e82011-08-10 15:36:32 +0100356 } else if (isVoicemailNumber) {
357 mainActionIntent = null;
358 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100359 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100360 } else if (isSipNumber) {
361 // TODO: This item is currently disabled for SIP addresses, because
362 // the Insert.PHONE extra only works correctly for PSTN numbers.
363 //
364 // To fix this for SIP addresses, we need to:
365 // - define ContactsContract.Intents.Insert.SIP_ADDRESS, and use it here if
366 // the current number is a SIP address
367 // - update the contacts UI code to handle Insert.SIP_ADDRESS by
368 // updating the SipAddress field
369 // and then we can remove the "!isSipNumber" check above.
370 mainActionIntent = null;
371 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100372 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100373 } else if (canPlaceCallsTo) {
374 mainActionIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
375 mainActionIntent.setType(Contacts.CONTENT_ITEM_TYPE);
376 mainActionIntent.putExtra(Insert.PHONE, mNumber);
377 mainActionIcon = R.drawable.ic_add_contact_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100378 mainActionDescription = getString(R.string.description_add_contact);
Flavio Lerda12592e82011-08-10 15:36:32 +0100379 } else {
380 // If we cannot call the number, when we probably cannot add it as a contact either.
381 // This is usually the case of private, unknown, or payphone numbers.
382 mainActionIntent = null;
383 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100384 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100385 }
386
387 if (mainActionIntent == null) {
388 mMainActionView.setVisibility(View.INVISIBLE);
389 mMainActionPushLayerView.setVisibility(View.GONE);
390 } else {
391 mMainActionView.setVisibility(View.VISIBLE);
392 mMainActionView.setImageResource(mainActionIcon);
393 mMainActionPushLayerView.setVisibility(View.VISIBLE);
394 mMainActionPushLayerView.setOnClickListener(new View.OnClickListener() {
395 @Override
396 public void onClick(View v) {
397 startActivity(mainActionIntent);
398 }
399 });
Flavio Lerdab184ed62011-08-10 18:17:55 +0100400 mMainActionPushLayerView.setContentDescription(mainActionDescription);
Flavio Lerda12592e82011-08-10 15:36:32 +0100401 }
402
Flavio Lerda12592e82011-08-10 15:36:32 +0100403 // This action allows to call the number that places the call.
404 if (canPlaceCallsTo) {
405 final CharSequence displayNumber =
406 mPhoneNumberHelper.getDisplayNumber(
407 firstDetails.number, firstDetails.formattedNumber);
408
409 ViewEntry entry = new ViewEntry(
410 getString(R.string.menu_callNumber, displayNumber),
Flavio Lerdab184ed62011-08-10 18:17:55 +0100411 new Intent(Intent.ACTION_CALL_PRIVILEGED, numberCallUri),
412 getString(R.string.description_call, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100413
414 // Only show a label if the number is shown and it is not a SIP address.
Flavio Lerda35be86e2011-08-12 14:13:22 +0100415 if (!TextUtils.isEmpty(firstDetails.name)
416 && !TextUtils.isEmpty(firstDetails.number)
Flavio Lerda12592e82011-08-10 15:36:32 +0100417 && !PhoneNumberUtils.isUriNumber(firstDetails.number.toString())) {
418 entry.label = Phone.getTypeLabel(mResources, firstDetails.numberType,
419 firstDetails.numberLabel);
420 }
421
422 // The secondary action allows to send an SMS to the number that placed the
423 // call.
424 if (mPhoneNumberHelper.canSendSmsTo(mNumber)) {
Flavio Lerdab184ed62011-08-10 18:17:55 +0100425 entry.setSecondaryAction(
426 R.drawable.ic_text_holo_dark,
Flavio Lerda12592e82011-08-10 15:36:32 +0100427 new Intent(Intent.ACTION_SENDTO,
Flavio Lerdab184ed62011-08-10 18:17:55 +0100428 Uri.fromParts("sms", mNumber, null)),
429 getString(R.string.description_send_text_message, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100430 }
431
Flavio Lerdab184ed62011-08-10 18:17:55 +0100432 configureCallButton(entry);
433 } else {
434 disableCallButton();
Flavio Lerda12592e82011-08-10 15:36:32 +0100435 }
436
437 mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
438
Flavio Lerda12592e82011-08-10 15:36:32 +0100439 ListView historyList = (ListView) findViewById(R.id.history);
440 historyList.setAdapter(
441 new CallDetailHistoryAdapter(CallDetailActivity.this, mInflater,
Flavio Lerdad1333a22011-08-11 16:19:47 +0100442 mCallTypeHelper, details, hasVoicemail(), canPlaceCallsTo));
443 BackScrollManager.bind(
444 new ScrollableHeader() {
445 private View controls = findViewById(R.id.controls);
446 private View photo = findViewById(R.id.contact_background_sizer);
447 private View nameHeader = findViewById(R.id.photo_text_bar);
448
449 @Override
450 public void setOffset(int offset) {
451 controls.setY(-offset);
452 }
453
454 @Override
455 public int getMaximumScrollableHeaderOffset() {
456 // We can scroll the photo out, but we should keep the header.
457 return photo.getHeight() - nameHeader.getHeight();
458 }
459 },
460 historyList);
Flavio Lerda12592e82011-08-10 15:36:32 +0100461 loadContactPhotos(photoUri);
Flavio Lerda4e63bab2011-08-10 18:26:46 +0100462 findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100463 }
Flavio Lerda12592e82011-08-10 15:36:32 +0100464 });
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100465 }
466
467 /** Return the phone call details for a given call log URI. */
468 private PhoneCallDetails getPhoneCallDetailsForUri(Uri callUri) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800469 ContentResolver resolver = getContentResolver();
470 Cursor callCursor = resolver.query(callUri, CALL_LOG_PROJECTION, null, null, null);
471 try {
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100472 if (callCursor == null || !callCursor.moveToFirst()) {
473 throw new IllegalArgumentException("Cannot find content: " + callUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800474 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100475
476 // Read call log specifics.
477 String number = callCursor.getString(NUMBER_COLUMN_INDEX);
478 long date = callCursor.getLong(DATE_COLUMN_INDEX);
479 long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
480 int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
481 String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100482 final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
483
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100484 if (TextUtils.isEmpty(countryIso)) {
485 countryIso = mDefaultCountryIso;
486 }
487
488 // Formatted phone number.
489 final CharSequence numberText;
490 // Read contact specifics.
491 CharSequence nameText = "";
492 int numberType = 0;
493 CharSequence numberLabel = "";
494 long personId = -1L;
Daniel Lehmann362654a2011-07-17 14:16:47 -0700495 Uri photoUri = null;
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100496 // If this is not a regular number, there is no point in looking it up in the contacts.
497 if (!mPhoneNumberHelper.canPlaceCallsTo(number)) {
498 numberText = mPhoneNumberHelper.getDisplayNumber(number, null);
499 } else {
500 // Perform a reverse-phonebook lookup to find the contact details.
501 Uri phoneUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
502 Uri.encode(number));
503 Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
504 String candidateNumberText = number;
505 try {
506 if (phonesCursor != null && phonesCursor.moveToFirst()) {
507 personId = phonesCursor.getLong(COLUMN_INDEX_ID);
508 nameText = phonesCursor.getString(COLUMN_INDEX_NAME);
Daniel Lehmann362654a2011-07-17 14:16:47 -0700509 String photoUriString = phonesCursor.getString(COLUMN_INDEX_PHOTO_URI);
510 photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100511 candidateNumberText = PhoneNumberUtils.formatNumber(
512 phonesCursor.getString(COLUMN_INDEX_NUMBER),
513 phonesCursor.getString(COLUMN_INDEX_NORMALIZED_NUMBER),
514 countryIso);
515 numberType = phonesCursor.getInt(COLUMN_INDEX_TYPE);
516 numberLabel = phonesCursor.getString(COLUMN_INDEX_LABEL);
517 } else {
518 // We could not find this contact in the contacts, just format the phone
519 // number as best as we can. All the other fields will have their default
520 // values.
521 candidateNumberText =
522 PhoneNumberUtils.formatNumber(number, countryIso);
523 }
524 } finally {
525 if (phonesCursor != null) phonesCursor.close();
526 numberText = candidateNumberText;
527 }
528 }
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100529 return new PhoneCallDetails(number, numberText, countryIso, geocode,
Flavio Lerdacb805e82011-07-18 10:31:44 +0100530 new int[]{ callType }, date, duration,
Daniel Lehmann362654a2011-07-17 14:16:47 -0700531 nameText, numberType, numberLabel, personId, photoUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800532 } finally {
533 if (callCursor != null) {
534 callCursor.close();
535 }
536 }
537 }
538
Flavio Lerda9cafe472011-06-08 14:06:13 +0100539 /** Load the contact photos and places them in the corresponding views. */
Daniel Lehmann362654a2011-07-17 14:16:47 -0700540 private void loadContactPhotos(Uri photoUri) {
541 mContactPhotoManager.loadPhoto(mContactBackgroundView, photoUri);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100542 }
543
Flavio Lerda696e8132011-07-05 19:00:23 +0100544 private String getVoicemailNumber() {
545 TelephonyManager telephonyManager =
546 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
547 return telephonyManager.getVoiceMailNumber();
548 }
549
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800550 static final class ViewEntry {
Flavio Lerdaa8956882011-07-09 21:34:38 +0100551 public final String text;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100552 public final Intent primaryIntent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100553 /** The description for accessibility of the primary action. */
554 public final String primaryDescription;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100555
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100556 public CharSequence label = null;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100557 /** Icon for the secondary action. */
558 public int secondaryIcon = 0;
559 /** Intent for the secondary action. If not null, an icon must be defined. */
560 public Intent secondaryIntent = null;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100561 /** The description for accessibility of the secondary action. */
562 public String secondaryDescription = null;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700563
Flavio Lerdab184ed62011-08-10 18:17:55 +0100564 public ViewEntry(String text, Intent intent, String description) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800565 this.text = text;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100566 primaryIntent = intent;
567 primaryDescription = description;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100568 }
569
Flavio Lerdab184ed62011-08-10 18:17:55 +0100570 public void setSecondaryAction(int icon, Intent intent, String description) {
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100571 secondaryIcon = icon;
572 secondaryIntent = intent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100573 secondaryDescription = description;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800574 }
575 }
576
Flavio Lerdab184ed62011-08-10 18:17:55 +0100577 /** Disables the call button area, e.g., for private numbers. */
578 private void disableCallButton() {
579 findViewById(R.id.call_and_sms).setVisibility(View.GONE);
580 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700581
Flavio Lerdab184ed62011-08-10 18:17:55 +0100582 /** Configures the call button area using the given entry. */
583 private void configureCallButton(ViewEntry entry) {
584 View convertView = findViewById(R.id.call_and_sms);
585 convertView.setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100586
Flavio Lerdab184ed62011-08-10 18:17:55 +0100587 ImageView icon = (ImageView) convertView.findViewById(R.id.call_and_sms_icon);
588 View divider = convertView.findViewById(R.id.call_and_sms_divider);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100589 TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100590
Flavio Lerdab184ed62011-08-10 18:17:55 +0100591 View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
592 mainAction.setOnClickListener(mPrimaryActionListener);
593 mainAction.setTag(entry);
594 mainAction.setContentDescription(entry.primaryDescription);
595
596 if (entry.secondaryIntent != null) {
597 icon.setOnClickListener(mSecondaryActionListener);
598 icon.setImageResource(entry.secondaryIcon);
599 icon.setVisibility(View.VISIBLE);
600 icon.setTag(entry);
601 icon.setContentDescription(entry.secondaryDescription);
602 divider.setVisibility(View.VISIBLE);
603 } else {
604 icon.setVisibility(View.GONE);
605 divider.setVisibility(View.GONE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800606 }
Flavio Lerdab184ed62011-08-10 18:17:55 +0100607 text.setText(entry.text);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700608
Flavio Lerda35be86e2011-08-12 14:13:22 +0100609 TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
610 if (TextUtils.isEmpty(entry.label)) {
611 label.setVisibility(View.GONE);
Flavio Lerdab184ed62011-08-10 18:17:55 +0100612 } else {
Flavio Lerda35be86e2011-08-12 14:13:22 +0100613 label.setText(entry.label);
614 label.setVisibility(View.VISIBLE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800615 }
616 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700617
Flavio Lerda9cafe472011-06-08 14:06:13 +0100618 @Override
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800619 public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
620 boolean globalSearch) {
621 if (globalSearch) {
622 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
623 } else {
624 ContactsSearchManager.startSearch(this, initialQuery);
625 }
626 }
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100627
628 protected void updateVoicemailStatusMessage(Cursor statusCursor) {
629 if (statusCursor == null) {
630 mStatusMessageView.setVisibility(View.GONE);
631 return;
632 }
633 final StatusMessage message = getStatusMessage(statusCursor);
634 if (message == null || !message.showInCallDetails()) {
635 mStatusMessageView.setVisibility(View.GONE);
636 return;
637 }
638
639 mStatusMessageView.setVisibility(View.VISIBLE);
640 mStatusMessageText.setText(message.callDetailsMessageId);
641 if (message.actionMessageId != -1) {
642 mStatusMessageAction.setText(message.actionMessageId);
643 }
644 if (message.actionUri != null) {
645 mStatusMessageAction.setClickable(true);
646 mStatusMessageAction.setOnClickListener(new View.OnClickListener() {
647 @Override
648 public void onClick(View v) {
649 startActivity(new Intent(Intent.ACTION_VIEW, message.actionUri));
650 }
651 });
652 } else {
653 mStatusMessageAction.setClickable(false);
654 }
655 }
656
657 private StatusMessage getStatusMessage(Cursor statusCursor) {
658 List<StatusMessage> messages = mVoicemailStatusHelper.getStatusMessages(statusCursor);
659 Log.d(TAG, "Num status messages: " + messages.size());
660 if (messages.size() == 0) {
661 return null;
662 }
663 // There can only be a single status message per source package, so num of messages can
664 // at most be 1.
665 if (messages.size() > 1) {
666 Log.w(TAG, String.format("Expected 1, found (%d) num of status messages." +
667 " Will use the first one.", messages.size()));
668 }
669 return messages.get(0);
670 }
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100671
672 @Override
673 public boolean onCreateOptionsMenu(Menu menu) {
674 getMenuInflater().inflate(R.menu.call_details_options, menu);
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100675 return super.onCreateOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100676 }
677
678 @Override
679 public boolean onPrepareOptionsMenu(Menu menu) {
680 // This action deletes all elements in the group from the call log.
681 // We don't have this action for voicemails, because you can just use the trash button.
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100682 menu.findItem(R.id.menu_remove_from_call_log).setVisible(!hasVoicemail());
683 menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCall);
684 menu.findItem(R.id.menu_trash).setVisible(hasVoicemail());
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100685 return super.onPrepareOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100686 }
687
688 @Override
689 public boolean onMenuItemSelected(int featureId, MenuItem item) {
690 switch (item.getItemId()) {
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100691 case android.R.id.home: {
692 onHomeSelected();
693 return true;
694 }
695
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100696 // All the options menu items are handled by onMenu... methods.
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100697 default:
698 throw new IllegalArgumentException();
699 }
700 }
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100701
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100702 public void onMenuRemoveFromCallLog(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100703 final StringBuilder callIds = new StringBuilder();
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100704 for (Uri callUri : getCallLogEntryUris()) {
705 if (callIds.length() != 0) {
706 callIds.append(",");
707 }
708 callIds.append(ContentUris.parseId(callUri));
709 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100710 mBackgroundTaskService.submit(new BackgroundTask() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100711 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100712 public void doInBackground() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100713 getContentResolver().delete(Calls.CONTENT_URI_WITH_VOICEMAIL,
714 Calls._ID + " IN (" + callIds + ")", null);
715 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100716 @Override
717 public void onPostExecute() {
718 finish();
719 }
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100720 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100721 }
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100722 public void onMenuEditNumberBeforeCall(MenuItem menuItem) {
723 startActivity(new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
724 }
725
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100726 public void onMenuTrashVoicemail(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100727 final Uri voicemailUri = getVoicemailUri();
Hugo Hudson51ada362011-08-05 14:36:14 +0100728 mBackgroundTaskService.submit(new BackgroundTask() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100729 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100730 public void doInBackground() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100731 getContentResolver().delete(voicemailUri, null, null);
732 }
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100733 @Override
Hugo Hudson51ada362011-08-05 14:36:14 +0100734 public void onPostExecute() {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100735 finish();
736 }
Hugo Hudson51ada362011-08-05 14:36:14 +0100737 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100738 }
739
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100740 private void configureActionBar() {
741 ActionBar actionBar = getActionBar();
742 if (actionBar != null) {
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100743 actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100744 }
745 }
746
747 /** Invoked when the user presses the home button in the action bar. */
748 private void onHomeSelected() {
749 Intent intent = new Intent(Intent.ACTION_VIEW, Calls.CONTENT_URI);
750 // This will open the call log even if the detail view has been opened directly.
751 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
752 startActivity(intent);
753 finish();
754 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800755}