Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.dialer; |
| 18 | |
Brian Attwell | beab3bb | 2014-10-27 12:24:49 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 20 | import android.content.ContentResolver; |
| 21 | import android.content.ContentUris; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.content.res.Resources; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 25 | import android.net.Uri; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 26 | import android.os.Bundle; |
Yorke Lee | 7151398 | 2015-02-25 20:23:53 -0800 | [diff] [blame] | 27 | import android.os.PowerManager; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 28 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 29 | import android.provider.VoicemailContract.Voicemails; |
Tyler Gunn | 9dc924c | 2014-09-12 09:33:50 -0700 | [diff] [blame] | 30 | import android.telecom.PhoneAccount; |
Nancy Chen | e80d622 | 2014-10-08 20:17:55 -0700 | [diff] [blame] | 31 | import android.telecom.PhoneAccountHandle; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 32 | import android.telephony.TelephonyManager; |
Andrew Lee | 99e8adb | 2014-10-02 12:27:37 -0700 | [diff] [blame] | 33 | import android.text.BidiFormatter; |
| 34 | import android.text.TextDirectionHeuristics; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 35 | import android.text.TextUtils; |
| 36 | import android.util.Log; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 37 | import android.view.KeyEvent; |
| 38 | import android.view.LayoutInflater; |
| 39 | import android.view.Menu; |
| 40 | import android.view.MenuItem; |
| 41 | import android.view.View; |
Yorke Lee | 257b6f2 | 2014-07-31 14:16:44 -0700 | [diff] [blame] | 42 | import android.widget.LinearLayout; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 43 | import android.widget.ListView; |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 44 | import android.widget.QuickContactBadge; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 45 | import android.widget.TextView; |
| 46 | import android.widget.Toast; |
| 47 | |
Chiao Cheng | 35071c0 | 2012-10-15 18:36:24 -0700 | [diff] [blame] | 48 | import com.android.contacts.common.ContactPhotoManager; |
Yorke Lee | 56cb0ef | 2014-02-21 10:02:18 -0800 | [diff] [blame] | 49 | import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; |
Chiao Cheng | 35071c0 | 2012-10-15 18:36:24 -0700 | [diff] [blame] | 50 | import com.android.contacts.common.GeoUtil; |
Brian Attwell | 8204324 | 2015-02-03 14:13:58 -0800 | [diff] [blame] | 51 | import com.android.contacts.common.CallUtil; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 52 | import com.android.dialer.calllog.CallDetailHistoryAdapter; |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 53 | import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener; |
| 54 | import com.android.dialer.calllog.CallLogAsyncTaskUtil; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 55 | import com.android.dialer.calllog.CallTypeHelper; |
| 56 | import com.android.dialer.calllog.ContactInfo; |
| 57 | import com.android.dialer.calllog.ContactInfoHelper; |
Nancy Chen | b2eebaf | 2014-07-21 13:41:36 -0700 | [diff] [blame] | 58 | import com.android.dialer.calllog.PhoneAccountUtils; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 59 | import com.android.dialer.calllog.PhoneNumberDisplayUtil; |
Chiao Cheng | fb0a934 | 2013-09-13 17:27:42 -0700 | [diff] [blame] | 60 | import com.android.dialer.calllog.PhoneNumberUtilsWrapper; |
Andrew Lee | 247df6e | 2015-05-12 19:09:00 -0700 | [diff] [blame] | 61 | import com.android.dialer.util.IntentUtil; |
Yorke Lee | 3921359 | 2014-04-07 15:39:48 -0700 | [diff] [blame] | 62 | import com.android.dialer.util.DialerUtils; |
Yorke Lee | 4aece95 | 2015-05-02 22:22:54 -0700 | [diff] [blame] | 63 | import com.android.dialer.util.TelecomUtil; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 64 | |
| 65 | import java.util.List; |
| 66 | |
| 67 | /** |
| 68 | * Displays the details of a specific call log entry. |
| 69 | * <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. |
| 72 | */ |
Andrew Lee | 93b816f | 2015-05-13 12:23:35 -0700 | [diff] [blame] | 73 | public class CallDetailActivity extends Activity { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 74 | private static final String TAG = "CallDetail"; |
| 75 | |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 76 | /** A long array extra containing ids of call log entries to display. */ |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 77 | 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"; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 80 | /** If the activity was triggered from a notification. */ |
| 81 | public static final String EXTRA_FROM_NOTIFICATION = "EXTRA_FROM_NOTIFICATION"; |
| 82 | |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 83 | public static final String VOICEMAIL_FRAGMENT_TAG = "voicemail_fragment"; |
| 84 | |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 85 | private CallLogAsyncTaskListener mCallLogAsyncTaskListener = new CallLogAsyncTaskListener() { |
| 86 | @Override |
| 87 | public void onDeleteCall() { |
| 88 | finish(); |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public void onDeleteVoicemail() { |
| 93 | finish(); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public void onGetCallDetails(PhoneCallDetails[] details) { |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 98 | if (details == null) { |
| 99 | // Somewhere went wrong: we're going to bail out and show error to users. |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 100 | Toast.makeText(mContext, R.string.toast_call_detail_error, |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 101 | Toast.LENGTH_SHORT).show(); |
| 102 | finish(); |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | // We know that all calls are from the same number and the same contact, so pick the |
| 107 | // first. |
| 108 | PhoneCallDetails firstDetails = details[0]; |
| 109 | mNumber = TextUtils.isEmpty(firstDetails.number) ? |
| 110 | null : firstDetails.number.toString(); |
| 111 | final int numberPresentation = firstDetails.numberPresentation; |
| 112 | final Uri contactUri = firstDetails.contactUri; |
| 113 | final Uri photoUri = firstDetails.photoUri; |
| 114 | final PhoneAccountHandle accountHandle = firstDetails.accountHandle; |
| 115 | |
| 116 | // Cache the details about the phone number. |
| 117 | final boolean canPlaceCallsTo = |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 118 | PhoneNumberUtilsWrapper.canPlaceCallsTo(mNumber, numberPresentation); |
| 119 | final PhoneNumberUtilsWrapper phoneUtils = new PhoneNumberUtilsWrapper(mContext); |
| 120 | mIsVoicemailNumber = |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 121 | phoneUtils.isVoicemailNumber(accountHandle, mNumber); |
| 122 | final boolean isSipNumber = PhoneNumberUtilsWrapper.isSipNumber(mNumber); |
| 123 | |
| 124 | final CharSequence callLocationOrType = getNumberTypeOrLocation(firstDetails); |
| 125 | |
| 126 | final CharSequence displayNumber = firstDetails.displayNumber; |
| 127 | final String displayNumberStr = mBidiFormatter.unicodeWrap( |
| 128 | displayNumber.toString(), TextDirectionHeuristics.LTR); |
| 129 | |
| 130 | if (!TextUtils.isEmpty(firstDetails.name)) { |
| 131 | mCallerName.setText(firstDetails.name); |
| 132 | mCallerNumber.setText(callLocationOrType + " " + displayNumberStr); |
| 133 | } else { |
| 134 | mCallerName.setText(displayNumberStr); |
| 135 | if (!TextUtils.isEmpty(callLocationOrType)) { |
| 136 | mCallerNumber.setText(callLocationOrType); |
| 137 | mCallerNumber.setVisibility(View.VISIBLE); |
| 138 | } else { |
| 139 | mCallerNumber.setVisibility(View.GONE); |
| 140 | } |
| 141 | } |
| 142 | |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 143 | mCallButton.setVisibility(canPlaceCallsTo ? View.VISIBLE : View.GONE); |
| 144 | |
| 145 | String accountLabel = PhoneAccountUtils.getAccountLabel(mContext, accountHandle); |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 146 | if (!TextUtils.isEmpty(accountLabel)) { |
| 147 | mAccountLabel.setText(accountLabel); |
| 148 | mAccountLabel.setVisibility(View.VISIBLE); |
| 149 | } else { |
| 150 | mAccountLabel.setVisibility(View.GONE); |
| 151 | } |
| 152 | |
| 153 | mHasEditNumberBeforeCallOption = |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 154 | canPlaceCallsTo && !isSipNumber && !mIsVoicemailNumber; |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 155 | mHasTrashOption = hasVoicemail(); |
| 156 | mHasRemoveFromCallLogOption = !hasVoicemail(); |
| 157 | invalidateOptionsMenu(); |
| 158 | |
| 159 | ListView historyList = (ListView) findViewById(R.id.history); |
| 160 | historyList.setAdapter( |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 161 | new CallDetailHistoryAdapter(mContext, mInflater, mCallTypeHelper, details)); |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 162 | |
| 163 | String lookupKey = contactUri == null ? null |
| 164 | : ContactInfoHelper.getLookupKeyFromUri(contactUri); |
| 165 | |
| 166 | final boolean isBusiness = mContactInfoHelper.isBusiness(firstDetails.sourceType); |
| 167 | |
| 168 | final int contactType = |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 169 | mIsVoicemailNumber ? ContactPhotoManager.TYPE_VOICEMAIL : |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 170 | isBusiness ? ContactPhotoManager.TYPE_BUSINESS : |
| 171 | ContactPhotoManager.TYPE_DEFAULT; |
| 172 | |
| 173 | String nameForDefaultImage; |
| 174 | if (TextUtils.isEmpty(firstDetails.name)) { |
| 175 | nameForDefaultImage = firstDetails.displayNumber; |
| 176 | } else { |
| 177 | nameForDefaultImage = firstDetails.name.toString(); |
| 178 | } |
| 179 | |
| 180 | loadContactPhotos( |
| 181 | contactUri, photoUri, nameForDefaultImage, lookupKey, contactType); |
| 182 | findViewById(R.id.call_detail).setVisibility(View.VISIBLE); |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Determines the location geocode text for a call, or the phone number type |
| 187 | * (if available). |
| 188 | * |
| 189 | * @param details The call details. |
| 190 | * @return The phone number type or location. |
| 191 | */ |
| 192 | private CharSequence getNumberTypeOrLocation(PhoneCallDetails details) { |
| 193 | if (!TextUtils.isEmpty(details.name)) { |
| 194 | return Phone.getTypeLabel(mResources, details.numberType, |
| 195 | details.numberLabel); |
| 196 | } else { |
| 197 | return details.geocode; |
| 198 | } |
| 199 | } |
| 200 | }; |
| 201 | |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 202 | private Context mContext; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 203 | private CallTypeHelper mCallTypeHelper; |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 204 | private QuickContactBadge mQuickContactBadge; |
| 205 | private TextView mCallerName; |
| 206 | private TextView mCallerNumber; |
Nancy Chen | 1970263 | 2014-07-25 13:23:16 -0700 | [diff] [blame] | 207 | private TextView mAccountLabel; |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 208 | private View mCallButton; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 209 | private ContactInfoHelper mContactInfoHelper; |
| 210 | |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 211 | private String mNumber; |
| 212 | private boolean mIsVoicemailNumber; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 213 | private String mDefaultCountryIso; |
| 214 | |
| 215 | /* package */ LayoutInflater mInflater; |
| 216 | /* package */ Resources mResources; |
| 217 | /** Helper to load contact photos. */ |
| 218 | private ContactPhotoManager mContactPhotoManager; |
Andrew Lee | c1167e9 | 2015-05-18 11:27:54 -0700 | [diff] [blame] | 219 | |
Yorke Lee | 257b6f2 | 2014-07-31 14:16:44 -0700 | [diff] [blame] | 220 | private Uri mVoicemailUri; |
Andrew Lee | 99e8adb | 2014-10-02 12:27:37 -0700 | [diff] [blame] | 221 | private BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 222 | |
| 223 | /** Whether we should show "edit number before call" in the options menu. */ |
| 224 | private boolean mHasEditNumberBeforeCallOption; |
| 225 | /** Whether we should show "trash" in the options menu. */ |
| 226 | private boolean mHasTrashOption; |
| 227 | /** Whether we should show "remove from call log" in the options menu. */ |
| 228 | private boolean mHasRemoveFromCallLogOption; |
| 229 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 230 | @Override |
| 231 | protected void onCreate(Bundle icicle) { |
| 232 | super.onCreate(icicle); |
| 233 | |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 234 | mContext = this; |
| 235 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 236 | setContentView(R.layout.call_detail); |
| 237 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 238 | mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); |
| 239 | mResources = getResources(); |
| 240 | |
| 241 | mCallTypeHelper = new CallTypeHelper(getResources()); |
Yorke Lee | 257b6f2 | 2014-07-31 14:16:44 -0700 | [diff] [blame] | 242 | |
| 243 | mVoicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI); |
| 244 | |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 245 | mQuickContactBadge = (QuickContactBadge) findViewById(R.id.quick_contact_photo); |
| 246 | mQuickContactBadge.setOverlay(null); |
Brian Attwell | 74eb4ec | 2015-02-25 22:31:22 -0800 | [diff] [blame] | 247 | mQuickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 248 | mCallerName = (TextView) findViewById(R.id.caller_name); |
| 249 | mCallerNumber = (TextView) findViewById(R.id.caller_number); |
Nancy Chen | 1970263 | 2014-07-25 13:23:16 -0700 | [diff] [blame] | 250 | mAccountLabel = (TextView) findViewById(R.id.phone_account_label); |
Chiao Cheng | 35071c0 | 2012-10-15 18:36:24 -0700 | [diff] [blame] | 251 | mDefaultCountryIso = GeoUtil.getCurrentCountryIso(this); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 252 | mContactPhotoManager = ContactPhotoManager.getInstance(this); |
Yorke Lee | 7151398 | 2015-02-25 20:23:53 -0800 | [diff] [blame] | 253 | |
Andrew Lee | e177fe6 | 2015-06-05 13:01:09 -0700 | [diff] [blame] | 254 | mCallButton = (View) findViewById(R.id.call_back_button); |
| 255 | mCallButton.setOnClickListener(new View.OnClickListener() { |
| 256 | @Override |
| 257 | public void onClick(View view) { |
| 258 | mContext.startActivity(IntentUtil.getCallIntent(mNumber)); |
| 259 | } |
| 260 | }); |
| 261 | |
Chiao Cheng | 35071c0 | 2012-10-15 18:36:24 -0700 | [diff] [blame] | 262 | mContactInfoHelper = new ContactInfoHelper(this, GeoUtil.getCurrentCountryIso(this)); |
Chiao Cheng | adb742c | 2013-10-07 17:46:25 -0700 | [diff] [blame] | 263 | getActionBar().setDisplayHomeAsUpEnabled(true); |
Yorke Lee | 257b6f2 | 2014-07-31 14:16:44 -0700 | [diff] [blame] | 264 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 265 | if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) { |
| 266 | closeSystemDialogs(); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public void onResume() { |
| 272 | super.onResume(); |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 273 | |
| 274 | CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 277 | private boolean hasVoicemail() { |
Yorke Lee | 257b6f2 | 2014-07-31 14:16:44 -0700 | [diff] [blame] | 278 | return mVoicemailUri != null; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 281 | /** |
| 282 | * Returns the list of URIs to show. |
| 283 | * <p> |
| 284 | * There are two ways the URIs can be provided to the activity: as the data on the intent, or as |
| 285 | * a list of ids in the call log added as an extra on the URI. |
| 286 | * <p> |
| 287 | * If both are available, the data on the intent takes precedence. |
| 288 | */ |
| 289 | private Uri[] getCallLogEntryUris() { |
Jay Shrauner | 757bdd3 | 2014-05-28 10:13:40 -0700 | [diff] [blame] | 290 | final Uri uri = getIntent().getData(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 291 | if (uri != null) { |
| 292 | // If there is a data on the intent, it takes precedence over the extra. |
| 293 | return new Uri[]{ uri }; |
| 294 | } |
Jay Shrauner | 757bdd3 | 2014-05-28 10:13:40 -0700 | [diff] [blame] | 295 | final long[] ids = getIntent().getLongArrayExtra(EXTRA_CALL_LOG_IDS); |
| 296 | final int numIds = ids == null ? 0 : ids.length; |
| 297 | final Uri[] uris = new Uri[numIds]; |
| 298 | for (int index = 0; index < numIds; ++index) { |
Yorke Lee | 4aece95 | 2015-05-02 22:22:54 -0700 | [diff] [blame] | 299 | uris[index] = ContentUris.withAppendedId( |
| 300 | TelecomUtil.getCallLogUri(CallDetailActivity.this), ids[index]); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 301 | } |
| 302 | return uris; |
| 303 | } |
| 304 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 305 | /** Load the contact photos and places them in the corresponding views. */ |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 306 | private void loadContactPhotos(Uri contactUri, Uri photoUri, String displayName, |
| 307 | String lookupKey, int contactType) { |
| 308 | |
Yorke Lee | 56cb0ef | 2014-02-21 10:02:18 -0800 | [diff] [blame] | 309 | final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey, |
Tyler Gunn | 18164c8 | 2014-06-09 10:20:57 -0700 | [diff] [blame] | 310 | contactType, true /* isCircular */); |
| 311 | |
| 312 | mQuickContactBadge.assignContactUri(contactUri); |
| 313 | mQuickContactBadge.setContentDescription( |
| 314 | mResources.getString(R.string.description_contact_details, displayName)); |
| 315 | |
| 316 | mContactPhotoManager.loadDirectoryPhoto(mQuickContactBadge, photoUri, |
| 317 | false /* darkTheme */, true /* isCircular */, request); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 320 | @Override |
| 321 | public boolean onCreateOptionsMenu(Menu menu) { |
| 322 | getMenuInflater().inflate(R.menu.call_details_options, menu); |
| 323 | return super.onCreateOptionsMenu(menu); |
| 324 | } |
| 325 | |
| 326 | @Override |
| 327 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 328 | // This action deletes all elements in the group from the call log. |
| 329 | // We don't have this action for voicemails, because you can just use the trash button. |
| 330 | menu.findItem(R.id.menu_remove_from_call_log).setVisible(mHasRemoveFromCallLogOption); |
| 331 | menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCallOption); |
| 332 | menu.findItem(R.id.menu_trash).setVisible(mHasTrashOption); |
| 333 | return super.onPrepareOptionsMenu(menu); |
| 334 | } |
| 335 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 336 | public void onMenuRemoveFromCallLog(MenuItem menuItem) { |
| 337 | final StringBuilder callIds = new StringBuilder(); |
| 338 | for (Uri callUri : getCallLogEntryUris()) { |
| 339 | if (callIds.length() != 0) { |
| 340 | callIds.append(","); |
| 341 | } |
| 342 | callIds.append(ContentUris.parseId(callUri)); |
| 343 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 344 | |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 345 | CallLogAsyncTaskUtil.deleteCalls(this, callIds.toString(), mCallLogAsyncTaskListener); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | public void onMenuEditNumberBeforeCall(MenuItem menuItem) { |
Chiao Cheng | 9d4f3b2 | 2012-09-05 16:00:16 -0700 | [diff] [blame] | 349 | startActivity(new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber))); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | public void onMenuTrashVoicemail(MenuItem menuItem) { |
Andrew Lee | 7c461dc | 2015-05-15 10:18:45 -0700 | [diff] [blame] | 353 | CallLogAsyncTaskUtil.deleteVoicemail(this, mVoicemailUri, mCallLogAsyncTaskListener); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 356 | private void closeSystemDialogs() { |
| 357 | sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); |
| 358 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 359 | } |