blob: 4941121a104e41f3745882f16d27a379955ce0ef [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 Hudson9c747ac2011-08-17 00:23:01 +010023import com.android.contacts.util.AsyncTaskExecutor;
24import com.android.contacts.util.AsyncTaskExecutors;
Hugo Hudsonb002f512011-07-15 17:41:12 +010025import com.android.contacts.voicemail.VoicemailPlaybackFragment;
Debashish Chatterjee0cb82242011-07-19 19:29:37 +010026import com.android.contacts.voicemail.VoicemailStatusHelper;
27import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
28import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
Amith Yamasani8bbe2f22009-03-24 21:24:12 -070029
Flavio Lerdad44e83a2011-07-24 23:10:17 +010030import android.app.ActionBar;
Flavio Lerdab184ed62011-08-10 18:17:55 +010031import android.app.Activity;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080032import android.content.ContentResolver;
33import android.content.ContentUris;
Debashish Chatterjee0a139002011-08-02 18:27:11 +010034import android.content.ContentValues;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080035import android.content.Context;
36import android.content.Intent;
37import android.content.res.Resources;
38import android.database.Cursor;
39import android.net.Uri;
Hugo Hudsona2625e42011-08-10 21:13:23 +010040import android.os.AsyncTask;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080041import android.os.Bundle;
42import android.provider.CallLog;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080043import android.provider.CallLog.Calls;
Flavio Lerda9cafe472011-06-08 14:06:13 +010044import android.provider.Contacts.Intents.Insert;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +010045import android.provider.ContactsContract.CommonDataKinds.Phone;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -070046import android.provider.ContactsContract.Contacts;
47import android.provider.ContactsContract.PhoneLookup;
Debashish Chatterjee0a139002011-08-02 18:27:11 +010048import android.provider.VoicemailContract.Voicemails;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080049import android.telephony.PhoneNumberUtils;
50import android.telephony.TelephonyManager;
51import android.text.TextUtils;
Flavio Lerda178eeeb2011-07-11 19:51:40 +010052import android.util.Log;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080053import android.view.KeyEvent;
54import android.view.LayoutInflater;
Flavio Lerda94d7bab2011-07-22 16:52:34 +010055import android.view.Menu;
56import android.view.MenuItem;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080057import android.view.View;
Daniel Lehmannd260de42011-08-01 18:08:38 -070058import android.widget.ImageButton;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080059import android.widget.ImageView;
Flavio Lerda9a208cc2011-07-12 21:05:47 +010060import android.widget.ListView;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080061import android.widget.TextView;
62import android.widget.Toast;
63
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080064import java.util.List;
65
66/**
67 * Displays the details of a specific call log entry.
Flavio Lerda178eeeb2011-07-11 19:51:40 +010068 * <p>
69 * This activity can be either started with the URI of a single call log entry, or with the
70 * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries.
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080071 */
Flavio Lerdab184ed62011-08-10 18:17:55 +010072public class CallDetailActivity extends Activity {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080073 private static final String TAG = "CallDetail";
74
Hugo Hudson9c747ac2011-08-17 00:23:01 +010075 /** The enumeration of {@link AsyncTask} objects used in this class. */
76 public enum Tasks {
77 MARK_VOICEMAIL_READ,
78 DELETE_VOICEMAIL_AND_FINISH,
79 REMOVE_FROM_CALL_LOG_AND_FINISH,
80 UPDATE_PHONE_CALL_DETAILS,
81 }
82
Flavio Lerda178eeeb2011-07-11 19:51:40 +010083 /** A long array extra containing ids of call log entries to display. */
Hugo Hudsonb002f512011-07-15 17:41:12 +010084 public static final String EXTRA_CALL_LOG_IDS = "EXTRA_CALL_LOG_IDS";
85 /** If we are started with a voicemail, we'll find the uri to play with this extra. */
86 public static final String EXTRA_VOICEMAIL_URI = "EXTRA_VOICEMAIL_URI";
87 /** If we should immediately start playback of the voicemail, this extra will be set to true. */
88 public static final String EXTRA_VOICEMAIL_START_PLAYBACK = "EXTRA_VOICEMAIL_START_PLAYBACK";
Flavio Lerda178eeeb2011-07-11 19:51:40 +010089
Flavio Lerda9a208cc2011-07-12 21:05:47 +010090 private CallTypeHelper mCallTypeHelper;
Flavio Lerda178eeeb2011-07-11 19:51:40 +010091 private PhoneNumberHelper mPhoneNumberHelper;
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010092 private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
Flavio Lerdab88abaa2011-08-02 23:38:36 +010093 private TextView mHeaderTextView;
Flavio Lerdafb63c432011-07-07 17:16:53 +010094 private ImageView mMainActionView;
Daniel Lehmannd260de42011-08-01 18:08:38 -070095 private ImageButton mMainActionPushLayerView;
Flavio Lerda9cafe472011-06-08 14:06:13 +010096 private ImageView mContactBackgroundView;
Hugo Hudson9c747ac2011-08-17 00:23:01 +010097 private AsyncTaskExecutor mAsyncTaskExecutor;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080098
99 private String mNumber = null;
Bai Tao09eb04f2010-09-01 15:34:16 +0800100 private String mDefaultCountryIso;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700101
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800102 /* package */ LayoutInflater mInflater;
103 /* package */ Resources mResources;
Flavio Lerda9cafe472011-06-08 14:06:13 +0100104 /** Helper to load contact photos. */
105 private ContactPhotoManager mContactPhotoManager;
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100106 /** Helper to make async queries to content resolver. */
107 private CallDetailActivityQueryHandler mAsyncQueryHandler;
108 /** Helper to get voicemail status messages. */
109 private VoicemailStatusHelper mVoicemailStatusHelper;
110 // Views related to voicemail status message.
111 private View mStatusMessageView;
112 private TextView mStatusMessageText;
113 private TextView mStatusMessageAction;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700114
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100115 /** Whether we should show "edit number before call" in the options menu. */
116 private boolean mHasEditNumberBeforeCall;
117
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800118 static final String[] CALL_LOG_PROJECTION = new String[] {
119 CallLog.Calls.DATE,
120 CallLog.Calls.DURATION,
121 CallLog.Calls.NUMBER,
122 CallLog.Calls.TYPE,
Bai Tao09eb04f2010-09-01 15:34:16 +0800123 CallLog.Calls.COUNTRY_ISO,
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100124 CallLog.Calls.GEOCODED_LOCATION,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800125 };
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700126
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800127 static final int DATE_COLUMN_INDEX = 0;
128 static final int DURATION_COLUMN_INDEX = 1;
129 static final int NUMBER_COLUMN_INDEX = 2;
130 static final int CALL_TYPE_COLUMN_INDEX = 3;
Bai Tao09eb04f2010-09-01 15:34:16 +0800131 static final int COUNTRY_ISO_COLUMN_INDEX = 4;
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100132 static final int GEOCODED_LOCATION_COLUMN_INDEX = 5;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700133
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800134 static final String[] PHONES_PROJECTION = new String[] {
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700135 PhoneLookup._ID,
136 PhoneLookup.DISPLAY_NAME,
137 PhoneLookup.TYPE,
138 PhoneLookup.LABEL,
139 PhoneLookup.NUMBER,
Bai Tao09eb04f2010-09-01 15:34:16 +0800140 PhoneLookup.NORMALIZED_NUMBER,
Daniel Lehmann362654a2011-07-17 14:16:47 -0700141 PhoneLookup.PHOTO_URI,
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800142 };
143 static final int COLUMN_INDEX_ID = 0;
144 static final int COLUMN_INDEX_NAME = 1;
145 static final int COLUMN_INDEX_TYPE = 2;
146 static final int COLUMN_INDEX_LABEL = 3;
147 static final int COLUMN_INDEX_NUMBER = 4;
Bai Tao09eb04f2010-09-01 15:34:16 +0800148 static final int COLUMN_INDEX_NORMALIZED_NUMBER = 5;
Daniel Lehmann362654a2011-07-17 14:16:47 -0700149 static final int COLUMN_INDEX_PHOTO_URI = 6;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800150
Flavio Lerdab184ed62011-08-10 18:17:55 +0100151 private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() {
152 @Override
153 public void onClick(View view) {
154 startActivity(((ViewEntry) view.getTag()).primaryIntent);
155 }
156 };
157
158 private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() {
159 @Override
160 public void onClick(View view) {
161 startActivity(((ViewEntry) view.getTag()).secondaryIntent);
162 }
163 };
164
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800165 @Override
166 protected void onCreate(Bundle icicle) {
167 super.onCreate(icicle);
168
169 setContentView(R.layout.call_detail);
170
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100171 mAsyncTaskExecutor = AsyncTaskExecutors.createThreadPoolExecutor();
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800172 mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
173 mResources = getResources();
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700174
Daniel Lehmann6ecb7322011-08-01 21:39:29 -0700175 mCallTypeHelper = new CallTypeHelper(getResources());
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100176 mPhoneNumberHelper = new PhoneNumberHelper(mResources, getVoicemailNumber());
Flavio Lerda40569562011-07-22 21:51:29 +0100177 mPhoneCallDetailsHelper = new PhoneCallDetailsHelper(mResources, mCallTypeHelper,
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100178 mPhoneNumberHelper);
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100179 mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
180 mAsyncQueryHandler = new CallDetailActivityQueryHandler(this);
Flavio Lerdab88abaa2011-08-02 23:38:36 +0100181 mHeaderTextView = (TextView) findViewById(R.id.header_text);
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100182 mStatusMessageView = findViewById(R.id.voicemail_status);
183 mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
184 mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
Flavio Lerdafb63c432011-07-07 17:16:53 +0100185 mMainActionView = (ImageView) findViewById(R.id.main_action);
Daniel Lehmannd260de42011-08-01 18:08:38 -0700186 mMainActionPushLayerView = (ImageButton) findViewById(R.id.main_action_push_layer);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100187 mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
Bai Tao09eb04f2010-09-01 15:34:16 +0800188 mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100189 mContactPhotoManager = ContactPhotoManager.getInstance(this);
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100190 configureActionBar();
Hugo Hudson51ada362011-08-05 14:36:14 +0100191 optionallyHandleVoicemail();
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800192 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700193
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800194 @Override
195 public void onResume() {
196 super.onResume();
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100197 updateData(getCallLogEntryUris());
Hugo Hudsonb002f512011-07-15 17:41:12 +0100198 }
199
200 /**
201 * Handle voicemail playback or hide voicemail ui.
202 * <p>
203 * If the Intent used to start this Activity contains the suitable extras, then start voicemail
204 * playback. If it doesn't, then hide the voicemail ui.
205 */
Hugo Hudson757aa552011-07-20 01:15:25 +0100206 private void optionallyHandleVoicemail() {
Flavio Lerda35be86e2011-08-12 14:13:22 +0100207 View voicemailContainer = findViewById(R.id.voicemail_container);
Hugo Hudson157dde12011-07-21 23:28:13 +0100208 if (hasVoicemail()) {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100209 // Has voicemail: add the voicemail fragment. Add suitable arguments to set the uri
210 // to play and optionally start the playback.
Hugo Hudson757aa552011-07-20 01:15:25 +0100211 // Do a query to fetch the voicemail status messages.
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100212 VoicemailPlaybackFragment playbackFragment = new VoicemailPlaybackFragment();
213 Bundle fragmentArguments = new Bundle();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100214 fragmentArguments.putParcelable(EXTRA_VOICEMAIL_URI, getVoicemailUri());
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100215 if (getIntent().getBooleanExtra(EXTRA_VOICEMAIL_START_PLAYBACK, false)) {
216 fragmentArguments.putBoolean(EXTRA_VOICEMAIL_START_PLAYBACK, true);
217 }
218 playbackFragment.setArguments(fragmentArguments);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100219 voicemailContainer.setVisibility(View.VISIBLE);
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100220 getFragmentManager().beginTransaction()
221 .add(R.id.voicemail_container, playbackFragment).commit();
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100222 mAsyncQueryHandler.startVoicemailStatusQuery(getVoicemailUri());
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100223 markVoicemailAsRead(getVoicemailUri());
Hugo Hudson757aa552011-07-20 01:15:25 +0100224 } else {
Hugo Hudsona9ad6942011-07-29 17:06:04 +0100225 // No voicemail uri: hide the status view.
Hugo Hudson757aa552011-07-20 01:15:25 +0100226 mStatusMessageView.setVisibility(View.GONE);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100227 voicemailContainer.setVisibility(View.GONE);
Hugo Hudsonb002f512011-07-15 17:41:12 +0100228 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100229 }
230
Hugo Hudson157dde12011-07-21 23:28:13 +0100231 private boolean hasVoicemail() {
Hugo Hudson7b02fde2011-08-02 20:56:48 +0100232 return getVoicemailUri() != null;
233 }
234
235 private Uri getVoicemailUri() {
236 return getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI);
Hugo Hudson157dde12011-07-21 23:28:13 +0100237 }
238
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100239 private void markVoicemailAsRead(final Uri voicemailUri) {
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100240 mAsyncTaskExecutor.submit(Tasks.MARK_VOICEMAIL_READ, new AsyncTask<Void, Void, Void>() {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100241 @Override
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100242 public Void doInBackground(Void... params) {
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100243 ContentValues values = new ContentValues();
244 values.put(Voicemails.IS_READ, true);
245 getContentResolver().update(voicemailUri, values, null, null);
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100246 return null;
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100247 }
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100248 });
Debashish Chatterjee0a139002011-08-02 18:27:11 +0100249 }
250
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100251 /**
252 * Returns the list of URIs to show.
253 * <p>
254 * There are two ways the URIs can be provided to the activity: as the data on the intent, or as
255 * a list of ids in the call log added as an extra on the URI.
256 * <p>
257 * If both are available, the data on the intent takes precedence.
258 */
259 private Uri[] getCallLogEntryUris() {
260 Uri uri = getIntent().getData();
261 if (uri != null) {
262 // If there is a data on the intent, it takes precedence over the extra.
263 return new Uri[]{ uri };
264 }
265 long[] ids = getIntent().getLongArrayExtra(EXTRA_CALL_LOG_IDS);
266 Uri[] uris = new Uri[ids.length];
267 for (int index = 0; index < ids.length; ++index) {
268 uris[index] = ContentUris.withAppendedId(Calls.CONTENT_URI_WITH_VOICEMAIL, ids[index]);
269 }
270 return uris;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800271 }
272
273 @Override
274 public boolean onKeyDown(int keyCode, KeyEvent event) {
275 switch (keyCode) {
276 case KeyEvent.KEYCODE_CALL: {
277 // Make sure phone isn't already busy before starting direct call
278 TelephonyManager tm = (TelephonyManager)
279 getSystemService(Context.TELEPHONY_SERVICE);
280 if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
281 Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
282 Uri.fromParts("tel", mNumber, null));
283 startActivity(callIntent);
284 return true;
285 }
286 }
287 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700288
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800289 return super.onKeyDown(keyCode, event);
290 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700291
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800292 /**
293 * Update user interface with details of given call.
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700294 *
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100295 * @param callUris URIs into {@link CallLog.Calls} of the calls to be displayed
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800296 */
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100297 private void updateData(final Uri... callUris) {
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100298 class UpdateContactDetailsTask extends AsyncTask<Void, Void, PhoneCallDetails[]> {
Flavio Lerda12592e82011-08-10 15:36:32 +0100299 @Override
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100300 public PhoneCallDetails[] doInBackground(Void... params) {
Flavio Lerda12592e82011-08-10 15:36:32 +0100301 // TODO: All phone calls correspond to the same person, so we can make a single
302 // lookup.
303 final int numCalls = callUris.length;
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100304 PhoneCallDetails[] details = new PhoneCallDetails[numCalls];
Flavio Lerda12592e82011-08-10 15:36:32 +0100305 try {
306 for (int index = 0; index < numCalls; ++index) {
307 details[index] = getPhoneCallDetailsForUri(callUris[index]);
308 }
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100309 return details;
Flavio Lerda12592e82011-08-10 15:36:32 +0100310 } catch (IllegalArgumentException e) {
311 // Something went wrong reading in our primary data.
312 Log.w(TAG, "invalid URI starting call details", e);
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100313 return null;
Flavio Lerdacfff16d2011-07-12 23:54:40 +0100314 }
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100315 }
316
Flavio Lerda12592e82011-08-10 15:36:32 +0100317 @Override
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100318 public void onPostExecute(PhoneCallDetails[] details) {
Flavio Lerda12592e82011-08-10 15:36:32 +0100319 if (details == null) {
320 // Somewhere went wrong: we're going to bail out and show error to users.
321 Toast.makeText(CallDetailActivity.this, R.string.toast_call_detail_error,
322 Toast.LENGTH_SHORT).show();
323 finish();
324 return;
325 }
326
327 // We know that all calls are from the same number and the same contact, so pick the
328 // first.
329 PhoneCallDetails firstDetails = details[0];
330 mNumber = firstDetails.number.toString();
331 final long personId = firstDetails.personId;
332 final Uri photoUri = firstDetails.photoUri;
333
334 // Set the details header, based on the first phone call.
335 mPhoneCallDetailsHelper.setPhoneCallName(mHeaderTextView, firstDetails);
336
337 // Cache the details about the phone number.
338 final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
339 final boolean canPlaceCallsTo = mPhoneNumberHelper.canPlaceCallsTo(mNumber);
340 final boolean isVoicemailNumber = mPhoneNumberHelper.isVoicemailNumber(mNumber);
341 final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);
342
343 // Let user view contact details if they exist, otherwise add option to create new
344 // contact from this number.
345 final Intent mainActionIntent;
346 final int mainActionIcon;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100347 final String mainActionDescription;
348
349 final CharSequence nameOrNumber;
350 if (!TextUtils.isEmpty(firstDetails.name)) {
351 nameOrNumber = firstDetails.name;
352 } else {
353 nameOrNumber = firstDetails.number;
354 }
Flavio Lerda12592e82011-08-10 15:36:32 +0100355
356 if (firstDetails.personId != -1) {
357 Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, personId);
358 mainActionIntent = new Intent(Intent.ACTION_VIEW, personUri);
359 mainActionIcon = R.drawable.ic_contacts_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100360 mainActionDescription =
361 getString(R.string.description_view_contact, nameOrNumber);
Flavio Lerda12592e82011-08-10 15:36:32 +0100362 } else if (isVoicemailNumber) {
363 mainActionIntent = null;
364 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100365 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100366 } else if (isSipNumber) {
367 // TODO: This item is currently disabled for SIP addresses, because
368 // the Insert.PHONE extra only works correctly for PSTN numbers.
369 //
370 // To fix this for SIP addresses, we need to:
371 // - define ContactsContract.Intents.Insert.SIP_ADDRESS, and use it here if
372 // the current number is a SIP address
373 // - update the contacts UI code to handle Insert.SIP_ADDRESS by
374 // updating the SipAddress field
375 // and then we can remove the "!isSipNumber" check above.
376 mainActionIntent = null;
377 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100378 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100379 } else if (canPlaceCallsTo) {
380 mainActionIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
381 mainActionIntent.setType(Contacts.CONTENT_ITEM_TYPE);
382 mainActionIntent.putExtra(Insert.PHONE, mNumber);
383 mainActionIcon = R.drawable.ic_add_contact_holo_dark;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100384 mainActionDescription = getString(R.string.description_add_contact);
Flavio Lerda12592e82011-08-10 15:36:32 +0100385 } else {
386 // If we cannot call the number, when we probably cannot add it as a contact either.
387 // This is usually the case of private, unknown, or payphone numbers.
388 mainActionIntent = null;
389 mainActionIcon = 0;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100390 mainActionDescription = null;
Flavio Lerda12592e82011-08-10 15:36:32 +0100391 }
392
393 if (mainActionIntent == null) {
394 mMainActionView.setVisibility(View.INVISIBLE);
395 mMainActionPushLayerView.setVisibility(View.GONE);
396 } else {
397 mMainActionView.setVisibility(View.VISIBLE);
398 mMainActionView.setImageResource(mainActionIcon);
399 mMainActionPushLayerView.setVisibility(View.VISIBLE);
400 mMainActionPushLayerView.setOnClickListener(new View.OnClickListener() {
401 @Override
402 public void onClick(View v) {
403 startActivity(mainActionIntent);
404 }
405 });
Flavio Lerdab184ed62011-08-10 18:17:55 +0100406 mMainActionPushLayerView.setContentDescription(mainActionDescription);
Flavio Lerda12592e82011-08-10 15:36:32 +0100407 }
408
Flavio Lerda12592e82011-08-10 15:36:32 +0100409 // This action allows to call the number that places the call.
410 if (canPlaceCallsTo) {
411 final CharSequence displayNumber =
412 mPhoneNumberHelper.getDisplayNumber(
413 firstDetails.number, firstDetails.formattedNumber);
414
415 ViewEntry entry = new ViewEntry(
416 getString(R.string.menu_callNumber, displayNumber),
Flavio Lerdab184ed62011-08-10 18:17:55 +0100417 new Intent(Intent.ACTION_CALL_PRIVILEGED, numberCallUri),
418 getString(R.string.description_call, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100419
420 // Only show a label if the number is shown and it is not a SIP address.
Flavio Lerda35be86e2011-08-12 14:13:22 +0100421 if (!TextUtils.isEmpty(firstDetails.name)
422 && !TextUtils.isEmpty(firstDetails.number)
Flavio Lerda12592e82011-08-10 15:36:32 +0100423 && !PhoneNumberUtils.isUriNumber(firstDetails.number.toString())) {
424 entry.label = Phone.getTypeLabel(mResources, firstDetails.numberType,
425 firstDetails.numberLabel);
426 }
427
428 // The secondary action allows to send an SMS to the number that placed the
429 // call.
430 if (mPhoneNumberHelper.canSendSmsTo(mNumber)) {
Flavio Lerdab184ed62011-08-10 18:17:55 +0100431 entry.setSecondaryAction(
432 R.drawable.ic_text_holo_dark,
Flavio Lerda12592e82011-08-10 15:36:32 +0100433 new Intent(Intent.ACTION_SENDTO,
Flavio Lerdab184ed62011-08-10 18:17:55 +0100434 Uri.fromParts("sms", mNumber, null)),
435 getString(R.string.description_send_text_message, nameOrNumber));
Flavio Lerda12592e82011-08-10 15:36:32 +0100436 }
437
Flavio Lerdab184ed62011-08-10 18:17:55 +0100438 configureCallButton(entry);
439 } else {
440 disableCallButton();
Flavio Lerda12592e82011-08-10 15:36:32 +0100441 }
442
443 mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
444
Flavio Lerda12592e82011-08-10 15:36:32 +0100445 ListView historyList = (ListView) findViewById(R.id.history);
446 historyList.setAdapter(
447 new CallDetailHistoryAdapter(CallDetailActivity.this, mInflater,
Flavio Lerdad1333a22011-08-11 16:19:47 +0100448 mCallTypeHelper, details, hasVoicemail(), canPlaceCallsTo));
449 BackScrollManager.bind(
450 new ScrollableHeader() {
451 private View controls = findViewById(R.id.controls);
452 private View photo = findViewById(R.id.contact_background_sizer);
453 private View nameHeader = findViewById(R.id.photo_text_bar);
454
455 @Override
456 public void setOffset(int offset) {
457 controls.setY(-offset);
458 }
459
460 @Override
461 public int getMaximumScrollableHeaderOffset() {
462 // We can scroll the photo out, but we should keep the header.
463 return photo.getHeight() - nameHeader.getHeight();
464 }
465 },
466 historyList);
Flavio Lerda12592e82011-08-10 15:36:32 +0100467 loadContactPhotos(photoUri);
Flavio Lerda4e63bab2011-08-10 18:26:46 +0100468 findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100469 }
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100470 }
471 mAsyncTaskExecutor.submit(Tasks.UPDATE_PHONE_CALL_DETAILS, new UpdateContactDetailsTask());
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100472 }
473
474 /** Return the phone call details for a given call log URI. */
475 private PhoneCallDetails getPhoneCallDetailsForUri(Uri callUri) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800476 ContentResolver resolver = getContentResolver();
477 Cursor callCursor = resolver.query(callUri, CALL_LOG_PROJECTION, null, null, null);
478 try {
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100479 if (callCursor == null || !callCursor.moveToFirst()) {
480 throw new IllegalArgumentException("Cannot find content: " + callUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800481 }
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100482
483 // Read call log specifics.
484 String number = callCursor.getString(NUMBER_COLUMN_INDEX);
485 long date = callCursor.getLong(DATE_COLUMN_INDEX);
486 long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
487 int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
488 String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100489 final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
490
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100491 if (TextUtils.isEmpty(countryIso)) {
492 countryIso = mDefaultCountryIso;
493 }
494
495 // Formatted phone number.
496 final CharSequence numberText;
497 // Read contact specifics.
498 CharSequence nameText = "";
499 int numberType = 0;
500 CharSequence numberLabel = "";
501 long personId = -1L;
Daniel Lehmann362654a2011-07-17 14:16:47 -0700502 Uri photoUri = null;
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100503 // If this is not a regular number, there is no point in looking it up in the contacts.
504 if (!mPhoneNumberHelper.canPlaceCallsTo(number)) {
505 numberText = mPhoneNumberHelper.getDisplayNumber(number, null);
506 } else {
507 // Perform a reverse-phonebook lookup to find the contact details.
508 Uri phoneUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
509 Uri.encode(number));
510 Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
511 String candidateNumberText = number;
512 try {
513 if (phonesCursor != null && phonesCursor.moveToFirst()) {
514 personId = phonesCursor.getLong(COLUMN_INDEX_ID);
515 nameText = phonesCursor.getString(COLUMN_INDEX_NAME);
Daniel Lehmann362654a2011-07-17 14:16:47 -0700516 String photoUriString = phonesCursor.getString(COLUMN_INDEX_PHOTO_URI);
517 photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
Flavio Lerda178eeeb2011-07-11 19:51:40 +0100518 candidateNumberText = PhoneNumberUtils.formatNumber(
519 phonesCursor.getString(COLUMN_INDEX_NUMBER),
520 phonesCursor.getString(COLUMN_INDEX_NORMALIZED_NUMBER),
521 countryIso);
522 numberType = phonesCursor.getInt(COLUMN_INDEX_TYPE);
523 numberLabel = phonesCursor.getString(COLUMN_INDEX_LABEL);
524 } else {
525 // We could not find this contact in the contacts, just format the phone
526 // number as best as we can. All the other fields will have their default
527 // values.
528 candidateNumberText =
529 PhoneNumberUtils.formatNumber(number, countryIso);
530 }
531 } finally {
532 if (phonesCursor != null) phonesCursor.close();
533 numberText = candidateNumberText;
534 }
535 }
Flavio Lerda71fc6ec2011-08-09 17:24:29 +0100536 return new PhoneCallDetails(number, numberText, countryIso, geocode,
Flavio Lerdacb805e82011-07-18 10:31:44 +0100537 new int[]{ callType }, date, duration,
Daniel Lehmann362654a2011-07-17 14:16:47 -0700538 nameText, numberType, numberLabel, personId, photoUri);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800539 } finally {
540 if (callCursor != null) {
541 callCursor.close();
542 }
543 }
544 }
545
Flavio Lerda9cafe472011-06-08 14:06:13 +0100546 /** Load the contact photos and places them in the corresponding views. */
Daniel Lehmann362654a2011-07-17 14:16:47 -0700547 private void loadContactPhotos(Uri photoUri) {
548 mContactPhotoManager.loadPhoto(mContactBackgroundView, photoUri);
Flavio Lerda9cafe472011-06-08 14:06:13 +0100549 }
550
Flavio Lerda696e8132011-07-05 19:00:23 +0100551 private String getVoicemailNumber() {
552 TelephonyManager telephonyManager =
553 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
554 return telephonyManager.getVoiceMailNumber();
555 }
556
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800557 static final class ViewEntry {
Flavio Lerdaa8956882011-07-09 21:34:38 +0100558 public final String text;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100559 public final Intent primaryIntent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100560 /** The description for accessibility of the primary action. */
561 public final String primaryDescription;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100562
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100563 public CharSequence label = null;
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100564 /** Icon for the secondary action. */
565 public int secondaryIcon = 0;
566 /** Intent for the secondary action. If not null, an icon must be defined. */
567 public Intent secondaryIntent = null;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100568 /** The description for accessibility of the secondary action. */
569 public String secondaryDescription = null;
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700570
Flavio Lerdab184ed62011-08-10 18:17:55 +0100571 public ViewEntry(String text, Intent intent, String description) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800572 this.text = text;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100573 primaryIntent = intent;
574 primaryDescription = description;
Flavio Lerdaa8956882011-07-09 21:34:38 +0100575 }
576
Flavio Lerdab184ed62011-08-10 18:17:55 +0100577 public void setSecondaryAction(int icon, Intent intent, String description) {
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100578 secondaryIcon = icon;
579 secondaryIntent = intent;
Flavio Lerdab184ed62011-08-10 18:17:55 +0100580 secondaryDescription = description;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800581 }
582 }
583
Flavio Lerdab184ed62011-08-10 18:17:55 +0100584 /** Disables the call button area, e.g., for private numbers. */
585 private void disableCallButton() {
586 findViewById(R.id.call_and_sms).setVisibility(View.GONE);
587 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700588
Flavio Lerdab184ed62011-08-10 18:17:55 +0100589 /** Configures the call button area using the given entry. */
590 private void configureCallButton(ViewEntry entry) {
591 View convertView = findViewById(R.id.call_and_sms);
592 convertView.setVisibility(View.VISIBLE);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100593
Flavio Lerdab184ed62011-08-10 18:17:55 +0100594 ImageView icon = (ImageView) convertView.findViewById(R.id.call_and_sms_icon);
595 View divider = convertView.findViewById(R.id.call_and_sms_divider);
Flavio Lerda35be86e2011-08-12 14:13:22 +0100596 TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text);
Flavio Lerda8ebfa3d2011-08-10 14:35:22 +0100597
Flavio Lerdab184ed62011-08-10 18:17:55 +0100598 View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
599 mainAction.setOnClickListener(mPrimaryActionListener);
600 mainAction.setTag(entry);
601 mainAction.setContentDescription(entry.primaryDescription);
602
603 if (entry.secondaryIntent != null) {
604 icon.setOnClickListener(mSecondaryActionListener);
605 icon.setImageResource(entry.secondaryIcon);
606 icon.setVisibility(View.VISIBLE);
607 icon.setTag(entry);
608 icon.setContentDescription(entry.secondaryDescription);
609 divider.setVisibility(View.VISIBLE);
610 } else {
611 icon.setVisibility(View.GONE);
612 divider.setVisibility(View.GONE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800613 }
Flavio Lerdab184ed62011-08-10 18:17:55 +0100614 text.setText(entry.text);
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700615
Flavio Lerda35be86e2011-08-12 14:13:22 +0100616 TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
617 if (TextUtils.isEmpty(entry.label)) {
618 label.setVisibility(View.GONE);
Flavio Lerdab184ed62011-08-10 18:17:55 +0100619 } else {
Flavio Lerda35be86e2011-08-12 14:13:22 +0100620 label.setText(entry.label);
621 label.setVisibility(View.VISIBLE);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800622 }
623 }
Dmitri Plotnikovd0d776d2009-08-19 17:38:04 -0700624
Flavio Lerda9cafe472011-06-08 14:06:13 +0100625 @Override
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800626 public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
627 boolean globalSearch) {
628 if (globalSearch) {
629 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
630 } else {
631 ContactsSearchManager.startSearch(this, initialQuery);
632 }
633 }
Debashish Chatterjee0cb82242011-07-19 19:29:37 +0100634
635 protected void updateVoicemailStatusMessage(Cursor statusCursor) {
636 if (statusCursor == null) {
637 mStatusMessageView.setVisibility(View.GONE);
638 return;
639 }
640 final StatusMessage message = getStatusMessage(statusCursor);
641 if (message == null || !message.showInCallDetails()) {
642 mStatusMessageView.setVisibility(View.GONE);
643 return;
644 }
645
646 mStatusMessageView.setVisibility(View.VISIBLE);
647 mStatusMessageText.setText(message.callDetailsMessageId);
648 if (message.actionMessageId != -1) {
649 mStatusMessageAction.setText(message.actionMessageId);
650 }
651 if (message.actionUri != null) {
652 mStatusMessageAction.setClickable(true);
653 mStatusMessageAction.setOnClickListener(new View.OnClickListener() {
654 @Override
655 public void onClick(View v) {
656 startActivity(new Intent(Intent.ACTION_VIEW, message.actionUri));
657 }
658 });
659 } else {
660 mStatusMessageAction.setClickable(false);
661 }
662 }
663
664 private StatusMessage getStatusMessage(Cursor statusCursor) {
665 List<StatusMessage> messages = mVoicemailStatusHelper.getStatusMessages(statusCursor);
666 Log.d(TAG, "Num status messages: " + messages.size());
667 if (messages.size() == 0) {
668 return null;
669 }
670 // There can only be a single status message per source package, so num of messages can
671 // at most be 1.
672 if (messages.size() > 1) {
673 Log.w(TAG, String.format("Expected 1, found (%d) num of status messages." +
674 " Will use the first one.", messages.size()));
675 }
676 return messages.get(0);
677 }
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100678
679 @Override
680 public boolean onCreateOptionsMenu(Menu menu) {
681 getMenuInflater().inflate(R.menu.call_details_options, menu);
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100682 return super.onCreateOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100683 }
684
685 @Override
686 public boolean onPrepareOptionsMenu(Menu menu) {
687 // This action deletes all elements in the group from the call log.
688 // We don't have this action for voicemails, because you can just use the trash button.
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100689 menu.findItem(R.id.menu_remove_from_call_log).setVisible(!hasVoicemail());
690 menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCall);
691 menu.findItem(R.id.menu_trash).setVisible(hasVoicemail());
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100692 return super.onPrepareOptionsMenu(menu);
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100693 }
694
695 @Override
696 public boolean onMenuItemSelected(int featureId, MenuItem item) {
697 switch (item.getItemId()) {
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100698 case android.R.id.home: {
699 onHomeSelected();
700 return true;
701 }
702
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100703 // All the options menu items are handled by onMenu... methods.
Flavio Lerda94d7bab2011-07-22 16:52:34 +0100704 default:
705 throw new IllegalArgumentException();
706 }
707 }
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100708
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100709 public void onMenuRemoveFromCallLog(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100710 final StringBuilder callIds = new StringBuilder();
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100711 for (Uri callUri : getCallLogEntryUris()) {
712 if (callIds.length() != 0) {
713 callIds.append(",");
714 }
715 callIds.append(ContentUris.parseId(callUri));
716 }
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100717 mAsyncTaskExecutor.submit(Tasks.REMOVE_FROM_CALL_LOG_AND_FINISH,
718 new AsyncTask<Void, Void, Void>() {
719 @Override
720 public Void doInBackground(Void... params) {
721 getContentResolver().delete(Calls.CONTENT_URI_WITH_VOICEMAIL,
722 Calls._ID + " IN (" + callIds + ")", null);
723 return null;
724 }
725
726 @Override
727 public void onPostExecute(Void result) {
728 finish();
729 }
730 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100731 }
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100732
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100733 public void onMenuEditNumberBeforeCall(MenuItem menuItem) {
734 startActivity(new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
735 }
736
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100737 public void onMenuTrashVoicemail(MenuItem menuItem) {
Hugo Hudson5bbe25d2011-08-03 17:16:42 +0100738 final Uri voicemailUri = getVoicemailUri();
Hugo Hudson9c747ac2011-08-17 00:23:01 +0100739 mAsyncTaskExecutor.submit(Tasks.DELETE_VOICEMAIL_AND_FINISH,
740 new AsyncTask<Void, Void, Void>() {
741 @Override
742 public Void doInBackground(Void... params) {
743 getContentResolver().delete(voicemailUri, null, null);
744 return null;
745 }
746 @Override
747 public void onPostExecute(Void result) {
748 finish();
749 }
750 });
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100751 }
752
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100753 private void configureActionBar() {
754 ActionBar actionBar = getActionBar();
755 if (actionBar != null) {
Hugo Hudsonc2f09c32011-07-30 16:31:28 +0100756 actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
Flavio Lerdad44e83a2011-07-24 23:10:17 +0100757 }
758 }
759
760 /** Invoked when the user presses the home button in the action bar. */
761 private void onHomeSelected() {
762 Intent intent = new Intent(Intent.ACTION_VIEW, Calls.CONTENT_URI);
763 // This will open the call log even if the detail view has been opened directly.
764 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
765 startActivity(intent);
766 finish();
767 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800768}