blob: 42776ffa97981e9aedd4576fb253dcb2b67b1254 [file] [log] [blame]
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -07001/*
2 * Copyright (C) 2010 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
Dmitri Plotnikov18ffaa22010-12-03 14:28:00 -080017package com.android.contacts.editor;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070018
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070019import android.content.ContentResolver;
20import android.content.Context;
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -080021import android.database.ContentObserver;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070022import android.database.Cursor;
23import android.net.Uri;
Wenyi Wang18fd9382015-11-20 10:12:52 -080024import android.os.Build;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070025import android.os.Handler;
26import android.os.HandlerThread;
27import android.os.Message;
28import android.os.Process;
29import android.provider.ContactsContract.CommonDataKinds.Email;
30import android.provider.ContactsContract.CommonDataKinds.Nickname;
31import android.provider.ContactsContract.CommonDataKinds.Phone;
Gary Mai6a87ee92016-11-18 14:24:51 -080032import android.provider.ContactsContract.CommonDataKinds.Photo;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070033import android.provider.ContactsContract.CommonDataKinds.StructuredName;
34import android.provider.ContactsContract.Contacts;
35import android.provider.ContactsContract.Contacts.AggregationSuggestions;
36import android.provider.ContactsContract.Contacts.AggregationSuggestions.Builder;
37import android.provider.ContactsContract.Data;
Dmitri Plotnikovc0130cc2010-10-18 19:14:54 -070038import android.provider.ContactsContract.RawContacts;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070039import android.text.TextUtils;
40
Chiao Cheng738ff862012-11-30 12:06:03 -080041import com.android.contacts.common.model.ValuesDelta;
Gary Mai220d10c2016-09-23 13:56:39 -070042import com.android.contacts.common.model.account.AccountWithDataSet;
Wenyi Wangaac0e662015-12-18 17:17:33 -080043import com.android.contacts.compat.AggregationSuggestionsCompat;
Gary Mai6a87ee92016-11-18 14:24:51 -080044
John Shao0a7d7172016-11-11 09:55:58 -080045import com.google.common.base.MoreObjects;
Chiao Chenge0b2f1e2012-06-12 13:07:56 -070046import com.google.common.collect.Lists;
47
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070048import java.util.ArrayList;
49import java.util.Arrays;
50import java.util.List;
51
52/**
53 * Runs asynchronous queries to obtain aggregation suggestions in the as-you-type mode.
54 */
55public class AggregationSuggestionEngine extends HandlerThread {
56 public static final String TAG = "AggregationSuggestionEngine";
57
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070058 public interface Listener {
59 void onAggregationSuggestionChange();
60 }
61
62 public static final class Suggestion {
63 public long contactId;
Gary Mai678108e2016-10-26 14:34:33 -070064 public String contactLookupKey;
65 public long rawContactId;
Gary Mai6a87ee92016-11-18 14:24:51 -080066 public long photoId = -1;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070067 public String name;
68 public String phoneNumber;
69 public String emailAddress;
70 public String nickname;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070071
72 @Override
73 public String toString() {
John Shao0a7d7172016-11-11 09:55:58 -080074 return MoreObjects.toStringHelper(Suggestion.class)
Gary Mai678108e2016-10-26 14:34:33 -070075 .add("contactId", contactId)
76 .add("contactLookupKey", contactLookupKey)
77 .add("rawContactId", rawContactId)
Gary Mai04926c02016-11-15 17:01:56 -080078 .add("photoId", photoId)
Gary Mai678108e2016-10-26 14:34:33 -070079 .add("name", name)
80 .add("phoneNumber", phoneNumber)
81 .add("emailAddress", emailAddress)
82 .add("nickname", nickname)
83 .toString();
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -070084 }
85 }
86
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -080087 private final class SuggestionContentObserver extends ContentObserver {
88 private SuggestionContentObserver(Handler handler) {
89 super(handler);
90 }
91
92 @Override
93 public void onChange(boolean selfChange) {
94 scheduleSuggestionLookup();
95 }
96 }
97
98 private static final int MESSAGE_RESET = 0;
99 private static final int MESSAGE_NAME_CHANGE = 1;
100 private static final int MESSAGE_DATA_CURSOR = 2;
101
102 private static final long SUGGESTION_LOOKUP_DELAY_MILLIS = 300;
103
Gary Mai678108e2016-10-26 14:34:33 -0700104 private static final int SUGGESTIONS_LIMIT = 3;
105
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800106 private final Context mContext;
107
108 private long[] mSuggestedContactIds = new long[0];
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800109 private Handler mMainHandler;
110 private Handler mHandler;
111 private long mContactId;
Gary Mai220d10c2016-09-23 13:56:39 -0700112 private AccountWithDataSet mAccountFilter;
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800113 private Listener mListener;
114 private Cursor mDataCursor;
115 private ContentObserver mContentObserver;
116 private Uri mSuggestionsUri;
117
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700118 public AggregationSuggestionEngine(Context context) {
119 super("AggregationSuggestions", Process.THREAD_PRIORITY_BACKGROUND);
Makoto Onuki2828c482012-04-27 15:01:44 -0700120 mContext = context.getApplicationContext();
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700121 mMainHandler = new Handler() {
122 @Override
123 public void handleMessage(Message msg) {
124 AggregationSuggestionEngine.this.deliverNotification((Cursor) msg.obj);
125 }
126 };
127 }
128
129 protected Handler getHandler() {
130 if (mHandler == null) {
131 mHandler = new Handler(getLooper()) {
132 @Override
133 public void handleMessage(Message msg) {
134 AggregationSuggestionEngine.this.handleMessage(msg);
135 }
136 };
137 }
138 return mHandler;
139 }
140
141 public void setContactId(long contactId) {
Dmitri Plotnikov916cf262010-10-19 17:30:01 -0700142 if (contactId != mContactId) {
143 mContactId = contactId;
144 reset();
145 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700146 }
147
Gary Mai220d10c2016-09-23 13:56:39 -0700148 public void setAccountFilter(AccountWithDataSet account) {
149 mAccountFilter = account;
150 }
151
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700152 public void setListener(Listener listener) {
153 mListener = listener;
154 }
155
156 @Override
157 public boolean quit() {
158 if (mDataCursor != null) {
159 mDataCursor.close();
160 }
161 mDataCursor = null;
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800162 if (mContentObserver != null) {
163 mContext.getContentResolver().unregisterContentObserver(mContentObserver);
164 mContentObserver = null;
165 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700166 return super.quit();
167 }
168
Dmitri Plotnikov9302ba72010-10-14 18:08:40 -0700169 public void reset() {
170 Handler handler = getHandler();
171 handler.removeMessages(MESSAGE_NAME_CHANGE);
172 handler.sendEmptyMessage(MESSAGE_RESET);
173 }
174
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700175 public void onNameChange(ValuesDelta values) {
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800176 mSuggestionsUri = buildAggregationSuggestionUri(values);
177 if (mSuggestionsUri != null) {
178 if (mContentObserver == null) {
179 mContentObserver = new SuggestionContentObserver(getHandler());
180 mContext.getContentResolver().registerContentObserver(
181 Contacts.CONTENT_URI, true, mContentObserver);
182 }
183 } else if (mContentObserver != null) {
184 mContext.getContentResolver().unregisterContentObserver(mContentObserver);
185 mContentObserver = null;
186 }
187 scheduleSuggestionLookup();
188 }
189
190 protected void scheduleSuggestionLookup() {
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700191 Handler handler = getHandler();
192 handler.removeMessages(MESSAGE_NAME_CHANGE);
193
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800194 if (mSuggestionsUri == null) {
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700195 return;
196 }
197
Dmitri Plotnikovd52121b2010-12-10 12:17:25 -0800198 Message msg = handler.obtainMessage(MESSAGE_NAME_CHANGE, mSuggestionsUri);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700199 handler.sendMessageDelayed(msg, SUGGESTION_LOOKUP_DELAY_MILLIS);
200 }
201
202 private Uri buildAggregationSuggestionUri(ValuesDelta values) {
203 StringBuilder nameSb = new StringBuilder();
204 appendValue(nameSb, values, StructuredName.PREFIX);
205 appendValue(nameSb, values, StructuredName.GIVEN_NAME);
206 appendValue(nameSb, values, StructuredName.MIDDLE_NAME);
207 appendValue(nameSb, values, StructuredName.FAMILY_NAME);
208 appendValue(nameSb, values, StructuredName.SUFFIX);
209
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700210 StringBuilder phoneticNameSb = new StringBuilder();
211 appendValue(phoneticNameSb, values, StructuredName.PHONETIC_FAMILY_NAME);
212 appendValue(phoneticNameSb, values, StructuredName.PHONETIC_MIDDLE_NAME);
213 appendValue(phoneticNameSb, values, StructuredName.PHONETIC_GIVEN_NAME);
214
215 if (nameSb.length() == 0 && phoneticNameSb.length() == 0) {
216 return null;
217 }
218
Wenyi Wang18fd9382015-11-20 10:12:52 -0800219 // AggregationSuggestions.Builder() became visible in API level 23, so use it if applicable.
220 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
221 final Builder uriBuilder = new AggregationSuggestions.Builder()
Gary Mai678108e2016-10-26 14:34:33 -0700222 .setLimit(SUGGESTIONS_LIMIT)
Wenyi Wang18fd9382015-11-20 10:12:52 -0800223 .setContactId(mContactId);
224 if (nameSb.length() != 0) {
225 uriBuilder.addNameParameter(nameSb.toString());
226 }
227 if (phoneticNameSb.length() != 0) {
228 uriBuilder.addNameParameter(phoneticNameSb.toString());
229 }
230 return uriBuilder.build();
231 }
232
233 // For previous SDKs, use the backup plan.
234 final AggregationSuggestionsCompat.Builder uriBuilder =
235 new AggregationSuggestionsCompat.Builder()
Gary Mai678108e2016-10-26 14:34:33 -0700236 .setLimit(SUGGESTIONS_LIMIT)
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700237 .setContactId(mContactId);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700238 if (nameSb.length() != 0) {
Wenyi Wang18fd9382015-11-20 10:12:52 -0800239 uriBuilder.addNameParameter(nameSb.toString());
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700240 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700241 if (phoneticNameSb.length() != 0) {
Wenyi Wang18fd9382015-11-20 10:12:52 -0800242 uriBuilder.addNameParameter(phoneticNameSb.toString());
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700243 }
Wenyi Wang18fd9382015-11-20 10:12:52 -0800244 return uriBuilder.build();
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700245 }
246
247 private void appendValue(StringBuilder sb, ValuesDelta values, String column) {
248 String value = values.getAsString(column);
249 if (!TextUtils.isEmpty(value)) {
250 if (sb.length() > 0) {
251 sb.append(' ');
252 }
253 sb.append(value);
254 }
255 }
256
257 protected void handleMessage(Message msg) {
Dmitri Plotnikov9302ba72010-10-14 18:08:40 -0700258 switch (msg.what) {
259 case MESSAGE_RESET:
260 mSuggestedContactIds = new long[0];
261 break;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700262 case MESSAGE_NAME_CHANGE:
263 loadAggregationSuggestions((Uri) msg.obj);
264 break;
265 }
266 }
267
268 private static final class DataQuery {
269
270 public static final String SELECTION_PREFIX =
271 Data.MIMETYPE + " IN ('"
Gary Mai678108e2016-10-26 14:34:33 -0700272 + Phone.CONTENT_ITEM_TYPE + "','"
273 + Email.CONTENT_ITEM_TYPE + "','"
274 + StructuredName.CONTENT_ITEM_TYPE + "','"
Gary Mai6a87ee92016-11-18 14:24:51 -0800275 + Nickname.CONTENT_ITEM_TYPE + "','"
276 + Photo.CONTENT_ITEM_TYPE + "')"
Gary Mai678108e2016-10-26 14:34:33 -0700277 + " AND " + Data.CONTACT_ID + " IN (";
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700278
279 public static final String[] COLUMNS = {
Gary Mai678108e2016-10-26 14:34:33 -0700280 Data.CONTACT_ID,
281 Data.LOOKUP_KEY,
282 Data.RAW_CONTACT_ID,
283 Data.MIMETYPE,
284 Data.DATA1,
285 Data.IS_SUPER_PRIMARY,
286 RawContacts.ACCOUNT_TYPE,
287 RawContacts.ACCOUNT_NAME,
Gary Mai04926c02016-11-15 17:01:56 -0800288 RawContacts.DATA_SET,
Gary Mai6a87ee92016-11-18 14:24:51 -0800289 Contacts.Photo._ID
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700290 };
291
Gary Mai678108e2016-10-26 14:34:33 -0700292 public static final int CONTACT_ID = 0;
293 public static final int LOOKUP_KEY = 1;
294 public static final int RAW_CONTACT_ID = 2;
295 public static final int MIMETYPE = 3;
296 public static final int DATA1 = 4;
297 public static final int IS_SUPERPRIMARY = 5;
298 public static final int ACCOUNT_TYPE = 6;
299 public static final int ACCOUNT_NAME = 7;
300 public static final int DATA_SET = 8;
Gary Mai04926c02016-11-15 17:01:56 -0800301 public static final int PHOTO_ID = 9;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700302 }
303
304 private void loadAggregationSuggestions(Uri uri) {
305 ContentResolver contentResolver = mContext.getContentResolver();
306 Cursor cursor = contentResolver.query(uri, new String[]{Contacts._ID}, null, null, null);
Jay Shrauner13c42f42014-01-27 17:06:27 -0800307 if (cursor == null) {
308 return;
309 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700310 try {
311 // If a new request is pending, chuck the result of the previous request
312 if (getHandler().hasMessages(MESSAGE_NAME_CHANGE)) {
313 return;
314 }
315
316 boolean changed = updateSuggestedContactIds(cursor);
317 if (!changed) {
318 return;
319 }
320
321 StringBuilder sb = new StringBuilder(DataQuery.SELECTION_PREFIX);
322 int count = mSuggestedContactIds.length;
323 for (int i = 0; i < count; i++) {
324 if (i > 0) {
325 sb.append(',');
326 }
327 sb.append(mSuggestedContactIds[i]);
328 }
329 sb.append(')');
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700330
331 Cursor dataCursor = contentResolver.query(Data.CONTENT_URI,
332 DataQuery.COLUMNS, sb.toString(), null, Data.CONTACT_ID);
Jay Shrauner13c42f42014-01-27 17:06:27 -0800333 if (dataCursor != null) {
Gary Mai678108e2016-10-26 14:34:33 -0700334 mMainHandler.sendMessage(
335 mMainHandler.obtainMessage(MESSAGE_DATA_CURSOR, dataCursor));
Jay Shrauner13c42f42014-01-27 17:06:27 -0800336 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700337 } finally {
338 cursor.close();
339 }
340 }
341
Jay Shrauner5a57e572014-05-29 13:41:24 -0700342 private boolean updateSuggestedContactIds(final Cursor cursor) {
343 final int count = cursor.getCount();
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700344 boolean changed = count != mSuggestedContactIds.length;
Jay Shrauner5a57e572014-05-29 13:41:24 -0700345 final ArrayList<Long> newIds = new ArrayList<Long>(count);
346 while (cursor.moveToNext()) {
347 final long contactId = cursor.getLong(0);
Gary Mai678108e2016-10-26 14:34:33 -0700348 if (!changed && Arrays.binarySearch(mSuggestedContactIds, contactId) < 0) {
Jay Shrauner5a57e572014-05-29 13:41:24 -0700349 changed = true;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700350 }
Jay Shrauner5a57e572014-05-29 13:41:24 -0700351 newIds.add(contactId);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700352 }
353
354 if (changed) {
Jay Shrauner5a57e572014-05-29 13:41:24 -0700355 mSuggestedContactIds = new long[newIds.size()];
356 int i = 0;
357 for (final Long newId : newIds) {
358 mSuggestedContactIds[i++] = newId;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700359 }
360 Arrays.sort(mSuggestedContactIds);
361 }
362
363 return changed;
364 }
365
366 protected void deliverNotification(Cursor dataCursor) {
367 if (mDataCursor != null) {
368 mDataCursor.close();
369 }
370 mDataCursor = dataCursor;
371 if (mListener != null) {
372 mListener.onAggregationSuggestionChange();
373 }
374 }
375
376 public int getSuggestedContactCount() {
Dmitri Plotnikov9302ba72010-10-14 18:08:40 -0700377 return mDataCursor != null ? mDataCursor.getCount() : 0;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700378 }
379
380 public List<Suggestion> getSuggestions() {
Gary Mai678108e2016-10-26 14:34:33 -0700381 final ArrayList<Suggestion> list = Lists.newArrayList();
Tingting Wange5e6a2a2015-10-22 16:53:31 -0700382
Gary Mai678108e2016-10-26 14:34:33 -0700383 if (mDataCursor != null && mAccountFilter != null) {
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700384 Suggestion suggestion = null;
Gary Mai678108e2016-10-26 14:34:33 -0700385 long currentRawContactId = -1;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700386 mDataCursor.moveToPosition(-1);
387 while (mDataCursor.moveToNext()) {
Gary Mai678108e2016-10-26 14:34:33 -0700388 final long rawContactId = mDataCursor.getLong(DataQuery.RAW_CONTACT_ID);
389 if (rawContactId != currentRawContactId) {
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700390 suggestion = new Suggestion();
Gary Mai678108e2016-10-26 14:34:33 -0700391 suggestion.rawContactId = rawContactId;
392 suggestion.contactId = mDataCursor.getLong(DataQuery.CONTACT_ID);
393 suggestion.contactLookupKey = mDataCursor.getString(DataQuery.LOOKUP_KEY);
394 final String accountName = mDataCursor.getString(DataQuery.ACCOUNT_NAME);
395 final String accountType = mDataCursor.getString(DataQuery.ACCOUNT_TYPE);
396 final String dataSet = mDataCursor.getString(DataQuery.DATA_SET);
Gary Mai220d10c2016-09-23 13:56:39 -0700397 final AccountWithDataSet account = new AccountWithDataSet(
Gary Mai678108e2016-10-26 14:34:33 -0700398 accountName, accountType, dataSet);
399 if (mAccountFilter.equals(account)) {
Gary Mai220d10c2016-09-23 13:56:39 -0700400 list.add(suggestion);
401 }
Gary Mai678108e2016-10-26 14:34:33 -0700402 currentRawContactId = rawContactId;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700403 }
404
Gary Mai678108e2016-10-26 14:34:33 -0700405 final String mimetype = mDataCursor.getString(DataQuery.MIMETYPE);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700406 if (Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {
Gary Mai678108e2016-10-26 14:34:33 -0700407 final String data = mDataCursor.getString(DataQuery.DATA1);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700408 int superprimary = mDataCursor.getInt(DataQuery.IS_SUPERPRIMARY);
409 if (!TextUtils.isEmpty(data)
410 && (superprimary != 0 || suggestion.phoneNumber == null)) {
411 suggestion.phoneNumber = data;
412 }
413 } else if (Email.CONTENT_ITEM_TYPE.equals(mimetype)) {
Gary Mai678108e2016-10-26 14:34:33 -0700414 final String data = mDataCursor.getString(DataQuery.DATA1);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700415 int superprimary = mDataCursor.getInt(DataQuery.IS_SUPERPRIMARY);
416 if (!TextUtils.isEmpty(data)
417 && (superprimary != 0 || suggestion.emailAddress == null)) {
418 suggestion.emailAddress = data;
419 }
420 } else if (Nickname.CONTENT_ITEM_TYPE.equals(mimetype)) {
Gary Mai678108e2016-10-26 14:34:33 -0700421 final String data = mDataCursor.getString(DataQuery.DATA1);
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700422 if (!TextUtils.isEmpty(data)) {
423 suggestion.nickname = data;
424 }
Gary Mai678108e2016-10-26 14:34:33 -0700425 } else if (StructuredName.CONTENT_ITEM_TYPE.equals(mimetype)) {
426 // DATA1 stores the display name for the raw contact.
427 final String data = mDataCursor.getString(DataQuery.DATA1);
428 if (!TextUtils.isEmpty(data) && suggestion.name == null) {
429 suggestion.name = data;
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700430 }
Gary Mai6a87ee92016-11-18 14:24:51 -0800431 } else if (Photo.CONTENT_ITEM_TYPE.equals(mimetype)) {
432 final Long id = mDataCursor.getLong(DataQuery.PHOTO_ID);
433 if (suggestion.photoId == -1) {
434 suggestion.photoId = id;
435 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700436 }
437 }
438 }
439 return list;
440 }
Dmitri Plotnikovf491ae92010-08-16 12:18:53 -0700441}