Merge "Fix StrictMode violation in voicemail playback." into ics-mr1
diff --git a/src/com/android/contacts/format/FormatUtils.java b/src/com/android/contacts/format/FormatUtils.java
index 8e2bb63..4b076cf 100644
--- a/src/com/android/contacts/format/FormatUtils.java
+++ b/src/com/android/contacts/format/FormatUtils.java
@@ -125,6 +125,7 @@
}
/** Returns a String that represents the content of the given {@link CharArrayBuffer}. */
+ @NeededForTesting
public static String charArrayBufferToString(CharArrayBuffer buffer) {
return new String(buffer.data, 0, buffer.sizeCopied);
}
diff --git a/src/com/android/contacts/list/AccountFilterActivity.java b/src/com/android/contacts/list/AccountFilterActivity.java
index 0b4c6e0..14db634 100644
--- a/src/com/android/contacts/list/AccountFilterActivity.java
+++ b/src/com/android/contacts/list/AccountFilterActivity.java
@@ -118,8 +118,8 @@
continue;
}
Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null;
- accountFilters.add(ContactListFilter.createAccountFilter(account.type, account.name,
- account.dataSet, icon, account.name));
+ accountFilters.add(ContactListFilter.createAccountFilter(
+ account.type, account.name, account.dataSet, icon));
}
// Always show "All", even when there's no accounts. (We may have local contacts)
diff --git a/src/com/android/contacts/list/ContactListAdapter.java b/src/com/android/contacts/list/ContactListAdapter.java
index 1592004..a8caf3b 100644
--- a/src/com/android/contacts/list/ContactListAdapter.java
+++ b/src/com/android/contacts/list/ContactListAdapter.java
@@ -39,56 +39,64 @@
public abstract class ContactListAdapter extends ContactEntryListAdapter {
protected static class ContactQuery {
- public static final String[] PROJECTION_CONTACT = new String[] {
+ private static final String[] CONTACT_PROJECTION_PRIMARY = new String[] {
Contacts._ID, // 0
Contacts.DISPLAY_NAME_PRIMARY, // 1
- Contacts.DISPLAY_NAME_ALTERNATIVE, // 2
- Contacts.CONTACT_PRESENCE, // 3
- Contacts.CONTACT_STATUS, // 4
- Contacts.PHOTO_ID, // 5
- Contacts.PHOTO_THUMBNAIL_URI, // 6
- Contacts.LOOKUP_KEY, // 7
- Contacts.IS_USER_PROFILE, // 8
+ Contacts.CONTACT_PRESENCE, // 2
+ Contacts.CONTACT_STATUS, // 3
+ Contacts.PHOTO_ID, // 4
+ Contacts.PHOTO_THUMBNAIL_URI, // 5
+ Contacts.LOOKUP_KEY, // 6
+ Contacts.IS_USER_PROFILE, // 7
};
- public static final String[] PROJECTION_DATA = new String[] {
- Data.CONTACT_ID, // 0
- Data.DISPLAY_NAME_PRIMARY, // 1
- Data.DISPLAY_NAME_ALTERNATIVE, // 2
- Data.CONTACT_PRESENCE, // 3
- Data.CONTACT_STATUS, // 4
- Data.PHOTO_ID, // 5
- Data.PHOTO_THUMBNAIL_URI, // 6
- Data.LOOKUP_KEY, // 7
+ private static final String[] CONTACT_PROJECTION_ALTERNATIVE = new String[] {
+ Contacts._ID, // 0
+ Contacts.DISPLAY_NAME_ALTERNATIVE, // 1
+ Contacts.CONTACT_PRESENCE, // 2
+ Contacts.CONTACT_STATUS, // 3
+ Contacts.PHOTO_ID, // 4
+ Contacts.PHOTO_THUMBNAIL_URI, // 5
+ Contacts.LOOKUP_KEY, // 6
+ Contacts.IS_USER_PROFILE, // 7
};
- public static final String[] FILTER_PROJECTION = new String[] {
+ private static final String[] FILTER_PROJECTION_PRIMARY = new String[] {
Contacts._ID, // 0
Contacts.DISPLAY_NAME_PRIMARY, // 1
- Contacts.DISPLAY_NAME_ALTERNATIVE, // 2
- Contacts.CONTACT_PRESENCE, // 3
- Contacts.CONTACT_STATUS, // 4
- Contacts.PHOTO_ID, // 5
- Contacts.PHOTO_THUMBNAIL_URI, // 6
- Contacts.LOOKUP_KEY, // 7
- Contacts.IS_USER_PROFILE, // 8
- SearchSnippetColumns.SNIPPET, // 9
+ Contacts.CONTACT_PRESENCE, // 2
+ Contacts.CONTACT_STATUS, // 3
+ Contacts.PHOTO_ID, // 4
+ Contacts.PHOTO_THUMBNAIL_URI, // 5
+ Contacts.LOOKUP_KEY, // 6
+ Contacts.IS_USER_PROFILE, // 7
+ SearchSnippetColumns.SNIPPET, // 8
};
- public static final int CONTACT_ID = 0;
- public static final int CONTACT_DISPLAY_NAME_PRIMARY = 1;
- public static final int CONTACT_DISPLAY_NAME_ALTERNATIVE = 2;
- public static final int CONTACT_PRESENCE_STATUS = 3;
- public static final int CONTACT_CONTACT_STATUS = 4;
- public static final int CONTACT_PHOTO_ID = 5;
- public static final int CONTACT_PHOTO_URI = 6;
- public static final int CONTACT_LOOKUP_KEY = 7;
- public static final int CONTACT_IS_USER_PROFILE = 8;
- public static final int CONTACT_SNIPPET = 9;
+ private static final String[] FILTER_PROJECTION_ALTERNATIVE = new String[] {
+ Contacts._ID, // 0
+ Contacts.DISPLAY_NAME_ALTERNATIVE, // 1
+ Contacts.CONTACT_PRESENCE, // 2
+ Contacts.CONTACT_STATUS, // 3
+ Contacts.PHOTO_ID, // 4
+ Contacts.PHOTO_THUMBNAIL_URI, // 5
+ Contacts.LOOKUP_KEY, // 6
+ Contacts.IS_USER_PROFILE, // 7
+ SearchSnippetColumns.SNIPPET, // 8
+ };
+
+ public static final int CONTACT_ID = 0;
+ public static final int CONTACT_DISPLAY_NAME = 1;
+ public static final int CONTACT_PRESENCE_STATUS = 2;
+ public static final int CONTACT_CONTACT_STATUS = 3;
+ public static final int CONTACT_PHOTO_ID = 4;
+ public static final int CONTACT_PHOTO_URI = 5;
+ public static final int CONTACT_LOOKUP_KEY = 6;
+ public static final int CONTACT_IS_USER_PROFILE = 7;
+ public static final int CONTACT_SNIPPET = 8;
}
private CharSequence mUnknownNameText;
- private int mDisplayNameColumnIndex;
private long mSelectedContactDirectoryId;
private String mSelectedContactLookupKey;
@@ -129,17 +137,7 @@
@Override
public String getContactDisplayName(int position) {
- return ((Cursor)getItem(position)).getString(mDisplayNameColumnIndex);
- }
-
- @Override
- public void setContactNameDisplayOrder(int displayOrder) {
- super.setContactNameDisplayOrder(displayOrder);
- if (getContactNameDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
- mDisplayNameColumnIndex = ContactQuery.CONTACT_DISPLAY_NAME_PRIMARY;
- } else {
- mDisplayNameColumnIndex = ContactQuery.CONTACT_DISPLAY_NAME_ALTERNATIVE;
- }
+ return ((Cursor) getItem(position)).getString(ContactQuery.CONTACT_DISPLAY_NAME);
}
/**
@@ -237,7 +235,8 @@
}
protected void bindName(final ContactListItemView view, Cursor cursor) {
- view.showDisplayName(cursor, mDisplayNameColumnIndex, getContactNameDisplayOrder());
+ view.showDisplayName(
+ cursor, ContactQuery.CONTACT_DISPLAY_NAME, getContactNameDisplayOrder());
// Note: we don't show phonetic any more (See issue 5265330)
}
@@ -341,4 +340,24 @@
setProfileExists(cursor.getInt(ContactQuery.CONTACT_IS_USER_PROFILE) == 1);
}
}
+
+ /**
+ * @return Projection useful for children.
+ */
+ protected final String[] getProjection(boolean forSearch) {
+ final int sortOrder = getContactNameDisplayOrder();
+ if (forSearch) {
+ if (sortOrder == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+ return ContactQuery.FILTER_PROJECTION_PRIMARY;
+ } else {
+ return ContactQuery.FILTER_PROJECTION_ALTERNATIVE;
+ }
+ } else {
+ if (sortOrder == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+ return ContactQuery.CONTACT_PROJECTION_PRIMARY;
+ } else {
+ return ContactQuery.CONTACT_PROJECTION_ALTERNATIVE;
+ }
+ }
+ }
}
diff --git a/src/com/android/contacts/list/ContactListFilter.java b/src/com/android/contacts/list/ContactListFilter.java
index 152b152..6e4e949 100644
--- a/src/com/android/contacts/list/ContactListFilter.java
+++ b/src/com/android/contacts/list/ContactListFilter.java
@@ -35,69 +35,51 @@
public static final int FILTER_TYPE_SINGLE_CONTACT = -6;
public static final int FILTER_TYPE_ACCOUNT = 0;
- public static final int FILTER_TYPE_GROUP = 1;
+
+ /**
+ * Obsolete filter which had been used in Honeycomb. This may be stored in
+ * {@link SharedPreferences}, but should be replaced with ALL filter when it is found.
+ *
+ * TODO: "group" filter and relevant variables are all obsolete. Remove them.
+ */
+ private static final int FILTER_TYPE_GROUP = 1;
private static final String KEY_FILTER_TYPE = "filter.type";
private static final String KEY_ACCOUNT_NAME = "filter.accountName";
private static final String KEY_ACCOUNT_TYPE = "filter.accountType";
private static final String KEY_DATA_SET = "filter.dataSet";
- private static final String KEY_GROUP_ID = "filter.groupId";
- private static final String KEY_GROUP_SOURCE_ID = "filter.groupSourceId";
- private static final String KEY_GROUP_READ_ONLY = "filter.groupReadOnly";
- private static final String KEY_GROUP_TITLE = "filter.groupTitle";
public final int filterType;
public final String accountType;
public final String accountName;
public final String dataSet;
public final Drawable icon;
- public long groupId;
- public String groupSourceId;
- public final boolean groupReadOnly;
- public final String title;
private String mId;
public ContactListFilter(int filterType, String accountType, String accountName, String dataSet,
- Drawable icon, long groupId, String groupSourceId, boolean groupReadOnly,
- String title) {
+ Drawable icon) {
this.filterType = filterType;
this.accountType = accountType;
this.accountName = accountName;
this.dataSet = dataSet;
this.icon = icon;
- this.groupId = groupId;
- this.groupSourceId = groupSourceId;
- this.groupReadOnly = groupReadOnly;
- this.title = title;
}
public static ContactListFilter createFilterWithType(int filterType) {
- return new ContactListFilter(filterType, null, null, null, null, 0, null, false, null);
- }
-
- public static ContactListFilter createGroupFilter(long groupId) {
- return new ContactListFilter(ContactListFilter.FILTER_TYPE_GROUP, null, null, null, null,
- groupId, null, false, null);
- }
-
- public static ContactListFilter createGroupFilter(String accountType, String accountName,
- String dataSet, long groupId, String groupSourceId, boolean groupReadOnly,
- String title) {
- return new ContactListFilter(ContactListFilter.FILTER_TYPE_GROUP, accountType, accountName,
- dataSet, null, groupId, groupSourceId, groupReadOnly, title);
+ return new ContactListFilter(filterType, null, null, null, null);
}
public static ContactListFilter createAccountFilter(String accountType, String accountName,
- String dataSet, Drawable icon, String title) {
+ String dataSet, Drawable icon) {
return new ContactListFilter(ContactListFilter.FILTER_TYPE_ACCOUNT, accountType,
- accountName, dataSet, icon, 0, null, false, title);
+ accountName, dataSet, icon);
}
/**
* Returns true if this filter is based on data and may become invalid over time.
*/
public boolean isValidationRequired() {
- return filterType == FILTER_TYPE_ACCOUNT || filterType == FILTER_TYPE_GROUP;
+ return filterType == FILTER_TYPE_ACCOUNT;
}
@Override
@@ -118,9 +100,6 @@
case FILTER_TYPE_ACCOUNT:
return "account: " + accountType + (dataSet != null ? "/" + dataSet : "")
+ " " + accountName;
- case FILTER_TYPE_GROUP:
- return "group: " + accountType + (dataSet != null ? "/" + dataSet : "")
- + " " + accountName + " " + title + "(" + groupId + ")";
}
return super.toString();
}
@@ -137,13 +116,7 @@
return res;
}
- if (filterType != another.filterType) {
- return filterType - another.filterType;
- }
-
- String title1 = title != null ? title : "";
- String title2 = another.title != null ? another.title : "";
- return title1.compareTo(title2);
+ return filterType - another.filterType;
}
@Override
@@ -156,11 +129,6 @@
if (dataSet != null) {
code = code * 31 + dataSet.hashCode();
}
- if (groupSourceId != null) {
- code = code * 31 + groupSourceId.hashCode();
- } else if (groupId != 0) {
- code = code * 31 + (int) groupId;
- }
return code;
}
@@ -182,11 +150,7 @@
return false;
}
- if (groupSourceId != null && otherFilter.groupSourceId != null) {
- return groupSourceId.equals(otherFilter.groupSourceId);
- }
-
- return groupId == otherFilter.groupId;
+ return true;
}
public static void storeToPreferences(SharedPreferences prefs, ContactListFilter filter) {
@@ -195,10 +159,6 @@
.putString(KEY_ACCOUNT_NAME, filter == null ? null : filter.accountName)
.putString(KEY_ACCOUNT_TYPE, filter == null ? null : filter.accountType)
.putString(KEY_DATA_SET, filter == null ? null : filter.dataSet)
- .putLong(KEY_GROUP_ID, filter == null ? -1 : filter.groupId)
- .putString(KEY_GROUP_SOURCE_ID, filter == null ? null : filter.groupSourceId)
- .putBoolean(KEY_GROUP_READ_ONLY, filter == null ? false : filter.groupReadOnly)
- .putString(KEY_GROUP_TITLE, filter == null ? null : filter.title)
.apply();
}
@@ -209,13 +169,16 @@
public static ContactListFilter restoreDefaultPreferences(SharedPreferences prefs) {
ContactListFilter filter = restoreFromPreferences(prefs);
if (filter == null) {
- filter = ContactListFilter.createFilterWithType(
- ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
+ filter = ContactListFilter.createFilterWithType(FILTER_TYPE_ALL_ACCOUNTS);
+ }
+ // "Group" filter is obsolete and thus is not exposed anymore.
+ if (filter.filterType == FILTER_TYPE_GROUP) {
+ filter = ContactListFilter.createFilterWithType(FILTER_TYPE_ALL_ACCOUNTS);
}
return filter;
}
- public static ContactListFilter restoreFromPreferences(SharedPreferences prefs) {
+ private static ContactListFilter restoreFromPreferences(SharedPreferences prefs) {
int filterType = prefs.getInt(KEY_FILTER_TYPE, FILTER_TYPE_DEFAULT);
if (filterType == FILTER_TYPE_DEFAULT) {
return null;
@@ -224,12 +187,7 @@
String accountName = prefs.getString(KEY_ACCOUNT_NAME, null);
String accountType = prefs.getString(KEY_ACCOUNT_TYPE, null);
String dataSet = prefs.getString(KEY_DATA_SET, null);
- long groupId = prefs.getLong(KEY_GROUP_ID, -1);
- String groupSourceId = prefs.getString(KEY_GROUP_SOURCE_ID, null);
- boolean groupReadOnly = prefs.getBoolean(KEY_GROUP_READ_ONLY, false);
- String title = prefs.getString(KEY_GROUP_TITLE, "group");
- return new ContactListFilter(filterType, accountType, accountName, dataSet, null, groupId,
- groupSourceId, groupReadOnly, title);
+ return new ContactListFilter(filterType, accountType, accountName, dataSet, null);
}
@@ -239,9 +197,6 @@
dest.writeString(accountName);
dest.writeString(accountType);
dest.writeString(dataSet);
- dest.writeLong(groupId);
- dest.writeString(groupSourceId);
- dest.writeInt(groupReadOnly ? 1 : 0);
}
public static final Parcelable.Creator<ContactListFilter> CREATOR =
@@ -252,11 +207,7 @@
String accountName = source.readString();
String accountType = source.readString();
String dataSet = source.readString();
- long groupId = source.readLong();
- String groupSourceId = source.readString();
- boolean groupReadOnly = source.readInt() != 0;
- return new ContactListFilter(filterType, accountType, accountName, dataSet, null,
- groupId, groupSourceId, groupReadOnly, null);
+ return new ContactListFilter(filterType, accountType, accountName, dataSet, null);
}
@Override
@@ -286,11 +237,6 @@
if (accountName != null) {
sb.append('-').append(accountName.replace('-', '_'));
}
- if (groupSourceId != null) {
- sb.append('-').append(groupSourceId);
- } else if (groupId != 0) {
- sb.append('-').append(groupId);
- }
mId = sb.toString();
}
return mId;
@@ -304,12 +250,6 @@
.append(", accountName: " + accountName)
.append(", dataSet: " + dataSet);
}
- if (filterType == FILTER_TYPE_GROUP) {
- builder.append(", groupId: " + groupId)
- .append(", groupSourceId: " + groupSourceId)
- .append(", groupReadOnly: " + groupReadOnly)
- .append("title: " + title);
- }
builder.append(", icon: " + icon + "]");
return builder.toString();
}
@@ -330,8 +270,6 @@
return "FILTER_TYPE_SINGLE_CONTACT";
case FILTER_TYPE_ACCOUNT:
return "FILTER_TYPE_ACCOUNT";
- case FILTER_TYPE_GROUP:
- return "FILTER_TYPE_GROUP";
default:
return "(unknown)";
}
diff --git a/src/com/android/contacts/list/ContactListFilterView.java b/src/com/android/contacts/list/ContactListFilterView.java
index 6dc9bc3..398a864 100644
--- a/src/com/android/contacts/list/ContactListFilterView.java
+++ b/src/com/android/contacts/list/ContactListFilterView.java
@@ -115,15 +115,6 @@
}
break;
}
- case ContactListFilter.FILTER_TYPE_GROUP: {
- mIcon.setVisibility(View.VISIBLE);
- mIcon.setImageResource(R.drawable.ic_menu_display_all_holo_light);
- mLabel.setText(mFilter.title);
- if (dropdown) {
- mIndent.setVisibility(mSingleAccount ? View.GONE : View.VISIBLE);
- }
- break;
- }
}
}
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 0cc211a..4bf1a04 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -177,10 +177,6 @@
mCounterHeaderView.setText(getString(
R.string.listTotalAllContactsZeroGroup, filter.accountName));
break;
- case ContactListFilter.FILTER_TYPE_GROUP:
- mCounterHeaderView.setText(
- getString(R.string.listTotalAllContactsZeroGroup, filter.title));
- break;
case ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY:
mCounterHeaderView.setText(R.string.listTotalPhoneContactsZero);
break;
diff --git a/src/com/android/contacts/list/DefaultContactListAdapter.java b/src/com/android/contacts/list/DefaultContactListAdapter.java
index deab8ab..348abb9 100644
--- a/src/com/android/contacts/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/list/DefaultContactListAdapter.java
@@ -72,7 +72,7 @@
// Regardless of the directory, we don't want anything returned,
// so let's just send a "nothing" query to the local directory.
loader.setUri(Contacts.CONTENT_URI);
- loader.setProjection(ContactQuery.PROJECTION_CONTACT);
+ loader.setProjection(getProjection(false));
loader.setSelection("0");
} else {
Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
@@ -87,11 +87,11 @@
SNIPPET_ARGS);
builder.appendQueryParameter(SearchSnippetColumns.DEFERRED_SNIPPETING_KEY,"1");
loader.setUri(builder.build());
- loader.setProjection(ContactQuery.FILTER_PROJECTION);
+ loader.setProjection(getProjection(true));
}
} else {
configureUri(loader, directoryId, filter);
- configureProjection(loader, directoryId, filter);
+ loader.setProjection(getProjection(false));
configureSelection(loader, directoryId, filter);
}
@@ -107,16 +107,12 @@
protected void configureUri(CursorLoader loader, long directoryId, ContactListFilter filter) {
Uri uri = Contacts.CONTENT_URI;
- if (filter != null) {
- if (filter.filterType == ContactListFilter.FILTER_TYPE_GROUP) {
- uri = Data.CONTENT_URI;
- } else if (filter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
- String lookupKey = getSelectedContactLookupKey();
- if (lookupKey != null) {
- uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey);
- } else {
- uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, getSelectedContactId());
- }
+ if (filter != null && filter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
+ String lookupKey = getSelectedContactLookupKey();
+ if (lookupKey != null) {
+ uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey);
+ } else {
+ uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, getSelectedContactId());
}
}
@@ -136,15 +132,6 @@
loader.setUri(uri);
}
- protected void configureProjection(
- CursorLoader loader, long directoryId, ContactListFilter filter) {
- if (filter != null && filter.filterType == ContactListFilter.FILTER_TYPE_GROUP) {
- loader.setProjection(ContactQuery.PROJECTION_DATA);
- } else {
- loader.setProjection(ContactQuery.PROJECTION_CONTACT);
- }
- }
-
private void configureSelection(
CursorLoader loader, long directoryId, ContactListFilter filter) {
if (filter == null) {
@@ -203,13 +190,6 @@
selection.append(")");
break;
}
- case ContactListFilter.FILTER_TYPE_GROUP: {
- selection.append(Data.MIMETYPE + "=?"
- + " AND " + GroupMembership.GROUP_ROW_ID + "=?");
- selectionArgs.add(GroupMembership.CONTENT_ITEM_TYPE);
- selectionArgs.add(String.valueOf(filter.groupId));
- break;
- }
}
loader.setSelection(selection.toString());
loader.setSelectionArgs(selectionArgs.toArray(new String[0]));
diff --git a/src/com/android/contacts/list/JoinContactListAdapter.java b/src/com/android/contacts/list/JoinContactListAdapter.java
index b81dd3b..bfe8c53 100644
--- a/src/com/android/contacts/list/JoinContactListAdapter.java
+++ b/src/com/android/contacts/list/JoinContactListAdapter.java
@@ -67,7 +67,7 @@
@Override
public void configureLoader(CursorLoader cursorLoader, long directoryId) {
- JoinContactLoader loader = (JoinContactLoader)cursorLoader;
+ JoinContactLoader loader = (JoinContactLoader) cursorLoader;
Builder builder = Contacts.CONTENT_URI.buildUpon();
builder.appendEncodedPath(String.valueOf(mTargetContactId));
@@ -83,7 +83,7 @@
loader.setSuggestionUri(builder.build());
// TODO simplify projection
- loader.setProjection(ContactQuery.PROJECTION_CONTACT);
+ loader.setProjection(getProjection(false));
Uri allContactsUri = buildSectionIndexerUri(Contacts.CONTENT_URI).buildUpon()
.appendQueryParameter(
ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT))
@@ -189,13 +189,6 @@
}
}
- public Cursor getShowAllContactsLabelCursor() {
- MatrixCursor matrixCursor = new MatrixCursor(ContactQuery.PROJECTION_CONTACT);
- Object[] row = new Object[ContactQuery.PROJECTION_CONTACT.length];
- matrixCursor.addRow(row);
- return matrixCursor;
- }
-
@Override
public Uri getContactUri(int partitionIndex, Cursor cursor) {
long contactId = cursor.getLong(ContactQuery.CONTACT_ID);
diff --git a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
index 2ce15ff..593c4b2 100644
--- a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
+++ b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
@@ -209,6 +209,9 @@
// TODO: Rotate between all the stream items?
StreamItemEntry streamItem = streamItems.get(0);
CharSequence status = HtmlUtils.fromHtml(context, streamItem.getText());
+ if (status == null) {
+ status = "";
+ }
if (status.length() <= SHORT_SNIPPET_LENGTH) {
sb.append("\n");
} else {
diff --git a/src/com/android/contacts/util/AccountPromptUtils.java b/src/com/android/contacts/util/AccountPromptUtils.java
index 58865d0..111c52e 100644
--- a/src/com/android/contacts/util/AccountPromptUtils.java
+++ b/src/com/android/contacts/util/AccountPromptUtils.java
@@ -22,6 +22,7 @@
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorDescription;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
@@ -57,10 +58,23 @@
/**
* Returns true if the "no account" prompt should be shown
- * (according to {@link SharedPreferences}), otherwise return false.
+ * (according to {@link SharedPreferences}), otherwise return false. Since this prompt is
+ * Google-specific for the time being, this method will also return false if the Google
+ * account type is not available from the {@link AccountManager}.
*/
public static boolean shouldShowAccountPrompt(Context context) {
- return getSharedPreferences(context).getBoolean(KEY_SHOW_ACCOUNT_PROMPT, true);
+ // TODO: Remove the filtering of account types once there is an API in
+ // {@link AccountManager} to show a similar account prompt
+ // (see {@link AccountManager#addAccount()} in {@link #launchAccountPrompt()}
+ // for any type of account. Bug: 5375902
+ AuthenticatorDescription[] allTypes =
+ AccountManager.get(context).getAuthenticatorTypes();
+ for (AuthenticatorDescription authenticatorType : allTypes) {
+ if (GoogleAccountType.ACCOUNT_TYPE.equals(authenticatorType.type)) {
+ return getSharedPreferences(context).getBoolean(KEY_SHOW_ACCOUNT_PROMPT, true);
+ }
+ }
+ return false;
}
/**
diff --git a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
index 4d24f54..555b339 100644
--- a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
+++ b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
@@ -16,10 +16,10 @@
package com.android.contacts.tests.allintents;
-import com.android.contacts.model.AccountWithDataSet;
import com.android.contacts.tests.R;
import com.google.android.collect.Lists;
+import android.accounts.Account;
import android.app.ListActivity;
import android.app.SearchManager;
import android.content.ComponentName;
@@ -51,6 +51,8 @@
/**
* An activity that provides access to various modes of the contacts application.
* Useful for manual and scripted tests.
+ * <p>
+ * Note: this class cannot depend (directly on indirectly) on anything outside the test package.
*/
@SuppressWarnings("deprecation")
public class AllIntentsActivity extends ListActivity
@@ -631,12 +633,12 @@
}
@Override
- public void onAccountChosen(AccountWithDataSet account, int tag) {
+ public void onAccountChosen(Account account, String dataSet, int tag) {
switch (ContactsIntent.get(tag)) {
case EDIT_NEW_CONTACT_FOR_ACCOUNT: {
final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
intent.putExtra(Insert.ACCOUNT, account);
- intent.putExtra(Insert.DATA_SET, account.dataSet);
+ intent.putExtra(Insert.DATA_SET, dataSet);
startActivity(intent);
break;
}
@@ -644,7 +646,7 @@
final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
intent.putExtra(Insert.ACCOUNT, account);
- intent.putExtra(Insert.DATA_SET, account.dataSet);
+ intent.putExtra(Insert.DATA_SET, dataSet);
putDataExtra(intent);
startActivity(intent);
diff --git a/tests/src/com/android/contacts/tests/allintents/SelectAccountDialogFragment.java b/tests/src/com/android/contacts/tests/allintents/SelectAccountDialogFragment.java
index c261553..f0c2df4 100644
--- a/tests/src/com/android/contacts/tests/allintents/SelectAccountDialogFragment.java
+++ b/tests/src/com/android/contacts/tests/allintents/SelectAccountDialogFragment.java
@@ -16,9 +16,8 @@
package com.android.contacts.tests.allintents;
-import com.android.contacts.model.AccountTypeManager;
-import com.android.contacts.model.AccountWithDataSet;
-
+import android.accounts.Account;
+import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -30,8 +29,6 @@
import android.widget.ArrayAdapter;
import android.widget.TextView;
-import java.util.List;
-
/**
* Shows a dialog asking the user which account to chose.
* The result is passed back to the owning Activity
@@ -46,14 +43,14 @@
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle parameters = getArguments();
- final List<AccountWithDataSet> accounts =
- AccountTypeManager.getInstance(getActivity()).getAccounts(false);
+ AccountManager accountManager = AccountManager.get(getActivity());
+ Account[] accounts = accountManager.getAccounts();
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final LayoutInflater inflater = LayoutInflater.from(builder.getContext());
- final ArrayAdapter<AccountWithDataSet> accountAdapter =
- new ArrayAdapter<AccountWithDataSet>(builder.getContext(),
+ final ArrayAdapter<Account> accountAdapter =
+ new ArrayAdapter<Account>(builder.getContext(),
android.R.layout.simple_list_item_2, accounts) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
@@ -64,7 +61,7 @@
final TextView text1 = (TextView)resultView.findViewById(android.R.id.text1);
final TextView text2 = (TextView)resultView.findViewById(android.R.id.text2);
- final AccountWithDataSet account = getItem(position);
+ final Account account = getItem(position);
text1.setText("Name: " + account.name);
text2.setText("Type: " + account.type);
@@ -79,8 +76,10 @@
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
+ // We currently do not pass the dataSet argument to the listener. To do so, we would
+ // have to determine the dataSet as it is done in AccountTypeManager.
((Listener) getActivity()).onAccountChosen(accountAdapter.getItem(which),
- parameters.getInt(EXTRA_TAG));
+ null, parameters.getInt(EXTRA_TAG));
}
};
@@ -97,6 +96,6 @@
}
public interface Listener {
- void onAccountChosen(AccountWithDataSet account, int tag);
+ void onAccountChosen(Account account, String dataSet, int tag);
}
}