• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.calllog;
18 
19 import android.net.Uri;
20 import android.text.TextUtils;
21 
22 import com.android.contacts.common.util.UriUtils;
23 import com.google.common.base.Objects;
24 
25 /**
26  * Information for a contact as needed by the Call Log.
27  */
28 public class ContactInfo {
29     public Uri lookupUri;
30     public String lookupKey;
31     public String name;
32     public int type;
33     public String label;
34     public String number;
35     public String formattedNumber;
36     public String normalizedNumber;
37     /** The photo for the contact, if available. */
38     public long photoId;
39     /** The high-res photo for the contact, if available. */
40     public Uri photoUri;
41     public boolean isBadData;
42     public String objectId;
43 
44     public static ContactInfo EMPTY = new ContactInfo();
45 
46     public static String GEOCODE_AS_LABEL = "";
47 
48     public int sourceType = 0;
49 
50     @Override
hashCode()51     public int hashCode() {
52         // Uses only name and contactUri to determine hashcode.
53         // This should be sufficient to have a reasonable distribution of hash codes.
54         // Moreover, there should be no two people with the same lookupUri.
55         final int prime = 31;
56         int result = 1;
57         result = prime * result + ((lookupUri == null) ? 0 : lookupUri.hashCode());
58         result = prime * result + ((name == null) ? 0 : name.hashCode());
59         return result;
60     }
61 
62     @Override
equals(Object obj)63     public boolean equals(Object obj) {
64         if (this == obj) return true;
65         if (obj == null) return false;
66         if (getClass() != obj.getClass()) return false;
67         ContactInfo other = (ContactInfo) obj;
68         if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false;
69         if (!TextUtils.equals(name, other.name)) return false;
70         if (type != other.type) return false;
71         if (!TextUtils.equals(label, other.label)) return false;
72         if (!TextUtils.equals(number, other.number)) return false;
73         if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false;
74         if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false;
75         if (photoId != other.photoId) return false;
76         if (!UriUtils.areEqual(photoUri, other.photoUri)) return false;
77         if (!TextUtils.equals(objectId, other.objectId)) return false;
78         return true;
79     }
80 
81     @Override
toString()82     public String toString() {
83         return Objects.toStringHelper(this).add("lookupUri", lookupUri).add("name", name).add(
84                 "type", type).add("label", label).add("number", number).add("formattedNumber",
85                 formattedNumber).add("normalizedNumber", normalizedNumber).add("photoId", photoId)
86                 .add("photoUri", photoUri).add("objectId", objectId).toString();
87     }
88 }
89