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 | |
Brandon Maxwell | 36aeec9 | 2015-10-23 12:01:00 -0700 | [diff] [blame^] | 19 | import com.android.contacts.common.preference.ContactsPreferences; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 20 | import com.android.dialer.calllog.PhoneNumberDisplayUtil; |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 21 | |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 22 | import android.content.Context; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
| 24 | import android.provider.CallLog.Calls; |
Nancy Chen | e80d622 | 2014-10-08 20:17:55 -0700 | [diff] [blame] | 25 | import android.telecom.PhoneAccountHandle; |
Brandon Maxwell | 36aeec9 | 2015-10-23 12:01:00 -0700 | [diff] [blame^] | 26 | import android.text.TextUtils; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * The details of a phone call to be shown in the UI. |
| 30 | */ |
| 31 | public class PhoneCallDetails { |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 32 | // The number of the other party involved in the call. |
| 33 | public CharSequence number; |
| 34 | // The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} |
| 35 | public int numberPresentation; |
| 36 | // The formatted version of {@link #number}. |
| 37 | public CharSequence formattedNumber; |
| 38 | // The country corresponding with the phone number. |
| 39 | public String countryIso; |
| 40 | // The geocoded location for the phone number. |
| 41 | public String geocode; |
| 42 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 43 | /** |
| 44 | * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}. |
| 45 | * <p> |
| 46 | * There might be multiple types if this represents a set of entries grouped together. |
| 47 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 48 | public int[] callTypes; |
| 49 | |
| 50 | // The date of the call, in milliseconds since the epoch. |
| 51 | public long date; |
| 52 | // The duration of the call in milliseconds, or 0 for missed calls. |
| 53 | public long duration; |
| 54 | // The name of the contact, or the empty string. |
Brandon Maxwell | 36aeec9 | 2015-10-23 12:01:00 -0700 | [diff] [blame^] | 55 | public CharSequence namePrimary; |
| 56 | // The alternative name of the contact, e.g. last name first, or the empty string |
| 57 | public CharSequence nameAlternative; |
| 58 | /** |
| 59 | * The user's preference on name display order, last name first or first time first. |
| 60 | * {@see ContactsPreferences} |
| 61 | */ |
| 62 | public int nameDisplayOrder; |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 63 | // The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available. |
| 64 | public int numberType; |
| 65 | // The custom label associated with the phone number in the contact, or the empty string. |
| 66 | public CharSequence numberLabel; |
| 67 | // The URI of the contact associated with this phone call. |
| 68 | public Uri contactUri; |
Andrew Lee | 2f05af3 | 2015-06-09 15:59:47 -0700 | [diff] [blame] | 69 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 70 | /** |
| 71 | * The photo URI of the picture of the contact that is associated with this phone call or |
| 72 | * null if there is none. |
| 73 | * <p> |
| 74 | * This is meant to store the high-res photo only. |
| 75 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 76 | public Uri photoUri; |
| 77 | |
| 78 | // The source type of the contact associated with this call. |
| 79 | public int sourceType; |
| 80 | |
Andrew Lee | 2f05af3 | 2015-06-09 15:59:47 -0700 | [diff] [blame] | 81 | // The object id type of the contact associated with this call. |
| 82 | public String objectId; |
| 83 | |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 84 | // The unique identifier for the account associated with the call. |
| 85 | public PhoneAccountHandle accountHandle; |
| 86 | |
| 87 | // Features applicable to this call. |
| 88 | public int features; |
| 89 | |
| 90 | // Total data usage for this call. |
| 91 | public Long dataUsage; |
| 92 | |
| 93 | // Voicemail transcription |
| 94 | public String transcription; |
| 95 | |
Nancy Chen | 03aaf38 | 2015-06-11 20:06:26 -0700 | [diff] [blame] | 96 | // The display string for the number. |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 97 | public String displayNumber; |
Nancy Chen | 03aaf38 | 2015-06-11 20:06:26 -0700 | [diff] [blame] | 98 | |
| 99 | // Whether the contact number is a voicemail number. |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 100 | public boolean isVoicemail; |
Nancy Chen | e80d622 | 2014-10-08 20:17:55 -0700 | [diff] [blame] | 101 | |
Nancy Chen | 87ba489 | 2014-06-11 17:56:07 -0700 | [diff] [blame] | 102 | /** |
Nancy Chen | 03aaf38 | 2015-06-11 20:06:26 -0700 | [diff] [blame] | 103 | * If this is a voicemail, whether the message is read. For other types of calls, this defaults |
| 104 | * to {@code true}. |
| 105 | */ |
| 106 | public boolean isRead = true; |
| 107 | |
| 108 | /** |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 109 | * Constructor with required fields for the details of a call with a number associated with a |
| 110 | * contact. |
Nancy Chen | 1970263 | 2014-07-25 13:23:16 -0700 | [diff] [blame] | 111 | */ |
Andrew Lee | edb22da | 2015-06-09 18:22:14 -0700 | [diff] [blame] | 112 | public PhoneCallDetails( |
| 113 | Context context, |
| 114 | CharSequence number, |
| 115 | int numberPresentation, |
| 116 | CharSequence formattedNumber, |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 117 | boolean isVoicemail) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 118 | this.number = number; |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 119 | this.numberPresentation = numberPresentation; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 120 | this.formattedNumber = formattedNumber; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 121 | this.isVoicemail = isVoicemail; |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 122 | this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber( |
| 123 | context, |
Andrew Lee | 49efd91 | 2015-05-19 12:17:26 -0700 | [diff] [blame] | 124 | this.number, |
| 125 | this.numberPresentation, |
| 126 | this.formattedNumber, |
| 127 | this.isVoicemail).toString(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 128 | } |
Brandon Maxwell | 36aeec9 | 2015-10-23 12:01:00 -0700 | [diff] [blame^] | 129 | |
| 130 | /** |
| 131 | * Returns the preferred name for the call details as specified by the |
| 132 | * {@link #nameDisplayOrder} |
| 133 | * |
| 134 | * @return the preferred name |
| 135 | */ |
| 136 | public CharSequence getPreferredName() { |
| 137 | if (nameDisplayOrder == ContactsPreferences.DISPLAY_ORDER_PRIMARY |
| 138 | || TextUtils.isEmpty(nameAlternative)) { |
| 139 | return namePrimary; |
| 140 | } |
| 141 | return nameAlternative; |
| 142 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 143 | } |