Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 19 | import com.android.dialer.calllog.PhoneNumberDisplayUtil; |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 20 | |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Nancy Chen | 87ba489 | 2014-06-11 17:56:07 -0700 | [diff] [blame] | 22 | import android.graphics.drawable.Drawable; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
| 24 | import android.provider.CallLog.Calls; |
| 25 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
Nancy Chen | e80d622 | 2014-10-08 20:17:55 -0700 | [diff] [blame] | 26 | import android.telecom.PhoneAccountHandle; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 27 | import android.text.TextUtils; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * The details of a phone call to be shown in the UI. |
| 31 | */ |
| 32 | public class PhoneCallDetails { |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 33 | // The number of the other party involved in the call. |
| 34 | public CharSequence number; |
| 35 | // The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} |
| 36 | public int numberPresentation; |
| 37 | // The formatted version of {@link #number}. |
| 38 | public CharSequence formattedNumber; |
| 39 | // The country corresponding with the phone number. |
| 40 | public String countryIso; |
| 41 | // The geocoded location for the phone number. |
| 42 | public String geocode; |
| 43 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 44 | /** |
| 45 | * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}. |
| 46 | * <p> |
| 47 | * There might be multiple types if this represents a set of entries grouped together. |
| 48 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 49 | public int[] callTypes; |
| 50 | |
| 51 | // The date of the call, in milliseconds since the epoch. |
| 52 | public long date; |
| 53 | // The duration of the call in milliseconds, or 0 for missed calls. |
| 54 | public long duration; |
| 55 | // The name of the contact, or the empty string. |
| 56 | public CharSequence name; |
| 57 | // The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available. |
| 58 | public int numberType; |
| 59 | // The custom label associated with the phone number in the contact, or the empty string. |
| 60 | public CharSequence numberLabel; |
| 61 | // The URI of the contact associated with this phone call. |
| 62 | public Uri contactUri; |
Andrew Lee | 2f05af3 | 2015-06-09 15:59:47 -0700 | [diff] [blame^] | 63 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 64 | /** |
| 65 | * The photo URI of the picture of the contact that is associated with this phone call or |
| 66 | * null if there is none. |
| 67 | * <p> |
| 68 | * This is meant to store the high-res photo only. |
| 69 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 70 | public Uri photoUri; |
| 71 | |
| 72 | // The source type of the contact associated with this call. |
| 73 | public int sourceType; |
| 74 | |
Andrew Lee | 2f05af3 | 2015-06-09 15:59:47 -0700 | [diff] [blame^] | 75 | // The object id type of the contact associated with this call. |
| 76 | public String objectId; |
| 77 | |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 78 | // The unique identifier for the account associated with the call. |
| 79 | public PhoneAccountHandle accountHandle; |
| 80 | |
| 81 | // Features applicable to this call. |
| 82 | public int features; |
| 83 | |
| 84 | // Total data usage for this call. |
| 85 | public Long dataUsage; |
| 86 | |
| 87 | // Voicemail transcription |
| 88 | public String transcription; |
| 89 | |
| 90 | public String displayNumber; |
| 91 | public boolean isVoicemail; |
Nancy Chen | e80d622 | 2014-10-08 20:17:55 -0700 | [diff] [blame] | 92 | |
Nancy Chen | 87ba489 | 2014-06-11 17:56:07 -0700 | [diff] [blame] | 93 | /** |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 94 | * Constructor with required fields for the details of a call with a number associated with a |
| 95 | * contact. |
Nancy Chen | 1970263 | 2014-07-25 13:23:16 -0700 | [diff] [blame] | 96 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 97 | public PhoneCallDetails( |
| 98 | Context context, |
| 99 | CharSequence number, |
| 100 | int numberPresentation, |
| 101 | CharSequence formattedNumber, |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 102 | boolean isVoicemail) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 103 | this.number = number; |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 104 | this.numberPresentation = numberPresentation; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 105 | this.formattedNumber = formattedNumber; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 106 | this.isVoicemail = isVoicemail; |
| 107 | |
| 108 | this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber( |
| 109 | context, |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 110 | this.number, |
| 111 | this.numberPresentation, |
| 112 | this.formattedNumber, |
| 113 | this.isVoicemail).toString(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 114 | } |
| 115 | } |