Loading res/menu/view_group.xml +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ android:title="@string/menu_addToGroup" contacts:showAsAction="ifRoom" /> <item android:id="@+id/menu_edit_group" android:icon="@drawable/ic_create_24dp" android:title="@string/menu_editGroup" contacts:showAsAction="ifRoom" /> <item android:id="@+id/menu_rename_group" android:title="@string/menu_renameGroup"/> Loading res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -338,7 +338,7 @@ <string name="groupUpdatedToast">Label updated</string> <!-- Toast displayed when contacts are removed from a label. [CHAR LIMIT=50] --> <string name="groupMembersRemovedToast">Removed contacts</string> <string name="groupMembersRemovedToast">Removed from label</string> <!-- Toast displayed when one or more contacts is added to a label. [CHAR LIMIT=50] --> <string name="groupMembersAddedToast">Added to label</string> Loading src/com/android/contacts/activities/GroupMembersActivity.java +76 −29 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements private static final String KEY_IS_INSERT_ACTION = "isInsertAction"; private static final String KEY_GROUP_URI = "groupUri"; private static final String KEY_GROUP_METADATA = "groupMetadata"; private static final String KEY_IS_EDIT_MODE = "editMode"; private static final String TAG_GROUP_MEMBERS = "groupMembers"; private static final String TAG_SELECT_ACCOUNT_DIALOG = "selectAccountDialog"; Loading Loading @@ -118,19 +119,21 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements } final long[] rawContactIdsToAdd; final long[] rawContactIdsToRemove; final String action; if (mType == TYPE_ADD) { rawContactIdsToAdd = rawContactIds; rawContactIdsToRemove = null; action = GroupMembersActivity.ACTION_ADD_TO_GROUP; } else if (mType == TYPE_REMOVE) { rawContactIdsToAdd = null; rawContactIdsToRemove = rawContactIds; action = GroupMembersActivity.ACTION_REMOVE_FROM_GROUP; } else { throw new IllegalStateException("Unrecognized type " + mType); } return ContactSaveService.createGroupUpdateIntent( mContext, mGroupId, /* newLabel */ null, rawContactIdsToAdd, rawContactIdsToRemove, GroupMembersActivity.class, GroupMembersActivity.ACTION_ADD_TO_GROUP); rawContactIdsToRemove, GroupMembersActivity.class, action); } // TODO(wjang): prune raw contacts that are already in the group; ContactSaveService will Loading Loading @@ -177,12 +180,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements private ActionBarAdapter mActionBarAdapter; private GroupMetadata mGroupMetadata; private GroupMembersFragment mMembersFragment; private Uri mGroupUri; private boolean mIsInsertAction; private boolean mIsEditMode; private GroupMetadata mGroupMetadata; @Override public void onCreate(Bundle savedState) { Loading @@ -192,6 +196,7 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements if (savedState != null) { mGroupUri = savedState.getParcelable(KEY_GROUP_URI); mIsInsertAction = savedState.getBoolean(KEY_IS_INSERT_ACTION); mIsEditMode = savedState.getBoolean(KEY_IS_EDIT_MODE); mGroupMetadata = savedState.getParcelable(KEY_GROUP_METADATA); } else { mGroupUri = getIntent().getData(); Loading Loading @@ -265,8 +270,9 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements if (mActionBarAdapter != null) { mActionBarAdapter.onSaveInstanceState(outState); } outState.putBoolean(KEY_IS_INSERT_ACTION, mIsInsertAction); outState.putParcelable(KEY_GROUP_URI, mGroupUri); outState.putBoolean(KEY_IS_INSERT_ACTION, mIsInsertAction); outState.putBoolean(KEY_IS_EDIT_MODE, mIsEditMode); outState.putParcelable(KEY_GROUP_METADATA, mGroupMetadata); } Loading @@ -293,14 +299,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements super.onNewIntent(newIntent); if (isDeleteAction(newIntent.getAction())) { Toast.makeText(this, R.string.groupDeletedToast, Toast.LENGTH_SHORT).show(); toast(R.string.groupDeletedToast); setResult(RESULT_OK); finish(); } else if (isSaveAction(newIntent.getAction())) { final Uri groupUri = newIntent.getData(); if (groupUri == null) { Toast.makeText(this, R.string.groupSavedErrorToast, Toast.LENGTH_SHORT).show(); setResultCanceledAndFinish(); setResultCanceledAndFinish(R.string.groupSavedErrorToast); return; } if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + groupUri); Loading @@ -308,24 +313,16 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements mGroupUri = groupUri; mIsInsertAction = false; Toast.makeText(this, getToastMessageForSaveAction(newIntent.getAction()), Toast.LENGTH_SHORT).show(); mMembersFragment = GroupMembersFragment.newInstance(groupUri); mMembersFragment.setListener(this); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); addGroupsAndFiltersFragments(transaction); transaction.replace(R.id.fragment_container_inner, mMembersFragment, TAG_GROUP_MEMBERS) .commitAllowingStateLoss(); if (mGroupMetadata != null && mGroupMetadata.editable) { mMembersFragment.setCheckBoxListListener(this); } toast(getToastMessageForSaveAction(newIntent.getAction())); // If we're editing the group, don't reload the fragment so the user can // continue to remove group members one by one if (!mIsEditMode && !ACTION_REMOVE_FROM_GROUP.equals(newIntent.getAction())) { replaceGroupMembersFragment(); invalidateOptionsMenu(); } } } private static boolean isDeleteAction(String action) { return ACTION_DELETE_GROUP.equals(action); Loading @@ -346,6 +343,18 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements throw new IllegalArgumentException("Unhanded contact save action " + action); } private void replaceGroupMembersFragment() { mMembersFragment = GroupMembersFragment.newInstance(mGroupUri); mMembersFragment.setListener(this); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); addGroupsAndFiltersFragments(transaction); transaction.replace(R.id.fragment_container_inner, mMembersFragment, TAG_GROUP_MEMBERS) .commitAllowingStateLoss(); if (mGroupMetadata != null && mGroupMetadata.editable) { mMembersFragment.setCheckBoxListListener(this); } } @Override protected void onGroupMenuItemClicked(long groupId) { if (mGroupMetadata.groupId != groupId) { Loading Loading @@ -392,7 +401,9 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements setVisible(menu, R.id.menu_add, isGroupEditable && !isSelectionMode); setVisible(menu, R.id.menu_rename_group, !isGroupReadOnly && !isSelectionMode); setVisible(menu, R.id.menu_delete_group, !isGroupReadOnly && !isSelectionMode); setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode); setVisible(menu, R.id.menu_edit_group, isGroupEditable && !mIsEditMode); setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode && !mIsEditMode); return true; } Loading Loading @@ -431,6 +442,15 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements deleteGroup(); return true; } case R.id.menu_edit_group: { if (mMembersFragment == null) { return false; } mIsEditMode = true; mActionBarAdapter.setSelectionMode(true); mMembersFragment.displayDeleteButtons(true); return true; } case R.id.menu_remove_from_group: { if (mMembersFragment == null) { return false; Loading Loading @@ -482,6 +502,12 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements mDrawer.closeDrawer(GravityCompat.START); } else if (mIsInsertAction) { finish(); } else if (mIsEditMode) { mIsEditMode = false; mActionBarAdapter.setSelectionMode(false); if (mMembersFragment != null) { mMembersFragment.displayDeleteButtons(false); } } else if (mActionBarAdapter.isSelectionMode()) { mActionBarAdapter.setSelectionMode(false); if (mMembersFragment != null) { Loading Loading @@ -525,14 +551,18 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements setResultCanceledAndFinish(-1); } private void setResultCanceledAndFinish(int toastResId) { if (toastResId >= 0) { Toast.makeText(this, toastResId, Toast.LENGTH_SHORT).show(); } private void setResultCanceledAndFinish(int resId) { toast(resId); setResult(RESULT_CANCELED); finish(); } private void toast(int resId) { if (resId >= 0) { Toast.makeText(this, resId, Toast.LENGTH_SHORT).show(); } } // SelectAccountDialogFragment.Listener callbacks @Override Loading @@ -554,16 +584,24 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements switch (action) { case ActionBarAdapter.Listener.Action.START_SELECTION_MODE: if (mMembersFragment != null) { if (mIsEditMode) { mMembersFragment.displayDeleteButtons(true); } else { mMembersFragment.displayCheckBoxes(true); } } invalidateOptionsMenu(); showFabWithAnimation(/* showFabWithAnimation = */ false); break; case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE: mActionBarAdapter.setSearchMode(false); if (mMembersFragment != null) { if (mIsEditMode) { mMembersFragment.displayDeleteButtons(false); } else { mMembersFragment.displayCheckBoxes(false); } } invalidateOptionsMenu(); showFabWithAnimation(/* showFabWithAnimation */ true); break; Loading Loading @@ -661,4 +699,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.LIST_GROUP); startActivity(intent); } @Override public void onGroupMemberListItemDeleted(int position, long contactId) { final long[] contactIds = new long[1]; contactIds[0] = contactId; new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE, this, contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName, mGroupMetadata.accountType).execute(); } } src/com/android/contacts/group/GroupMembersAdapter.java +25 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { private final CharSequence mUnknownNameText; private long mGroupId; private boolean mDisplayDeleteButtons; public GroupMembersAdapter(Context context) { super(context, GroupMembersQuery.CONTACT_ID); Loading @@ -89,6 +90,21 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { return Contacts.getLookupUri(contactId, lookupKey); } /** Returns the ID of the contact at the given position in the underlying cursor. */ public long getContactId(int position) { final Cursor cursor = (Cursor) getItem(position); return cursor.getLong(GroupMembersQuery.CONTACT_ID); } public void setDisplayDeleteButtons(boolean displayDeleteButtons) { mDisplayDeleteButtons = displayDeleteButtons; notifyDataSetChanged(); } public boolean getDisplayDeleteButtons() { return mDisplayDeleteButtons; } @Override public void configureLoader(CursorLoader loader, long directoryId) { loader.setUri(Data.CONTENT_URI.buildUpon() Loading Loading @@ -143,6 +159,7 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { bindSectionHeaderAndDivider(view, position); bindName(view, cursor); bindPhoto(view, cursor); bindDeleteButton(view); } protected void bindSectionHeaderAndDivider(ContactListItemView view, int position) { Loading Loading @@ -170,4 +187,12 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false, getCircularPhotos(), imageRequest); } private void bindDeleteButton(final ContactListItemView view) { if (mDisplayDeleteButtons) { view.getDeleteImageButton(); } else { view.hideDeleteImageButton(); } } } src/com/android/contacts/group/GroupMembersFragment.java +14 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM /** Invoked when a group member in the list is clicked. */ void onGroupMemberListItemClicked(int position, Uri contactLookupUri); /** Invoked when a the delete button for a group member in the list is clicked. */ void onGroupMemberListItemDeleted(int position, long contactId); } /** Filters out duplicate contacts. */ Loading Loading @@ -209,6 +212,10 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM mListener = listener; } public void displayDeleteButtons(boolean displayDeleteButtons) { getAdapter().setDisplayDeleteButtons(displayDeleteButtons); } public ArrayList<String> getMemberContactIds() { return new ArrayList<>(mGroupMemberContactIds); } Loading Loading @@ -328,8 +335,13 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM return; } if (mListener != null) { if (getAdapter().getDisplayDeleteButtons()) { final long contactId = getAdapter().getContactId(position); mListener.onGroupMemberListItemDeleted(position, contactId); } else { final Uri contactLookupUri = getAdapter().getContactLookupUri(position); mListener.onGroupMemberListItemClicked(position, contactLookupUri); } } } } Loading
res/menu/view_group.xml +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ android:title="@string/menu_addToGroup" contacts:showAsAction="ifRoom" /> <item android:id="@+id/menu_edit_group" android:icon="@drawable/ic_create_24dp" android:title="@string/menu_editGroup" contacts:showAsAction="ifRoom" /> <item android:id="@+id/menu_rename_group" android:title="@string/menu_renameGroup"/> Loading
res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -338,7 +338,7 @@ <string name="groupUpdatedToast">Label updated</string> <!-- Toast displayed when contacts are removed from a label. [CHAR LIMIT=50] --> <string name="groupMembersRemovedToast">Removed contacts</string> <string name="groupMembersRemovedToast">Removed from label</string> <!-- Toast displayed when one or more contacts is added to a label. [CHAR LIMIT=50] --> <string name="groupMembersAddedToast">Added to label</string> Loading
src/com/android/contacts/activities/GroupMembersActivity.java +76 −29 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements private static final String KEY_IS_INSERT_ACTION = "isInsertAction"; private static final String KEY_GROUP_URI = "groupUri"; private static final String KEY_GROUP_METADATA = "groupMetadata"; private static final String KEY_IS_EDIT_MODE = "editMode"; private static final String TAG_GROUP_MEMBERS = "groupMembers"; private static final String TAG_SELECT_ACCOUNT_DIALOG = "selectAccountDialog"; Loading Loading @@ -118,19 +119,21 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements } final long[] rawContactIdsToAdd; final long[] rawContactIdsToRemove; final String action; if (mType == TYPE_ADD) { rawContactIdsToAdd = rawContactIds; rawContactIdsToRemove = null; action = GroupMembersActivity.ACTION_ADD_TO_GROUP; } else if (mType == TYPE_REMOVE) { rawContactIdsToAdd = null; rawContactIdsToRemove = rawContactIds; action = GroupMembersActivity.ACTION_REMOVE_FROM_GROUP; } else { throw new IllegalStateException("Unrecognized type " + mType); } return ContactSaveService.createGroupUpdateIntent( mContext, mGroupId, /* newLabel */ null, rawContactIdsToAdd, rawContactIdsToRemove, GroupMembersActivity.class, GroupMembersActivity.ACTION_ADD_TO_GROUP); rawContactIdsToRemove, GroupMembersActivity.class, action); } // TODO(wjang): prune raw contacts that are already in the group; ContactSaveService will Loading Loading @@ -177,12 +180,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements private ActionBarAdapter mActionBarAdapter; private GroupMetadata mGroupMetadata; private GroupMembersFragment mMembersFragment; private Uri mGroupUri; private boolean mIsInsertAction; private boolean mIsEditMode; private GroupMetadata mGroupMetadata; @Override public void onCreate(Bundle savedState) { Loading @@ -192,6 +196,7 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements if (savedState != null) { mGroupUri = savedState.getParcelable(KEY_GROUP_URI); mIsInsertAction = savedState.getBoolean(KEY_IS_INSERT_ACTION); mIsEditMode = savedState.getBoolean(KEY_IS_EDIT_MODE); mGroupMetadata = savedState.getParcelable(KEY_GROUP_METADATA); } else { mGroupUri = getIntent().getData(); Loading Loading @@ -265,8 +270,9 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements if (mActionBarAdapter != null) { mActionBarAdapter.onSaveInstanceState(outState); } outState.putBoolean(KEY_IS_INSERT_ACTION, mIsInsertAction); outState.putParcelable(KEY_GROUP_URI, mGroupUri); outState.putBoolean(KEY_IS_INSERT_ACTION, mIsInsertAction); outState.putBoolean(KEY_IS_EDIT_MODE, mIsEditMode); outState.putParcelable(KEY_GROUP_METADATA, mGroupMetadata); } Loading @@ -293,14 +299,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements super.onNewIntent(newIntent); if (isDeleteAction(newIntent.getAction())) { Toast.makeText(this, R.string.groupDeletedToast, Toast.LENGTH_SHORT).show(); toast(R.string.groupDeletedToast); setResult(RESULT_OK); finish(); } else if (isSaveAction(newIntent.getAction())) { final Uri groupUri = newIntent.getData(); if (groupUri == null) { Toast.makeText(this, R.string.groupSavedErrorToast, Toast.LENGTH_SHORT).show(); setResultCanceledAndFinish(); setResultCanceledAndFinish(R.string.groupSavedErrorToast); return; } if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + groupUri); Loading @@ -308,24 +313,16 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements mGroupUri = groupUri; mIsInsertAction = false; Toast.makeText(this, getToastMessageForSaveAction(newIntent.getAction()), Toast.LENGTH_SHORT).show(); mMembersFragment = GroupMembersFragment.newInstance(groupUri); mMembersFragment.setListener(this); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); addGroupsAndFiltersFragments(transaction); transaction.replace(R.id.fragment_container_inner, mMembersFragment, TAG_GROUP_MEMBERS) .commitAllowingStateLoss(); if (mGroupMetadata != null && mGroupMetadata.editable) { mMembersFragment.setCheckBoxListListener(this); } toast(getToastMessageForSaveAction(newIntent.getAction())); // If we're editing the group, don't reload the fragment so the user can // continue to remove group members one by one if (!mIsEditMode && !ACTION_REMOVE_FROM_GROUP.equals(newIntent.getAction())) { replaceGroupMembersFragment(); invalidateOptionsMenu(); } } } private static boolean isDeleteAction(String action) { return ACTION_DELETE_GROUP.equals(action); Loading @@ -346,6 +343,18 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements throw new IllegalArgumentException("Unhanded contact save action " + action); } private void replaceGroupMembersFragment() { mMembersFragment = GroupMembersFragment.newInstance(mGroupUri); mMembersFragment.setListener(this); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); addGroupsAndFiltersFragments(transaction); transaction.replace(R.id.fragment_container_inner, mMembersFragment, TAG_GROUP_MEMBERS) .commitAllowingStateLoss(); if (mGroupMetadata != null && mGroupMetadata.editable) { mMembersFragment.setCheckBoxListListener(this); } } @Override protected void onGroupMenuItemClicked(long groupId) { if (mGroupMetadata.groupId != groupId) { Loading Loading @@ -392,7 +401,9 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements setVisible(menu, R.id.menu_add, isGroupEditable && !isSelectionMode); setVisible(menu, R.id.menu_rename_group, !isGroupReadOnly && !isSelectionMode); setVisible(menu, R.id.menu_delete_group, !isGroupReadOnly && !isSelectionMode); setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode); setVisible(menu, R.id.menu_edit_group, isGroupEditable && !mIsEditMode); setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode && !mIsEditMode); return true; } Loading Loading @@ -431,6 +442,15 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements deleteGroup(); return true; } case R.id.menu_edit_group: { if (mMembersFragment == null) { return false; } mIsEditMode = true; mActionBarAdapter.setSelectionMode(true); mMembersFragment.displayDeleteButtons(true); return true; } case R.id.menu_remove_from_group: { if (mMembersFragment == null) { return false; Loading Loading @@ -482,6 +502,12 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements mDrawer.closeDrawer(GravityCompat.START); } else if (mIsInsertAction) { finish(); } else if (mIsEditMode) { mIsEditMode = false; mActionBarAdapter.setSelectionMode(false); if (mMembersFragment != null) { mMembersFragment.displayDeleteButtons(false); } } else if (mActionBarAdapter.isSelectionMode()) { mActionBarAdapter.setSelectionMode(false); if (mMembersFragment != null) { Loading Loading @@ -525,14 +551,18 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements setResultCanceledAndFinish(-1); } private void setResultCanceledAndFinish(int toastResId) { if (toastResId >= 0) { Toast.makeText(this, toastResId, Toast.LENGTH_SHORT).show(); } private void setResultCanceledAndFinish(int resId) { toast(resId); setResult(RESULT_CANCELED); finish(); } private void toast(int resId) { if (resId >= 0) { Toast.makeText(this, resId, Toast.LENGTH_SHORT).show(); } } // SelectAccountDialogFragment.Listener callbacks @Override Loading @@ -554,16 +584,24 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements switch (action) { case ActionBarAdapter.Listener.Action.START_SELECTION_MODE: if (mMembersFragment != null) { if (mIsEditMode) { mMembersFragment.displayDeleteButtons(true); } else { mMembersFragment.displayCheckBoxes(true); } } invalidateOptionsMenu(); showFabWithAnimation(/* showFabWithAnimation = */ false); break; case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE: mActionBarAdapter.setSearchMode(false); if (mMembersFragment != null) { if (mIsEditMode) { mMembersFragment.displayDeleteButtons(false); } else { mMembersFragment.displayCheckBoxes(false); } } invalidateOptionsMenu(); showFabWithAnimation(/* showFabWithAnimation */ true); break; Loading Loading @@ -661,4 +699,13 @@ public class GroupMembersActivity extends ContactsDrawerActivity implements intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.LIST_GROUP); startActivity(intent); } @Override public void onGroupMemberListItemDeleted(int position, long contactId) { final long[] contactIds = new long[1]; contactIds[0] = contactId; new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE, this, contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName, mGroupMetadata.accountType).execute(); } }
src/com/android/contacts/group/GroupMembersAdapter.java +25 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { private final CharSequence mUnknownNameText; private long mGroupId; private boolean mDisplayDeleteButtons; public GroupMembersAdapter(Context context) { super(context, GroupMembersQuery.CONTACT_ID); Loading @@ -89,6 +90,21 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { return Contacts.getLookupUri(contactId, lookupKey); } /** Returns the ID of the contact at the given position in the underlying cursor. */ public long getContactId(int position) { final Cursor cursor = (Cursor) getItem(position); return cursor.getLong(GroupMembersQuery.CONTACT_ID); } public void setDisplayDeleteButtons(boolean displayDeleteButtons) { mDisplayDeleteButtons = displayDeleteButtons; notifyDataSetChanged(); } public boolean getDisplayDeleteButtons() { return mDisplayDeleteButtons; } @Override public void configureLoader(CursorLoader loader, long directoryId) { loader.setUri(Data.CONTENT_URI.buildUpon() Loading Loading @@ -143,6 +159,7 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { bindSectionHeaderAndDivider(view, position); bindName(view, cursor); bindPhoto(view, cursor); bindDeleteButton(view); } protected void bindSectionHeaderAndDivider(ContactListItemView view, int position) { Loading Loading @@ -170,4 +187,12 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter { getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false, getCircularPhotos(), imageRequest); } private void bindDeleteButton(final ContactListItemView view) { if (mDisplayDeleteButtons) { view.getDeleteImageButton(); } else { view.hideDeleteImageButton(); } } }
src/com/android/contacts/group/GroupMembersFragment.java +14 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM /** Invoked when a group member in the list is clicked. */ void onGroupMemberListItemClicked(int position, Uri contactLookupUri); /** Invoked when a the delete button for a group member in the list is clicked. */ void onGroupMemberListItemDeleted(int position, long contactId); } /** Filters out duplicate contacts. */ Loading Loading @@ -209,6 +212,10 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM mListener = listener; } public void displayDeleteButtons(boolean displayDeleteButtons) { getAdapter().setDisplayDeleteButtons(displayDeleteButtons); } public ArrayList<String> getMemberContactIds() { return new ArrayList<>(mGroupMemberContactIds); } Loading Loading @@ -328,8 +335,13 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM return; } if (mListener != null) { if (getAdapter().getDisplayDeleteButtons()) { final long contactId = getAdapter().getContactId(position); mListener.onGroupMemberListItemDeleted(position, contactId); } else { final Uri contactLookupUri = getAdapter().getContactLookupUri(position); mListener.onGroupMemberListItemClicked(position, contactLookupUri); } } } }