blob: fb1827dc4b1488a5ec0f2ef6bdb195a877fa6c1f [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;
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 Cheng94b10b52012-08-17 16:59:12 -070043 /**
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 Leeedb22da2015-06-09 18:22:14 -070048 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 Maxwell36aeec92015-10-23 12:01:00 -070055 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 Leeedb22da2015-06-09 18:22:14 -070063 // 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 Lee2f05af32015-06-09 15:59:47 -070069
Chiao Cheng94b10b52012-08-17 16:59:12 -070070 /**
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 Leeedb22da2015-06-09 18:22:14 -070076 public Uri photoUri;
77
78 // The source type of the contact associated with this call.
79 public int sourceType;
80
Andrew Lee2f05af32015-06-09 15:59:47 -070081 // The object id type of the contact associated with this call.
82 public String objectId;
83
Andrew Leeedb22da2015-06-09 18:22:14 -070084 // 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 Chen03aaf382015-06-11 20:06:26 -070096 // The display string for the number.
Andrew Leeedb22da2015-06-09 18:22:14 -070097 public String displayNumber;
Nancy Chen03aaf382015-06-11 20:06:26 -070098
99 // Whether the contact number is a voicemail number.
Andrew Leeedb22da2015-06-09 18:22:14 -0700100 public boolean isVoicemail;
Nancy Chene80d6222014-10-08 20:17:55 -0700101
Nancy Chen87ba4892014-06-11 17:56:07 -0700102 /**
Nancy Chen03aaf382015-06-11 20:06:26 -0700103 * 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 Leeedb22da2015-06-09 18:22:14 -0700109 * Constructor with required fields for the details of a call with a number associated with a
110 * contact.
Nancy Chen19702632014-07-25 13:23:16 -0700111 */
Andrew Leeedb22da2015-06-09 18:22:14 -0700112 public PhoneCallDetails(
113 Context context,
114 CharSequence number,
115 int numberPresentation,
116 CharSequence formattedNumber,
Andrew Lee49efd912015-05-19 12:17:26 -0700117 boolean isVoicemail) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700118 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700119 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700120 this.formattedNumber = formattedNumber;
Andrew Lee49efd912015-05-19 12:17:26 -0700121 this.isVoicemail = isVoicemail;
Andrew Lee49efd912015-05-19 12:17:26 -0700122 this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
123 context,
Andrew Lee49efd912015-05-19 12:17:26 -0700124 this.number,
125 this.numberPresentation,
126 this.formattedNumber,
127 this.isVoicemail).toString();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700128 }
Brandon Maxwell36aeec92015-10-23 12:01:00 -0700129
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 Cheng94b10b52012-08-17 16:59:12 -0700143}