blob: 71aa26d1570d3965ab958048c15208ecf039f75a [file] [log] [blame]
Chiao Cheng94b10b52012-08-17 16:59:12 -07001/*
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
17package com.android.dialer;
18
Brandon Maxwell36aeec92015-10-23 12:01:00 -070019import com.android.contacts.common.preference.ContactsPreferences;
Andrew Lee49efd912015-05-19 12:17:26 -070020import com.android.dialer.calllog.PhoneNumberDisplayUtil;
Yorke Lee8cd94232014-07-23 14:05:31 -070021
Andrew Lee49efd912015-05-19 12:17:26 -070022import android.content.Context;
Chiao Cheng94b10b52012-08-17 16:59:12 -070023import android.net.Uri;
24import android.provider.CallLog.Calls;
Nancy Chene80d6222014-10-08 20:17:55 -070025import android.telecom.PhoneAccountHandle;
Brandon Maxwell36aeec92015-10-23 12:01:00 -070026import android.text.TextUtils;
Chiao Cheng94b10b52012-08-17 16:59:12 -070027
28/**
29 * The details of a phone call to be shown in the UI.
30 */
31public class PhoneCallDetails {
Andrew Leeedb22da2015-06-09 18:22:14 -070032 // The number of the other party involved in the call.
33 public CharSequence number;
Hall Liu35e44d42015-10-14 15:19:06 -070034 // Post-dial digits associated with the outgoing call.
35 public String postDialDigits;
Andrew Leeedb22da2015-06-09 18:22:14 -070036 // 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 Cheng94b10b52012-08-17 16:59:12 -070045 /**
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 Leeedb22da2015-06-09 18:22:14 -070050 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 Maxwell36aeec92015-10-23 12:01:00 -070057 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 Leeedb22da2015-06-09 18:22:14 -070065 // 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 Lee2f05af32015-06-09 15:59:47 -070071
Chiao Cheng94b10b52012-08-17 16:59:12 -070072 /**
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 Leeedb22da2015-06-09 18:22:14 -070078 public Uri photoUri;
79
80 // The source type of the contact associated with this call.
81 public int sourceType;
82
Andrew Lee2f05af32015-06-09 15:59:47 -070083 // The object id type of the contact associated with this call.
84 public String objectId;
85
Andrew Leeedb22da2015-06-09 18:22:14 -070086 // 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 Chen03aaf382015-06-11 20:06:26 -070098 // The display string for the number.
Andrew Leeedb22da2015-06-09 18:22:14 -070099 public String displayNumber;
Nancy Chen03aaf382015-06-11 20:06:26 -0700100
101 // Whether the contact number is a voicemail number.
Andrew Leeedb22da2015-06-09 18:22:14 -0700102 public boolean isVoicemail;
Nancy Chene80d6222014-10-08 20:17:55 -0700103
Nancy Chen87ba4892014-06-11 17:56:07 -0700104 /**
Nancy Chen03aaf382015-06-11 20:06:26 -0700105 * 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 Leeedb22da2015-06-09 18:22:14 -0700111 * Constructor with required fields for the details of a call with a number associated with a
112 * contact.
Nancy Chen19702632014-07-25 13:23:16 -0700113 */
Andrew Leeedb22da2015-06-09 18:22:14 -0700114 public PhoneCallDetails(
115 Context context,
116 CharSequence number,
117 int numberPresentation,
118 CharSequence formattedNumber,
Hall Liu35e44d42015-10-14 15:19:06 -0700119 CharSequence postDialDigits,
Andrew Lee49efd912015-05-19 12:17:26 -0700120 boolean isVoicemail) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700121 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700122 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700123 this.formattedNumber = formattedNumber;
Andrew Lee49efd912015-05-19 12:17:26 -0700124 this.isVoicemail = isVoicemail;
Hall Liu35e44d42015-10-14 15:19:06 -0700125 this.postDialDigits = postDialDigits.toString();
Andrew Lee49efd912015-05-19 12:17:26 -0700126 this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
127 context,
Andrew Lee49efd912015-05-19 12:17:26 -0700128 this.number,
129 this.numberPresentation,
130 this.formattedNumber,
Hall Liu35e44d42015-10-14 15:19:06 -0700131 this.postDialDigits,
Andrew Lee49efd912015-05-19 12:17:26 -0700132 this.isVoicemail).toString();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700133 }
Brandon Maxwell36aeec92015-10-23 12:01:00 -0700134
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 Cheng94b10b52012-08-17 16:59:12 -0700148}