Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 1 | /* |
Alexandre Lision | c1024c0 | 2014-01-06 11:12:53 -0500 | [diff] [blame] | 2 | * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 3 | * |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 4 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | * |
| 20 | * Additional permission under GNU GPL version 3 section 7: |
| 21 | * |
| 22 | * If you modify this program, or any covered work, by linking or |
| 23 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 24 | * modified version of that library), containing parts covered by the |
| 25 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 26 | * grants you additional permission to convey the resulting work. |
| 27 | * Corresponding Source for a non-source form of such a combination |
| 28 | * shall include the source code for the parts of OpenSSL used as well |
| 29 | * as that of the covered work. |
| 30 | */ |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 31 | package org.sflphone.model; |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 32 | |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 33 | import java.lang.ref.WeakReference; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 34 | import java.util.ArrayList; |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 35 | |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 36 | import android.content.ContentResolver; |
| 37 | import android.database.Cursor; |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 38 | import android.graphics.Bitmap; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 39 | import android.os.Parcel; |
| 40 | import android.os.Parcelable; |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 41 | import android.provider.ContactsContract.Profile; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 42 | |
| 43 | public class CallContact implements Parcelable { |
| 44 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 45 | private long id; |
| 46 | private String mDisplayName; |
| 47 | private long photo_id; |
| 48 | private ArrayList<Phone> phones, sip_phones; |
| 49 | private String mEmail; |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 50 | private boolean isUser; |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 51 | private WeakReference<Bitmap> contact_photo = new WeakReference<Bitmap>(null); |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 52 | |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 53 | private CallContact(long cID, String displayName, long photoID, ArrayList<Phone> p, ArrayList<Phone> sip, String mail, boolean user) { |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 54 | id = cID; |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 55 | mDisplayName = displayName; |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 56 | phones = p; |
| 57 | sip_phones = sip; |
| 58 | mEmail = mail; |
| 59 | photo_id = photoID; |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 60 | isUser = user; |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 61 | } |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 62 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 63 | public CallContact(Parcel in) { |
| 64 | readFromParcel(in); |
| 65 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 66 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 67 | public long getId() { |
| 68 | return id; |
| 69 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 70 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 71 | public String getmDisplayName() { |
| 72 | return mDisplayName; |
| 73 | } |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 74 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 75 | public long getPhoto_id() { |
| 76 | return photo_id; |
| 77 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 78 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 79 | public void setPhoto_id(long photo_id) { |
| 80 | this.photo_id = photo_id; |
| 81 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 82 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 83 | public ArrayList<Phone> getPhones() { |
| 84 | return phones; |
| 85 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 86 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 87 | public void setPhones(ArrayList<Phone> phones) { |
| 88 | this.phones = phones; |
| 89 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 90 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 91 | public ArrayList<Phone> getSip_phones() { |
| 92 | return sip_phones; |
| 93 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 94 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 95 | public void setSip_phones(ArrayList<Phone> sip_phones) { |
| 96 | this.sip_phones = sip_phones; |
| 97 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 98 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 99 | public Phone getSipPhone() { |
| 100 | if (sip_phones.size() > 0) { |
| 101 | return sip_phones.get(0); |
| 102 | } |
| 103 | if (phones.size() > 0) { |
| 104 | return phones.get(0); |
| 105 | } |
| 106 | return null; |
| 107 | } |
Alexandre Savard | 38d6a15 | 2012-09-18 13:33:02 -0400 | [diff] [blame] | 108 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 109 | public String getmEmail() { |
| 110 | return mEmail; |
| 111 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 112 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 113 | public void setmEmail(String mEmail) { |
| 114 | this.mEmail = mEmail; |
| 115 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 116 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 117 | @Override |
| 118 | public String toString() { |
| 119 | return mDisplayName; |
| 120 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 121 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 122 | public static class ContactBuilder { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 123 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 124 | long contactID; |
| 125 | String contactName; |
| 126 | long contactPhoto; |
| 127 | ArrayList<Phone> phones; |
| 128 | ArrayList<Phone> sip; |
| 129 | String contactMail; |
| 130 | boolean hasPhoto; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 131 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 132 | public ContactBuilder startNewContact(long id, String displayName, long photo_id) { |
| 133 | contactID = id; |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 134 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 135 | contactName = displayName; |
| 136 | contactPhoto = photo_id; |
| 137 | phones = new ArrayList<Phone>(); |
| 138 | sip = new ArrayList<Phone>(); |
| 139 | return this; |
| 140 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 141 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 142 | public ContactBuilder addPhoneNumber(String num, int type) { |
| 143 | phones.add(new Phone(num, type)); |
| 144 | return this; |
| 145 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 146 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 147 | public ContactBuilder addSipNumber(String num, int type) { |
| 148 | sip.add(new Phone(num, type)); |
| 149 | return this; |
| 150 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 151 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 152 | public CallContact build() { |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 153 | return new CallContact(contactID, contactName, contactPhoto, phones, sip, contactMail, false); |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 154 | } |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 155 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 156 | public static ContactBuilder getInstance() { |
| 157 | return new ContactBuilder(); |
| 158 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 159 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 160 | public static CallContact buildUnknownContact(String to) { |
| 161 | ArrayList<Phone> phones = new ArrayList<Phone>(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 162 | phones.add(new Phone(to, 0)); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 163 | |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 164 | return new CallContact(-1, to, 0, phones, new ArrayList<CallContact.Phone>(), "", false); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 165 | } |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 166 | |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 167 | public static CallContact buildUserContact(ContentResolver cr) { |
| 168 | String[] mProjection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.PHOTO_ID }; |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 169 | Cursor mProfileCursor = cr.query(Profile.CONTENT_URI, mProjection, null, null, null); |
| 170 | CallContact result = null; |
| 171 | if (mProfileCursor.getCount() > 0) { |
| 172 | mProfileCursor.moveToFirst(); |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 173 | String displayName = mProfileCursor.getString(mProfileCursor.getColumnIndex(Profile.DISPLAY_NAME_PRIMARY)); |
| 174 | |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 175 | result = new CallContact(mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile._ID)), displayName, |
| 176 | mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile.PHOTO_ID)), new ArrayList<Phone>(), |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 177 | new ArrayList<CallContact.Phone>(), "", true); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 178 | } else { |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 179 | result = new CallContact(-1, "Me", 0, new ArrayList<Phone>(), new ArrayList<CallContact.Phone>(), "", true); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 180 | } |
| 181 | mProfileCursor.close(); |
| 182 | return result; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 183 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 184 | |
Alexandre Lision | a458ba2 | 2013-12-11 15:04:11 -0500 | [diff] [blame] | 185 | public CallContact buildSimpleContact(String name, String number_called) { |
| 186 | ArrayList<Phone> phones = new ArrayList<Phone>(); |
| 187 | phones.add(new Phone(number_called, 0)); |
| 188 | |
| 189 | return new CallContact(-1, name, 0, phones, new ArrayList<CallContact.Phone>(), "", false); |
| 190 | } |
| 191 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 192 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 193 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 194 | @Override |
| 195 | public int describeContents() { |
| 196 | return 0; |
| 197 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 198 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 199 | @Override |
| 200 | public void writeToParcel(Parcel dest, int flags) { |
| 201 | dest.writeLong(id); |
| 202 | dest.writeString(mDisplayName); |
| 203 | dest.writeLong(photo_id); |
| 204 | dest.writeTypedList(phones); |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 205 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 206 | dest.writeTypedList(sip_phones); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 207 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 208 | dest.writeString(mEmail); |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 209 | dest.writeByte((byte) (isUser ? 1 : 0)); |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 210 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 211 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 212 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 213 | private void readFromParcel(Parcel in) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 214 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 215 | id = in.readLong(); |
| 216 | mDisplayName = in.readString(); |
| 217 | photo_id = in.readLong(); |
| 218 | phones = new ArrayList<CallContact.Phone>(); |
| 219 | sip_phones = new ArrayList<CallContact.Phone>(); |
| 220 | in.readTypedList(phones, Phone.CREATOR); |
| 221 | in.readTypedList(sip_phones, Phone.CREATOR); |
| 222 | mEmail = in.readString(); |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 223 | isUser = in.readByte() == 1 ? true : false; |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 224 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 225 | |
Alexandre Lision | 6e8931e | 2013-09-19 16:49:34 -0400 | [diff] [blame] | 226 | public static final Parcelable.Creator<CallContact> CREATOR = new Parcelable.Creator<CallContact>() { |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 227 | @Override |
| 228 | public CallContact createFromParcel(Parcel in) { |
| 229 | return new CallContact(in); |
| 230 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 231 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 232 | @Override |
| 233 | public CallContact[] newArray(int size) { |
| 234 | return new CallContact[size]; |
| 235 | } |
| 236 | }; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 237 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 238 | public static class Phone implements Parcelable { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 239 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 240 | int type; |
| 241 | String number; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 242 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 243 | public Phone(String num, int ty) { |
| 244 | type = ty; |
| 245 | number = num; |
| 246 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 247 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 248 | public Phone(Parcel in) { |
| 249 | readFromParcel(in); |
| 250 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 251 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 252 | @Override |
| 253 | public int describeContents() { |
| 254 | return 0; |
| 255 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 256 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 257 | @Override |
| 258 | public void writeToParcel(Parcel dest, int arg1) { |
| 259 | dest.writeInt(type); |
| 260 | dest.writeString(number); |
| 261 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 262 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 263 | private void readFromParcel(Parcel in) { |
| 264 | type = in.readInt(); |
| 265 | number = in.readString(); |
| 266 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 267 | |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 268 | public static final Parcelable.Creator<Phone> CREATOR = new Parcelable.Creator<Phone>() { |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 269 | @Override |
| 270 | public Phone createFromParcel(Parcel in) { |
| 271 | return new Phone(in); |
| 272 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 273 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 274 | @Override |
| 275 | public Phone[] newArray(int size) { |
| 276 | return new Phone[size]; |
| 277 | } |
| 278 | }; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 279 | |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 280 | public int getType() { |
| 281 | return type; |
| 282 | } |
| 283 | |
| 284 | public void setType(int type) { |
| 285 | this.type = type; |
| 286 | } |
| 287 | |
| 288 | public String getNumber() { |
| 289 | return number; |
| 290 | } |
| 291 | |
| 292 | public void setNumber(String number) { |
| 293 | this.number = number; |
| 294 | } |
| 295 | |
| 296 | } |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 297 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 298 | public void addPhoneNumber(String tel, int type) { |
| 299 | phones.add(new Phone(tel, type)); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 300 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | public void addSipNumber(String tel, int type) { |
| 304 | sip_phones.add(new Phone(tel, type)); |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 305 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 306 | } |
| 307 | |
alision | cd8fb91 | 2013-06-28 14:43:51 -0400 | [diff] [blame] | 308 | public boolean isUser() { |
| 309 | return isUser; |
| 310 | } |
| 311 | |
Alexandre Lision | 35c3cbb | 2013-11-04 17:11:54 -0500 | [diff] [blame] | 312 | public boolean hasPhoto() { |
| 313 | if (contact_photo.get() != null) |
| 314 | return true; |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | public Bitmap getPhoto() { |
| 319 | return contact_photo.get(); |
| 320 | } |
| 321 | |
| 322 | public void setPhoto(Bitmap externalBMP) { |
| 323 | contact_photo = new WeakReference<Bitmap>(externalBMP); |
| 324 | } |
| 325 | |
Alexandre Lision | 2b4f94e | 2013-12-12 10:15:47 -0500 | [diff] [blame] | 326 | /** |
| 327 | * A contact is Unknown when his name == his phone number |
| 328 | * @return true when Name == Number |
| 329 | */ |
| 330 | public boolean isUnknown() { |
| 331 | return mDisplayName.contentEquals(phones.get(0).getNumber()); |
| 332 | } |
| 333 | |
Alexandre Savard | 166dbb6 | 2012-09-18 09:37:27 -0400 | [diff] [blame] | 334 | } |