Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.dialer; |
| 18 | |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 19 | import com.google.common.annotations.VisibleForTesting; |
| 20 | |
Nancy Chen | 87ba489 | 2014-06-11 17:56:07 -0700 | [diff] [blame] | 21 | import android.graphics.drawable.Drawable; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 22 | import android.net.Uri; |
| 23 | import android.provider.CallLog.Calls; |
| 24 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
| 25 | |
| 26 | /** |
| 27 | * The details of a phone call to be shown in the UI. |
| 28 | */ |
| 29 | public class PhoneCallDetails { |
| 30 | /** The number of the other party involved in the call. */ |
| 31 | public final CharSequence number; |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 32 | /** The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} */ |
| 33 | public final int numberPresentation; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 34 | /** 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 Lee | 56cb0ef | 2014-02-21 10:02:18 -0800 | [diff] [blame] | 65 | /** |
| 66 | * The source type of the contact associated with this call. |
| 67 | */ |
| 68 | public final int sourceType; |
Nancy Chen | 87ba489 | 2014-06-11 17:56:07 -0700 | [diff] [blame] | 69 | /** |
| 70 | * The unique identifier for the provider associated with the call. |
| 71 | */ |
Ihab Awad | 1d1bd0d | 2014-06-30 21:24:01 -0700 | [diff] [blame] | 72 | public final Drawable accountIcon; |
Tyler Gunn | 8b0e858 | 2014-07-10 12:28:43 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Features applicable to this call. |
| 75 | */ |
| 76 | public final int features; |
| 77 | /** |
| 78 | * Total data usage for this call. |
| 79 | */ |
| 80 | public final Long dataUsage; |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 81 | /** |
| 82 | * Voicemail transcription |
| 83 | */ |
| 84 | public final String transcription; |
| 85 | |
| 86 | /** |
| 87 | * Create the details for a call, with empty defaults specified for extra fields that are |
| 88 | * not necessary for testing. |
| 89 | */ |
| 90 | @VisibleForTesting |
| 91 | public PhoneCallDetails(CharSequence number, int numberPresentation, |
| 92 | CharSequence formattedNumber, String countryIso, String geocode, |
| 93 | int[] callTypes, long date, long duration) { |
| 94 | this (number, numberPresentation, formattedNumber, countryIso, geocode, |
| 95 | callTypes, date, duration, "", 0, "", null, null, 0, null, Calls.FEATURES_NONE, |
| 96 | null, null); |
| 97 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 98 | |
| 99 | /** Create the details for a call with a number not associated with a contact. */ |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 100 | public PhoneCallDetails(CharSequence number, int numberPresentation, |
| 101 | CharSequence formattedNumber, String countryIso, String geocode, |
Tyler Gunn | 8b0e858 | 2014-07-10 12:28:43 -0700 | [diff] [blame] | 102 | int[] callTypes, long date, long duration, Drawable accountIcon, int features, |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 103 | Long dataUsage, String transcription) { |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 104 | this(number, numberPresentation, formattedNumber, countryIso, geocode, |
Tyler Gunn | 8b0e858 | 2014-07-10 12:28:43 -0700 | [diff] [blame] | 105 | callTypes, date, duration, "", 0, "", null, null, 0, accountIcon, features, |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 106 | dataUsage, transcription); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /** Create the details for a call with a number associated with a contact. */ |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 110 | public PhoneCallDetails(CharSequence number, int numberPresentation, |
| 111 | CharSequence formattedNumber, String countryIso, String geocode, |
| 112 | int[] callTypes, long date, long duration, CharSequence name, |
| 113 | int numberType, CharSequence numberLabel, Uri contactUri, |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 114 | Uri photoUri, int sourceType, Drawable accountIcon, int features, Long dataUsage, |
| 115 | String transcription) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 116 | this.number = number; |
Jay Shrauner | 719a7ad | 2013-05-30 15:41:13 -0700 | [diff] [blame] | 117 | this.numberPresentation = numberPresentation; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 118 | this.formattedNumber = formattedNumber; |
| 119 | this.countryIso = countryIso; |
| 120 | this.geocode = geocode; |
| 121 | this.callTypes = callTypes; |
| 122 | this.date = date; |
| 123 | this.duration = duration; |
| 124 | this.name = name; |
| 125 | this.numberType = numberType; |
| 126 | this.numberLabel = numberLabel; |
| 127 | this.contactUri = contactUri; |
| 128 | this.photoUri = photoUri; |
Yorke Lee | 56cb0ef | 2014-02-21 10:02:18 -0800 | [diff] [blame] | 129 | this.sourceType = sourceType; |
Ihab Awad | 1d1bd0d | 2014-06-30 21:24:01 -0700 | [diff] [blame] | 130 | this.accountIcon = accountIcon; |
Tyler Gunn | 8b0e858 | 2014-07-10 12:28:43 -0700 | [diff] [blame] | 131 | this.features = features; |
| 132 | this.dataUsage = dataUsage; |
Yorke Lee | 8cd9423 | 2014-07-23 14:05:31 -0700 | [diff] [blame] | 133 | this.transcription = transcription; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 134 | } |
| 135 | } |