blob: add63151a3f545b369738ea1b19862acc3019f27 [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
Andrew Lee49efd912015-05-19 12:17:26 -070019import com.android.dialer.calllog.PhoneNumberDisplayUtil;
Yorke Lee8cd94232014-07-23 14:05:31 -070020
Andrew Lee49efd912015-05-19 12:17:26 -070021import android.content.Context;
Nancy Chen87ba4892014-06-11 17:56:07 -070022import android.graphics.drawable.Drawable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070023import android.net.Uri;
24import android.provider.CallLog.Calls;
25import android.provider.ContactsContract.CommonDataKinds.Phone;
Nancy Chene80d6222014-10-08 20:17:55 -070026import android.telecom.PhoneAccountHandle;
Andrew Lee49efd912015-05-19 12:17:26 -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;
35 // The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED}
36 public int numberPresentation;
37 // The formatted version of {@link #number}.
38 public CharSequence formattedNumber;
39 // The country corresponding with the phone number.
40 public String countryIso;
41 // The geocoded location for the phone number.
42 public String geocode;
43
Chiao Cheng94b10b52012-08-17 16:59:12 -070044 /**
45 * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
46 * <p>
47 * There might be multiple types if this represents a set of entries grouped together.
48 */
Andrew Leeedb22da2015-06-09 18:22:14 -070049 public int[] callTypes;
50
51 // The date of the call, in milliseconds since the epoch.
52 public long date;
53 // The duration of the call in milliseconds, or 0 for missed calls.
54 public long duration;
55 // The name of the contact, or the empty string.
56 public CharSequence name;
57 // The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available.
58 public int numberType;
59 // The custom label associated with the phone number in the contact, or the empty string.
60 public CharSequence numberLabel;
61 // The URI of the contact associated with this phone call.
62 public Uri contactUri;
Andrew Lee2f05af32015-06-09 15:59:47 -070063
Chiao Cheng94b10b52012-08-17 16:59:12 -070064 /**
65 * The photo URI of the picture of the contact that is associated with this phone call or
66 * null if there is none.
67 * <p>
68 * This is meant to store the high-res photo only.
69 */
Andrew Leeedb22da2015-06-09 18:22:14 -070070 public Uri photoUri;
71
72 // The source type of the contact associated with this call.
73 public int sourceType;
74
Andrew Lee2f05af32015-06-09 15:59:47 -070075 // The object id type of the contact associated with this call.
76 public String objectId;
77
Andrew Leeedb22da2015-06-09 18:22:14 -070078 // The unique identifier for the account associated with the call.
79 public PhoneAccountHandle accountHandle;
80
81 // Features applicable to this call.
82 public int features;
83
84 // Total data usage for this call.
85 public Long dataUsage;
86
87 // Voicemail transcription
88 public String transcription;
89
90 public String displayNumber;
91 public boolean isVoicemail;
Nancy Chene80d6222014-10-08 20:17:55 -070092
Nancy Chen87ba4892014-06-11 17:56:07 -070093 /**
Andrew Leeedb22da2015-06-09 18:22:14 -070094 * Constructor with required fields for the details of a call with a number associated with a
95 * contact.
Nancy Chen19702632014-07-25 13:23:16 -070096 */
Andrew Leeedb22da2015-06-09 18:22:14 -070097 public PhoneCallDetails(
98 Context context,
99 CharSequence number,
100 int numberPresentation,
101 CharSequence formattedNumber,
Andrew Lee49efd912015-05-19 12:17:26 -0700102 boolean isVoicemail) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700103 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700104 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700105 this.formattedNumber = formattedNumber;
Andrew Lee49efd912015-05-19 12:17:26 -0700106 this.isVoicemail = isVoicemail;
107
108 this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
109 context,
Andrew Lee49efd912015-05-19 12:17:26 -0700110 this.number,
111 this.numberPresentation,
112 this.formattedNumber,
113 this.isVoicemail).toString();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700114 }
115}