blob: 68fdadc0c139cd9c4ce65c5ddc369396408dfe8c [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;
Chiao Cheng94b10b52012-08-17 16:59:12 -070063 /**
64 * The photo URI of the picture of the contact that is associated with this phone call or
65 * null if there is none.
66 * <p>
67 * This is meant to store the high-res photo only.
68 */
Andrew Leeedb22da2015-06-09 18:22:14 -070069 public Uri photoUri;
70
71 // The source type of the contact associated with this call.
72 public int sourceType;
73
74 // The unique identifier for the account associated with the call.
75 public PhoneAccountHandle accountHandle;
76
77 // Features applicable to this call.
78 public int features;
79
80 // Total data usage for this call.
81 public Long dataUsage;
82
83 // Voicemail transcription
84 public String transcription;
85
86 public String displayNumber;
87 public boolean isVoicemail;
Nancy Chene80d6222014-10-08 20:17:55 -070088
Nancy Chen87ba4892014-06-11 17:56:07 -070089 /**
Andrew Leeedb22da2015-06-09 18:22:14 -070090 * Constructor with required fields for the details of a call with a number associated with a
91 * contact.
Nancy Chen19702632014-07-25 13:23:16 -070092 */
Andrew Leeedb22da2015-06-09 18:22:14 -070093 public PhoneCallDetails(
94 Context context,
95 CharSequence number,
96 int numberPresentation,
97 CharSequence formattedNumber,
Andrew Lee49efd912015-05-19 12:17:26 -070098 boolean isVoicemail) {
Chiao Cheng94b10b52012-08-17 16:59:12 -070099 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700100 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700101 this.formattedNumber = formattedNumber;
Andrew Lee49efd912015-05-19 12:17:26 -0700102 this.isVoicemail = isVoicemail;
103
104 this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
105 context,
Andrew Lee49efd912015-05-19 12:17:26 -0700106 this.number,
107 this.numberPresentation,
108 this.formattedNumber,
109 this.isVoicemail).toString();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700110 }
111}