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