Remove unused columns from all contacts query
- remove ContactBrowseListContextMenuAdapter, which isn't used
- remove columns used only by the class
- remove SORT_KEY_PRIMARY which isn't used right now
- remove phonetic name
Bug: 5535731
Bug: 5265330
Change-Id: I60f28369395a95fbbc4b5048ff5a3227b323bd3f
diff --git a/src/com/android/contacts/list/ContactBrowseListContextMenuAdapter.java b/src/com/android/contacts/list/ContactBrowseListContextMenuAdapter.java
deleted file mode 100644
index 135fbc6..0000000
--- a/src/com/android/contacts/list/ContactBrowseListContextMenuAdapter.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.contacts.list;
-
-import com.android.contacts.R;
-import com.android.contacts.util.PhoneCapabilityTester;
-import com.android.contacts.widget.ContextMenuAdapter;
-
-import android.content.Context;
-import android.net.Uri;
-import android.util.Log;
-import android.view.ContextMenu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.widget.AdapterView;
-
-/**
- * A contextual menu adapter for the basic contact list.
- *
- * TODO Not used any more. Remove it.
- */
-public class ContactBrowseListContextMenuAdapter implements ContextMenuAdapter {
-
- private static final int MENU_ITEM_VIEW_CONTACT = 1;
- private static final int MENU_ITEM_CALL = 2;
- private static final int MENU_ITEM_SEND_SMS = 3;
- private static final int MENU_ITEM_EDIT = 4;
- private static final int MENU_ITEM_DELETE = 5;
- private static final int MENU_ITEM_TOGGLE_STAR = 6;
-
- private static final String TAG = "LightContactBrowserContextMenuAdapter";
-
- private final ContactBrowseListFragment mContactListFragment;
-
- public ContactBrowseListContextMenuAdapter(ContactBrowseListFragment fragment) {
- this.mContactListFragment = fragment;
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
- AdapterView.AdapterContextMenuInfo info;
- try {
- info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- } catch (ClassCastException e) {
- Log.wtf(TAG, "Bad menuInfo", e);
- return;
- }
-
- ContactListAdapter adapter = mContactListFragment.getAdapter();
- int headerViewsCount = mContactListFragment.getListView().getHeaderViewsCount();
- int position = info.position - headerViewsCount;
-
- // Setup the menu header
- menu.setHeaderTitle(adapter.getContactDisplayName(position));
-
- // View contact details
- menu.add(0, MENU_ITEM_VIEW_CONTACT, 0, R.string.menu_viewContact);
-
- if (adapter.getHasPhoneNumber(position)) {
- final Context context = mContactListFragment.getContext();
- boolean hasPhoneApp = PhoneCapabilityTester.isPhone(context);
- boolean hasSmsApp = PhoneCapabilityTester.isSmsIntentRegistered(context);
- // Calling contact
- if (hasPhoneApp) menu.add(0, MENU_ITEM_CALL, 0, R.string.menu_call);
- // Send SMS item
- if (hasSmsApp) menu.add(0, MENU_ITEM_SEND_SMS, 0, R.string.menu_sendSMS);
- }
-
- // Star toggling
- if (!adapter.isContactStarred(position)) {
- menu.add(0, MENU_ITEM_TOGGLE_STAR, 0, R.string.menu_addStar);
- } else {
- menu.add(0, MENU_ITEM_TOGGLE_STAR, 0, R.string.menu_removeStar);
- }
-
- // Contact editing
- menu.add(0, MENU_ITEM_EDIT, 0, R.string.menu_editContact);
- menu.add(0, MENU_ITEM_DELETE, 0, R.string.menu_deleteContact);
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- AdapterView.AdapterContextMenuInfo info;
- try {
- info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
- } catch (ClassCastException e) {
- Log.wtf(TAG, "Bad menuInfo", e);
- return false;
- }
-
- ContactListAdapter adapter = mContactListFragment.getAdapter();
- int headerViewsCount = mContactListFragment.getListView().getHeaderViewsCount();
- int position = info.position - headerViewsCount;
-
- final Uri contactUri = adapter.getContactUri(position);
- switch (item.getItemId()) {
- case MENU_ITEM_VIEW_CONTACT: {
- mContactListFragment.viewContact(contactUri);
- return true;
- }
-
- case MENU_ITEM_TOGGLE_STAR: {
- if (adapter.isContactStarred(position)) {
- mContactListFragment.removeFromFavorites(contactUri);
- } else {
- mContactListFragment.addToFavorites(contactUri);
- }
- return true;
- }
-
- case MENU_ITEM_CALL: {
- mContactListFragment.callContact(contactUri);
- return true;
- }
-
- case MENU_ITEM_SEND_SMS: {
- mContactListFragment.smsContact(contactUri);
- return true;
- }
-
- case MENU_ITEM_EDIT: {
- mContactListFragment.editContact(contactUri);
- return true;
- }
-
- case MENU_ITEM_DELETE: {
- mContactListFragment.deleteContact(contactUri);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/src/com/android/contacts/list/ContactListAdapter.java b/src/com/android/contacts/list/ContactListAdapter.java
index 6eb9423..bc988e4 100644
--- a/src/com/android/contacts/list/ContactListAdapter.java
+++ b/src/com/android/contacts/list/ContactListAdapter.java
@@ -42,64 +42,48 @@
Contacts._ID, // 0
Contacts.DISPLAY_NAME_PRIMARY, // 1
Contacts.DISPLAY_NAME_ALTERNATIVE, // 2
- Contacts.SORT_KEY_PRIMARY, // 3
- Contacts.STARRED, // 4
- Contacts.CONTACT_PRESENCE, // 5
- Contacts.CONTACT_STATUS, // 6
- Contacts.PHOTO_ID, // 7
- Contacts.PHOTO_THUMBNAIL_URI, // 8
- Contacts.LOOKUP_KEY, // 9
- Contacts.PHONETIC_NAME, // 10
- Contacts.HAS_PHONE_NUMBER, // 11
- Contacts.IS_USER_PROFILE, // 12
+ 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
};
protected static final String[] PROJECTION_DATA = new String[] {
Data.CONTACT_ID, // 0
Data.DISPLAY_NAME_PRIMARY, // 1
Data.DISPLAY_NAME_ALTERNATIVE, // 2
- Data.SORT_KEY_PRIMARY, // 3
- Data.STARRED, // 4
- Data.CONTACT_PRESENCE, // 5
- Data.CONTACT_STATUS, // 6
- Data.PHOTO_ID, // 7
- Data.PHOTO_THUMBNAIL_URI, // 8
- Data.LOOKUP_KEY, // 9
- Data.PHONETIC_NAME, // 10
- Data.HAS_PHONE_NUMBER, // 11
+ Data.CONTACT_PRESENCE, // 3
+ Data.CONTACT_STATUS, // 4
+ Data.PHOTO_ID, // 5
+ Data.PHOTO_THUMBNAIL_URI, // 6
+ Data.LOOKUP_KEY, // 7
};
protected static final String[] FILTER_PROJECTION = new String[] {
Contacts._ID, // 0
Contacts.DISPLAY_NAME_PRIMARY, // 1
Contacts.DISPLAY_NAME_ALTERNATIVE, // 2
- Contacts.SORT_KEY_PRIMARY, // 3
- Contacts.STARRED, // 4
- Contacts.CONTACT_PRESENCE, // 5
- Contacts.CONTACT_STATUS, // 6
- Contacts.PHOTO_ID, // 7
- Contacts.PHOTO_THUMBNAIL_URI, // 8
- Contacts.LOOKUP_KEY, // 9
- Contacts.PHONETIC_NAME, // 10
- Contacts.HAS_PHONE_NUMBER, // 11
- Contacts.IS_USER_PROFILE, // 12
- SearchSnippetColumns.SNIPPET, // 13
+ 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
};
protected static final int CONTACT_ID_COLUMN_INDEX = 0;
protected static final int CONTACT_DISPLAY_NAME_PRIMARY_COLUMN_INDEX = 1;
protected static final int CONTACT_DISPLAY_NAME_ALTERNATIVE_COLUMN_INDEX = 2;
- protected static final int CONTACT_SORT_KEY_PRIMARY_COLUMN_INDEX = 3;
- protected static final int CONTACT_STARRED_COLUMN_INDEX = 4;
- protected static final int CONTACT_PRESENCE_STATUS_COLUMN_INDEX = 5;
- protected static final int CONTACT_CONTACT_STATUS_COLUMN_INDEX = 6;
- protected static final int CONTACT_PHOTO_ID_COLUMN_INDEX = 7;
- protected static final int CONTACT_PHOTO_URI_COLUMN_INDEX = 8;
- protected static final int CONTACT_LOOKUP_KEY_COLUMN_INDEX = 9;
- protected static final int CONTACT_PHONETIC_NAME_COLUMN_INDEX = 10;
- protected static final int CONTACT_HAS_PHONE_COLUMN_INDEX = 11;
- protected static final int CONTACT_IS_USER_PROFILE = 12;
- protected static final int CONTACT_SNIPPET_COLUMN_INDEX = 13;
+ protected static final int CONTACT_PRESENCE_STATUS_COLUMN_INDEX = 3;
+ protected static final int CONTACT_CONTACT_STATUS_COLUMN_INDEX = 4;
+ protected static final int CONTACT_PHOTO_ID_COLUMN_INDEX = 5;
+ protected static final int CONTACT_PHOTO_URI_COLUMN_INDEX = 6;
+ protected static final int CONTACT_LOOKUP_KEY_COLUMN_INDEX = 7;
+ protected static final int CONTACT_IS_USER_PROFILE = 8;
+ protected static final int CONTACT_SNIPPET_COLUMN_INDEX = 9;
private CharSequence mUnknownNameText;
private int mDisplayNameColumnIndex;
@@ -144,14 +128,6 @@
.appendQueryParameter(ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, "true").build();
}
- public boolean getHasPhoneNumber(int position) {
- return ((Cursor)getItem(position)).getInt(CONTACT_HAS_PHONE_COLUMN_INDEX) != 0;
- }
-
- public boolean isContactStarred(int position) {
- return ((Cursor)getItem(position)).getInt(CONTACT_STARRED_COLUMN_INDEX) != 0;
- }
-
@Override
public String getContactDisplayName(int position) {
return ((Cursor)getItem(position)).getString(mDisplayNameColumnIndex);
@@ -266,7 +242,7 @@
protected void bindName(final ContactListItemView view, Cursor cursor) {
view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
false, getContactNameDisplayOrder());
- view.showPhoneticName(cursor, CONTACT_PHONETIC_NAME_COLUMN_INDEX);
+ // Note: we don't show phonetic any more (See issue 5265330)
}
protected void bindPresenceAndStatusMessage(final ContactListItemView view, Cursor cursor) {
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index b16b10c..459d232 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -53,7 +53,6 @@
Phone.CONTACT_ID, // 6
Phone.LOOKUP_KEY, // 7
Phone.PHOTO_ID, // 8
- Phone.PHONETIC_NAME, // 9
};
protected static final int PHONE_ID_COLUMN_INDEX = 0;
@@ -65,7 +64,6 @@
protected static final int PHONE_CONTACT_ID_COLUMN_INDEX = 6;
protected static final int PHONE_LOOKUP_KEY_COLUMN_INDEX = 7;
protected static final int PHONE_PHOTO_ID_COLUMN_INDEX = 8;
- protected static final int PHONE_PHONETIC_NAME_COLUMN_INDEX = 9;
private CharSequence mUnknownNameText;
private int mDisplayNameColumnIndex;
@@ -230,9 +228,8 @@
// Look at elements before and after this position, checking if contact IDs are same.
// If they have one same contact ID, it means they can be grouped.
//
- // In one group, only the first entry will show its photo and names (display name and
- // phonetic name), and the other entries in the group show just their data (e.g. phone
- // number, email address).
+ // In one group, only the first entry will show its photo and its name, and the other
+ // entries in the group show just their data (e.g. phone number, email address).
cursor.moveToPosition(position);
boolean isFirstEntry = true;
boolean showBottomDivider = true;
@@ -302,12 +299,11 @@
protected void bindName(final ContactListItemView view, Cursor cursor) {
view.showDisplayName(cursor, mDisplayNameColumnIndex, mAlternativeDisplayNameColumnIndex,
false, getContactNameDisplayOrder());
- view.showPhoneticName(cursor, PHONE_PHONETIC_NAME_COLUMN_INDEX);
+ // Note: we don't show phonetic names any more (see issue 5265330)
}
protected void unbindName(final ContactListItemView view) {
view.hideDisplayName();
- view.hidePhoneticName();
}
protected void bindPhoto(final ContactListItemView view, Cursor cursor) {