194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/* 294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Copyright (C) 2011 The Android Open Source Project 394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * you may not use this file except in compliance with the License. 694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * You may obtain a copy of the License at 794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 1094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Unless required by applicable law or agreed to in writing, software 1194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * See the License for the specific language governing permissions and 1494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * limitations under the License. 1594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 1694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpackage com.android.dialer.calllog; 1894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.net.Uri; 2094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.text.TextUtils; 2194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 2235071c06d1587942f5a66c8f12e6247e8f904d26Chiao Chengimport com.android.contacts.common.util.UriUtils; 23e6933be00d2ecc266612a374a62e05352937408eChiao Chengimport com.google.common.base.Objects; 2494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 2594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/** 2694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Information for a contact as needed by the Call Log. 2794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 28173ec96476278f0d6aa147d31a60aa3e419e5ca3Jay Shraunerpublic class ContactInfo { 2994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public Uri lookupUri; 3056cb0efa5eda1670077e66fc0e8c79478d0c1c67Yorke Lee public String lookupKey; 3194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public String name; 3294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public int type; 3394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public String label; 3494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public String number; 3594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public String formattedNumber; 3694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public String normalizedNumber; 3794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** The photo for the contact, if available. */ 3894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public long photoId; 3994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** The high-res photo for the contact, if available. */ 4094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public Uri photoUri; 41b77bf5df2b866dd40e330b7c2dedee4a1d51fc78Sai Cheemalapati public boolean isBadData; 4255733814f213809baaa8eaa8984ff026bdb08b4eAnthony Lee public String objectId; 4394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 4494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public static ContactInfo EMPTY = new ContactInfo(); 4594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 46034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee public static String GEOCODE_AS_LABEL = ""; 47034a2b329e469bf6888fbbcf91992f974015c2a8Yorke Lee 489fd02a6742c8e9139a03d80bacca360238be11bfChiao Cheng public int sourceType = 0; 499fd02a6742c8e9139a03d80bacca360238be11bfChiao Cheng 5094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 5194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public int hashCode() { 5294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng // Uses only name and contactUri to determine hashcode. 5394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng // This should be sufficient to have a reasonable distribution of hash codes. 5494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng // Moreover, there should be no two people with the same lookupUri. 5594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng final int prime = 31; 5694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng int result = 1; 5794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng result = prime * result + ((lookupUri == null) ? 0 : lookupUri.hashCode()); 5894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng result = prime * result + ((name == null) ? 0 : name.hashCode()); 5994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return result; 6094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 6194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 6294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 6394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public boolean equals(Object obj) { 6494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (this == obj) return true; 6594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (obj == null) return false; 6694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (getClass() != obj.getClass()) return false; 6794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng ContactInfo other = (ContactInfo) obj; 6894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false; 6994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!TextUtils.equals(name, other.name)) return false; 7094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (type != other.type) return false; 7194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!TextUtils.equals(label, other.label)) return false; 7294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!TextUtils.equals(number, other.number)) return false; 7394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false; 7494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; 7594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (photoId != other.photoId) return false; 7694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; 7755733814f213809baaa8eaa8984ff026bdb08b4eAnthony Lee if (!TextUtils.equals(objectId, other.objectId)) return false; 7894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return true; 7994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 80e6933be00d2ecc266612a374a62e05352937408eChiao Cheng 81e6933be00d2ecc266612a374a62e05352937408eChiao Cheng @Override 82e6933be00d2ecc266612a374a62e05352937408eChiao Cheng public String toString() { 83e6933be00d2ecc266612a374a62e05352937408eChiao Cheng return Objects.toStringHelper(this).add("lookupUri", lookupUri).add("name", name).add( 84e6933be00d2ecc266612a374a62e05352937408eChiao Cheng "type", type).add("label", label).add("number", number).add("formattedNumber", 85e6933be00d2ecc266612a374a62e05352937408eChiao Cheng formattedNumber).add("normalizedNumber", normalizedNumber).add("photoId", photoId) 8655733814f213809baaa8eaa8984ff026bdb08b4eAnthony Lee .add("photoUri", photoUri).add("objectId", objectId).toString(); 87e6933be00d2ecc266612a374a62e05352937408eChiao Cheng } 8894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng} 89