Merge change 24088 into eclair

* changes:
  Re-enabling email suggestions and switching to new contacts API.
This commit is contained in:
Android (Google) Code Review 2009-09-08 13:22:24 -07:00
commit e8a37cf769
2 changed files with 19 additions and 35 deletions

View File

@ -16,33 +16,32 @@
package com.android.email; package com.android.email;
import android.provider.ContactsContract; import com.android.email.mail.Address;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.DatabaseUtils; import android.net.Uri;
import android.provider.Contacts.ContactMethods; import android.provider.ContactsContract.Contacts;
import android.provider.Contacts.People; import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.view.View; import android.view.View;
import android.widget.ResourceCursorAdapter; import android.widget.ResourceCursorAdapter;
import android.widget.TextView; import android.widget.TextView;
import com.android.email.mail.Address;
public class EmailAddressAdapter extends ResourceCursorAdapter { public class EmailAddressAdapter extends ResourceCursorAdapter {
public static final int NAME_INDEX = 1; public static final int NAME_INDEX = 1;
public static final int DATA_INDEX = 2; public static final int DATA_INDEX = 2;
private static final String SORT_ORDER = People.TIMES_CONTACTED + " DESC, " + People.NAME; private static final String SORT_ORDER =
Contacts.TIMES_CONTACTED + " DESC, " + Contacts.DISPLAY_NAME;
private ContentResolver mContentResolver; private ContentResolver mContentResolver;
private static final String[] PROJECTION = { private static final String[] PROJECTION = {
ContactMethods._ID, // 0 Data._ID, // 0
ContactMethods.NAME, // 1 Contacts.DISPLAY_NAME, // 1
ContactMethods.DATA Email.DATA // 2
// 2
}; };
public EmailAddressAdapter(Context context) { public EmailAddressAdapter(Context context) {
@ -68,23 +67,8 @@ public class EmailAddressAdapter extends ResourceCursorAdapter {
@Override @Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) { public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
String where = null; String filter = constraint == null ? "" : constraint.toString();
Uri uri = Uri.withAppendedPath(Email.CONTENT_FILTER_URI, Uri.encode(filter));
if (constraint != null) { return mContentResolver.query(uri, PROJECTION, null, null, SORT_ORDER);
String filter = DatabaseUtils.sqlEscapeString(constraint.toString() + '%');
StringBuilder s = new StringBuilder();
s.append("(people.name LIKE ");
s.append(filter);
s.append(") OR (contact_methods.data LIKE ");
s.append(filter);
s.append(")");
where = s.toString();
}
return mContentResolver.query(
ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_EMAIL_URI,
PROJECTION, where, null, SORT_ORDER);
} }
} }

View File

@ -18,6 +18,7 @@ package com.android.email.activity;
import com.android.email.Controller; import com.android.email.Controller;
import com.android.email.Email; import com.android.email.Email;
import com.android.email.EmailAddressAdapter;
import com.android.email.EmailAddressValidator; import com.android.email.EmailAddressValidator;
import com.android.email.R; import com.android.email.R;
import com.android.email.mail.Address; import com.android.email.mail.Address;
@ -470,19 +471,18 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
mQuotedTextDelete.setOnClickListener(this); mQuotedTextDelete.setOnClickListener(this);
// Temporarily disable addressAdapter, see BUG 2077496 EmailAddressAdapter addressAdapter = new EmailAddressAdapter(this);
// EmailAddressAdapter addressAdapter = new EmailAddressAdapter(this);
EmailAddressValidator addressValidator = new EmailAddressValidator(); EmailAddressValidator addressValidator = new EmailAddressValidator();
// mToView.setAdapter(addressAdapter); mToView.setAdapter(addressAdapter);
mToView.setTokenizer(new Rfc822Tokenizer()); mToView.setTokenizer(new Rfc822Tokenizer());
mToView.setValidator(addressValidator); mToView.setValidator(addressValidator);
// mCcView.setAdapter(addressAdapter); mCcView.setAdapter(addressAdapter);
mCcView.setTokenizer(new Rfc822Tokenizer()); mCcView.setTokenizer(new Rfc822Tokenizer());
mCcView.setValidator(addressValidator); mCcView.setValidator(addressValidator);
// mBccView.setAdapter(addressAdapter); mBccView.setAdapter(addressAdapter);
mBccView.setTokenizer(new Rfc822Tokenizer()); mBccView.setTokenizer(new Rfc822Tokenizer());
mBccView.setValidator(addressValidator); mBccView.setValidator(addressValidator);