blob: f6f9edacef916074fe2b1d32d37d4564cc1c3e25 [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
Yorke Lee8cd94232014-07-23 14:05:31 -070019import com.google.common.annotations.VisibleForTesting;
20
Nancy Chen87ba4892014-06-11 17:56:07 -070021import android.graphics.drawable.Drawable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070022import android.net.Uri;
23import android.provider.CallLog.Calls;
24import android.provider.ContactsContract.CommonDataKinds.Phone;
25
26/**
27 * The details of a phone call to be shown in the UI.
28 */
29public class PhoneCallDetails {
30 /** The number of the other party involved in the call. */
31 public final CharSequence number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -070032 /** The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} */
33 public final int numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -070034 /** The formatted version of {@link #number}. */
35 public final CharSequence formattedNumber;
36 /** The country corresponding with the phone number. */
37 public final String countryIso;
38 /** The geocoded location for the phone number. */
39 public final String geocode;
40 /**
41 * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
42 * <p>
43 * There might be multiple types if this represents a set of entries grouped together.
44 */
45 public final int[] callTypes;
46 /** The date of the call, in milliseconds since the epoch. */
47 public final long date;
48 /** The duration of the call in milliseconds, or 0 for missed calls. */
49 public final long duration;
50 /** The name of the contact, or the empty string. */
51 public final CharSequence name;
52 /** The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available. */
53 public final int numberType;
54 /** The custom label associated with the phone number in the contact, or the empty string. */
55 public final CharSequence numberLabel;
56 /** The URI of the contact associated with this phone call. */
57 public final Uri contactUri;
58 /**
59 * The photo URI of the picture of the contact that is associated with this phone call or
60 * null if there is none.
61 * <p>
62 * This is meant to store the high-res photo only.
63 */
64 public final Uri photoUri;
Yorke Lee56cb0ef2014-02-21 10:02:18 -080065 /**
66 * The source type of the contact associated with this call.
67 */
68 public final int sourceType;
Nancy Chen87ba4892014-06-11 17:56:07 -070069 /**
Nancy Chen19702632014-07-25 13:23:16 -070070 * The unique identifier for the account associated with the call.
71 */
72 public final String accountLabel;
73 /**
74 * The icon for the account associated with the call.
Nancy Chen87ba4892014-06-11 17:56:07 -070075 */
Ihab Awad1d1bd0d2014-06-30 21:24:01 -070076 public final Drawable accountIcon;
Tyler Gunn8b0e8582014-07-10 12:28:43 -070077 /**
78 * Features applicable to this call.
79 */
80 public final int features;
81 /**
82 * Total data usage for this call.
83 */
84 public final Long dataUsage;
Yorke Lee8cd94232014-07-23 14:05:31 -070085 /**
86 * Voicemail transcription
87 */
88 public final String transcription;
89
90 /**
91 * Create the details for a call, with empty defaults specified for extra fields that are
92 * not necessary for testing.
93 */
94 @VisibleForTesting
95 public PhoneCallDetails(CharSequence number, int numberPresentation,
96 CharSequence formattedNumber, String countryIso, String geocode,
97 int[] callTypes, long date, long duration) {
98 this (number, numberPresentation, formattedNumber, countryIso, geocode,
Nancy Chen19702632014-07-25 13:23:16 -070099 callTypes, date, duration, "", 0, "", null, null, 0, null, null, Calls.FEATURES_NONE,
Yorke Lee8cd94232014-07-23 14:05:31 -0700100 null, null);
101 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700102
103 /** Create the details for a call with a number not associated with a contact. */
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700104 public PhoneCallDetails(CharSequence number, int numberPresentation,
105 CharSequence formattedNumber, String countryIso, String geocode,
Nancy Chen19702632014-07-25 13:23:16 -0700106 int[] callTypes, long date, long duration, String accountLabel, Drawable accountIcon,
107 int features, Long dataUsage, String transcription) {
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700108 this(number, numberPresentation, formattedNumber, countryIso, geocode,
Nancy Chen19702632014-07-25 13:23:16 -0700109 callTypes, date, duration, "", 0, "", null, null, 0, accountLabel, accountIcon,
110 features, dataUsage, transcription);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700111 }
112
113 /** Create the details for a call with a number associated with a contact. */
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700114 public PhoneCallDetails(CharSequence number, int numberPresentation,
115 CharSequence formattedNumber, String countryIso, String geocode,
116 int[] callTypes, long date, long duration, CharSequence name,
117 int numberType, CharSequence numberLabel, Uri contactUri,
Nancy Chen19702632014-07-25 13:23:16 -0700118 Uri photoUri, int sourceType, String accountLabel, Drawable accountIcon, int features,
119 Long dataUsage, String transcription) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700120 this.number = number;
Jay Shrauner719a7ad2013-05-30 15:41:13 -0700121 this.numberPresentation = numberPresentation;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700122 this.formattedNumber = formattedNumber;
123 this.countryIso = countryIso;
124 this.geocode = geocode;
125 this.callTypes = callTypes;
126 this.date = date;
127 this.duration = duration;
128 this.name = name;
129 this.numberType = numberType;
130 this.numberLabel = numberLabel;
131 this.contactUri = contactUri;
132 this.photoUri = photoUri;
Yorke Lee56cb0ef2014-02-21 10:02:18 -0800133 this.sourceType = sourceType;
Nancy Chen19702632014-07-25 13:23:16 -0700134 this.accountLabel = accountLabel;
Ihab Awad1d1bd0d2014-06-30 21:24:01 -0700135 this.accountIcon = accountIcon;
Tyler Gunn8b0e8582014-07-10 12:28:43 -0700136 this.features = features;
137 this.dataUsage = dataUsage;
Yorke Lee8cd94232014-07-23 14:05:31 -0700138 this.transcription = transcription;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700139 }
140}