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