summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsaac Katzenelson <isaack@android.com>2011-08-18 17:39:04 -0700
committerIsaac Katzenelson <isaack@android.com>2011-08-23 15:15:23 -0700
commitb848271a560eaeddb2f4007fcbd3f77506a40ac1 (patch)
treef59a131041f612fab6a21de8787cef4a19507ab5
parent69aa5899ef42c0ca18b52d638d82ca019b168935 (diff)
downloadpackages_apps_Contacts-b848271a560eaeddb2f4007fcbd3f77506a40ac1.tar.gz
packages_apps_Contacts-b848271a560eaeddb2f4007fcbd3f77506a40ac1.tar.bz2
packages_apps_Contacts-b848271a560eaeddb2f4007fcbd3f77506a40ac1.zip
Fix overlapping group editors
Bug: 5173297 Group editor tends to duplicate itself and overlap the views on top of each other Add code to remove old editor when a new one is created. Added code to prevent multiple contacts in list of contacts to display. Change-Id: I1bd6da440545047d18667bd01f74f84c1677601a
-rw-r--r--src/com/android/contacts/group/GroupEditorFragment.java39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/com/android/contacts/group/GroupEditorFragment.java b/src/com/android/contacts/group/GroupEditorFragment.java
index 2287557fa..9cdbe4691 100644
--- a/src/com/android/contacts/group/GroupEditorFragment.java
+++ b/src/com/android/contacts/group/GroupEditorFragment.java
@@ -92,6 +92,8 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
private static final String KEY_MEMBERS_TO_REMOVE = "membersToRemove";
private static final String KEY_MEMBERS_TO_DISPLAY = "membersToDisplay";
+ private static final String CURRENT_EDITOR_TAG = "currentEditorForAccount";
+
public static interface Listener {
/**
* Group metadata was not found, close the fragment now.
@@ -189,6 +191,7 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
private boolean mGroupNameIsReadOnly;
private String mOriginalGroupName = "";
+ private int mLastGroupEditorId;
private MemberListAdapter mMemberListAdapter;
private ContactPhotoManager mPhotoManager;
@@ -374,10 +377,31 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
private void setupEditorForAccount() {
final AccountType accountType = getAccountType();
final boolean editable = isGroupMembershipEditable();
+ boolean isNewEditor = false;
mMemberListAdapter.setIsGroupMembershipEditable(editable);
- View editorView = mLayoutInflater.inflate(editable ?
- R.layout.group_editor_view : R.layout.external_group_editor_view, mRootView, false);
+ // Since this method can be called multiple time, remove old editor if the editor type
+ // is different from the new one and mark the editor with a tag so it can be found for
+ // removal if needed
+ View editorView;
+ int newGroupEditorId =
+ editable ? R.layout.group_editor_view : R.layout.external_group_editor_view;
+ if (newGroupEditorId != mLastGroupEditorId) {
+ View oldEditorView = mRootView.findViewWithTag(CURRENT_EDITOR_TAG);
+ if (oldEditorView != null) {
+ mRootView.removeView(oldEditorView);
+ }
+ editorView = mLayoutInflater.inflate(newGroupEditorId, mRootView, false);
+ editorView.setTag(CURRENT_EDITOR_TAG);
+ mAutoCompleteAdapter = null;
+ mLastGroupEditorId = newGroupEditorId;
+ isNewEditor = true;
+ } else {
+ editorView = mRootView.findViewWithTag(CURRENT_EDITOR_TAG);
+ if (editorView == null) {
+ throw new IllegalStateException("Group editor view not found");
+ }
+ }
mGroupNameView = (TextView) editorView.findViewById(R.id.group_name);
mAccountIcon = (ImageView) editorView.findViewById(R.id.account_icon);
@@ -433,8 +457,9 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
// If the group name is ready only, don't let the user focus on the field.
mGroupNameView.setFocusable(!mGroupNameIsReadOnly);
-
- mRootView.addView(editorView);
+ if(isNewEditor) {
+ mRootView.addView(editorView);
+ }
mStatus = Status.EDITING;
}
@@ -680,9 +705,15 @@ public class GroupEditorFragment extends Fragment implements SelectAccountDialog
}
private void addExistingMembers(List<Member> members) {
+
+ // Re-create the list to display
+ mListToDisplay.clear();
mListToDisplay.addAll(members);
+ mListToDisplay.addAll(mListMembersToAdd);
+ mListToDisplay.removeAll(mListMembersToRemove);
mMemberListAdapter.notifyDataSetChanged();
+
// Update the autocomplete adapter (if there is one) so these contacts don't get suggested
if (mAutoCompleteAdapter != null) {
mAutoCompleteAdapter.updateExistingMembersList(members);