PrimaryInfo.java revision ccca31529c07970e89419fb85a9e8153a5396838
1/*
2 * Copyright (C) 2016 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.incallui.incall.protocol;
18
19import android.graphics.drawable.Drawable;
20import android.support.annotation.Nullable;
21import com.android.dialer.common.LogUtil;
22import com.android.dialer.multimedia.MultimediaData;
23import java.util.Locale;
24
25/** Information about the primary call. */
26public class PrimaryInfo {
27  @Nullable public final String number;
28  @Nullable public final String name;
29  public final boolean nameIsNumber;
30  // This is from contacts and shows the type of number. For example, "Mobile".
31  @Nullable public final String label;
32  @Nullable public final String location;
33  @Nullable public final Drawable photo;
34  @ContactPhotoType public final int photoType;
35  public final boolean isSipCall;
36  public final boolean isContactPhotoShown;
37  public final boolean isWorkCall;
38  public final boolean isSpam;
39  public final boolean answeringDisconnectsOngoingCall;
40  public final boolean shouldShowLocation;
41  // Used for consistent LetterTile coloring.
42  @Nullable public final String contactInfoLookupKey;
43  @Nullable public final MultimediaData multimediaData;
44
45  // TODO: Convert to autovalue. b/34502119
46  public static PrimaryInfo createEmptyPrimaryInfo() {
47    return new PrimaryInfo(
48        null,
49        null,
50        false,
51        null,
52        null,
53        null,
54        ContactPhotoType.DEFAULT_PLACEHOLDER,
55        false,
56        false,
57        false,
58        false,
59        false,
60        false,
61        null,
62        null);
63  }
64
65  public PrimaryInfo(
66      @Nullable String number,
67      @Nullable String name,
68      boolean nameIsNumber,
69      @Nullable String location,
70      @Nullable String label,
71      @Nullable Drawable photo,
72      @ContactPhotoType int phototType,
73      boolean isSipCall,
74      boolean isContactPhotoShown,
75      boolean isWorkCall,
76      boolean isSpam,
77      boolean answeringDisconnectsOngoingCall,
78      boolean shouldShowLocation,
79      @Nullable String contactInfoLookupKey,
80      @Nullable MultimediaData multimediaData) {
81    this.number = number;
82    this.name = name;
83    this.nameIsNumber = nameIsNumber;
84    this.location = location;
85    this.label = label;
86    this.photo = photo;
87    this.photoType = phototType;
88    this.isSipCall = isSipCall;
89    this.isContactPhotoShown = isContactPhotoShown;
90    this.isWorkCall = isWorkCall;
91    this.isSpam = isSpam;
92    this.answeringDisconnectsOngoingCall = answeringDisconnectsOngoingCall;
93    this.shouldShowLocation = shouldShowLocation;
94    this.contactInfoLookupKey = contactInfoLookupKey;
95    this.multimediaData = multimediaData;
96  }
97
98  @Override
99  public String toString() {
100    return String.format(
101        Locale.US,
102        "PrimaryInfo, number: %s, name: %s, location: %s, label: %s, "
103            + "photo: %s, photoType: %d, isPhotoVisible: %b",
104        LogUtil.sanitizePhoneNumber(number),
105        LogUtil.sanitizePii(name),
106        LogUtil.sanitizePii(location),
107        label,
108        photo,
109        photoType,
110        isContactPhotoShown);
111  }
112}
113