blob: b332b43cc7b9cf0e035310ce6bfd193677065644 [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
Victor Chang240523d2015-12-17 09:14:15 +000019import com.android.contacts.common.ContactsUtils.UserType;
Brandon Maxwell36aeec92015-10-23 12:01:00 -070020import com.android.contacts.common.preference.ContactsPreferences;
Andrew Lee49efd912015-05-19 12:17:26 -070021import com.android.dialer.calllog.PhoneNumberDisplayUtil;
Yorke Lee8cd94232014-07-23 14:05:31 -070022
Andrew Lee49efd912015-05-19 12:17:26 -070023import android.content.Context;
Chiao Cheng94b10b52012-08-17 16:59:12 -070024import android.net.Uri;
25import android.provider.CallLog.Calls;
Nancy Chene80d6222014-10-08 20:17:55 -070026import android.telecom.PhoneAccountHandle;
Brandon Maxwell36aeec92015-10-23 12:01:00 -070027import android.text.TextUtils;
Chiao Cheng94b10b52012-08-17 16:59:12 -070028
29/**
30 * The details of a phone call to be shown in the UI.
31 */
32public class PhoneCallDetails {
Andrew Leeedb22da2015-06-09 18:22:14 -070033 // The number of the other party involved in the call.
34 public CharSequence number;
Hall Liu35e44d42015-10-14 15:19:06 -070035 // Post-dial digits associated with the outgoing call.
36 public String postDialDigits;
Andrew Leeedb22da2015-06-09 18:22:14 -070037 // The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED}
38 public int numberPresentation;
39 // The formatted version of {@link #number}.
40 public CharSequence formattedNumber;
41 // The country corresponding with the phone number.
42 public String countryIso;
43 // The geocoded location for the phone number.
44 public String geocode;
45
Chiao Cheng94b10b52012-08-17 16:59:12 -070046 /**
47 * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
48 * <p>
49 * There might be multiple types if this represents a set of entries grouped together.
50 */
Andrew Leeedb22da2015-06-09 18:22:14 -070051 public int[] callTypes;
52
53 // The date of the call, in milliseconds since the epoch.
54 public long date;
55 // The duration of the call in milliseconds, or 0 for missed calls.
56 public long duration;
57 // The name of the contact, or the empty string.
Brandon Maxwell36aeec92015-10-23 12:01:00 -070058 public CharSequence namePrimary;
59 // The alternative name of the contact, e.g. last name first, or the empty string
60 public CharSequence nameAlternative;
61 /**
62 * The user's preference on name display order, last name first or first time first.
63 * {@see ContactsPreferences}
64 */
65 public int nameDisplayOrder;
Andrew Leeedb22da2015-06-09 18:22:14 -070066 // The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available.
67 public int numberType;
68 // The custom label associated with the phone number in the contact, or the empty string.
69 public CharSequence numberLabel;
70 // The URI of the contact associated with this phone call.
71 public Uri contactUri;
Andrew Lee2f05af32015-06-09 15:59:47 -070072
Chiao Cheng94b10b52012-08-17 16:59:12 -070073 /**
74 * The photo URI of the picture of the contact that is associated with this phone call or
75 * null if there is none.
76 * <p>
77 * This is meant to store the high-res photo only.
78 */
Andrew Leeedb22da2015-06-09 18:22:14 -070079 public Uri photoUri;
80
81 // The source type of the contact associated with this call.
82 public int sourceType;
83
Andrew Lee2f05af32015-06-09 15:59:47 -070084 // The object id type of the contact associated with this call.
85 public String objectId;
86
Andrew Leeedb22da2015-06-09 18:22:14 -070087 // The unique identifier for the account associated with the call.
88 public PhoneAccountHandle accountHandle;
89
90 // Features applicable to this call.
91 public int features;
92
93 // Total data usage for this call.
94 public Long dataUsage;
95
96 // Voicemail transcription
97 public String transcription;
98
Nancy Chen03aaf382015-06-11 20:06:26 -070099 // The display string for the number.
Andrew Leeedb22da2015-06-09 18:22:14 -0700100 public String displayNumber;
Nancy Chen03aaf382015-06-11 20:06:26 -0700101
102 // Whether the contact number is a voicemail number.
Andrew Leeedb22da2015-06-09 18:22:14 -0700103 public boolean isVoicemail;
Nancy Chene80d6222014-10-08 20:17:55 -0700104
Victor Chang240523d2015-12-17 09:14:15 +0000105 /** The {@link UserType} of the contact */
106 public @UserType long contactUserType;
107
Nancy Chen87ba4892014-06-11 17:56:07 -0700108 /**
Nancy Chen03aaf382015-06-11 20:06:26 -0700109 * If this is a voicemail, whether the message is read. For other types of calls, this defaults
110 * to {@code true}.
111 */
112 public boolean isRead = true;
113
114 /**
Andrew Leeedb22da2015-06-09 18:22:14 -0700115 * Constructor with required fields for the details of a call with a number associated with a
116 * contact.
Nancy Chen19702632014-07-25 13:23:16 -0700117 */
Andrew Leeedb22da2015-06-09 18:22:14 -0700118 public PhoneCallDetails(
119 Context context,
120 CharSequence number,
121 int numberPresentation,
122 CharSequence formattedNumber,
Hall Liu35e44d42015-10-14 15:19:06 -0700123 CharSequence postDialDigits,
Andrew Lee49efd912015-05-19 12:17:26 -0700124 boolean isVoicemail) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700125 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700126 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700127 this.formattedNumber = formattedNumber;
Andrew Lee49efd912015-05-19 12:17:26 -0700128 this.isVoicemail = isVoicemail;
Hall Liu35e44d42015-10-14 15:19:06 -0700129 this.postDialDigits = postDialDigits.toString();
Andrew Lee49efd912015-05-19 12:17:26 -0700130 this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
131 context,
Andrew Lee49efd912015-05-19 12:17:26 -0700132 this.number,
133 this.numberPresentation,
134 this.formattedNumber,
Hall Liu35e44d42015-10-14 15:19:06 -0700135 this.postDialDigits,
Andrew Lee49efd912015-05-19 12:17:26 -0700136 this.isVoicemail).toString();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700137 }
Brandon Maxwell36aeec92015-10-23 12:01:00 -0700138
139 /**
140 * Returns the preferred name for the call details as specified by the
141 * {@link #nameDisplayOrder}
142 *
143 * @return the preferred name
144 */
145 public CharSequence getPreferredName() {
146 if (nameDisplayOrder == ContactsPreferences.DISPLAY_ORDER_PRIMARY
147 || TextUtils.isEmpty(nameAlternative)) {
148 return namePrimary;
149 }
150 return nameAlternative;
151 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700152}