Second pass on fragments navigation
1. Fix some janky animation when opening or updating groups.
a. Use FragmentTransaction#replace instead of FragmentTransaction#add
so that mAllFragment will not appear before group members are loaded.
b. Change group URI and reuse existing group fragment to reload group
members, instead of popping old group fragment and adding new group
fragment, when user opens another group from a group view.
2. Fix an error in ContactsDrawerActivity#updateFilterMenu.
3. Move code to handle new Intent from PeopleActivity to group fragment.
4. Initialize ContactListFilterController in
DefaultContactBrowseListFragment#onCreate rather than onActivityCreated.
Because onActivityCreated will be called when fragment is removed and
added back, and we don't want to set filter again and again.
5. Fix a bug where activity title is not updated when nagivating from
account A --> group X --> account A.
6. Move all group actions from GroupUtil to ContactSaveService.
7. Other minor refactoring and cleanup.
Bug: 30944495
Test: manual - navigate between fragments, rotate, press Back/Home/Recent
button, search, multi-select, modify group members,
add/delete groups, view/edit/add groups from
ContactsTests.apk and when no contacts view is shown.
Change-Id: I27c89b4125e55b67921a37f2092fde839a9f8ed4
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index a38e279..492de76 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -109,8 +109,6 @@
private static final String KEY_NEW_GROUP_ACCOUNT = "newGroupAccount";
private static final String KEY_CONTACTS_VIEW = "contactsView";
- protected static final String ACTION_CREATE_GROUP = "createGroup";
-
protected ContactsView mCurrentView;
private class ContactsActionBarDrawerToggle extends ActionBarDrawerToggle {
@@ -525,7 +523,7 @@
public void updateFilterMenu(ContactListFilter filter) {
clearCheckedMenus();
- if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) {
+ if (filter != null && filter.isContactsFilterType()) {
if (mIdMenuMap != null && mIdMenuMap.get(R.id.nav_all_contacts) != null) {
setMenuChecked(mIdMenuMap.get(R.id.nav_all_contacts), true);
}
@@ -583,11 +581,7 @@
}
public void switchToAllContacts() {
- final Intent intent = new Intent();
- final ContactListFilter filter = AccountFilterUtil.createContactsFilter(this);
- intent.putExtra(AccountFilterActivity.EXTRA_CONTACT_LIST_FILTER, filter);
- AccountFilterUtil.handleAccountFilterResult(
- mContactListFilterController, AppCompatActivity.RESULT_OK, intent);
+ resetFilter();
final Menu menu = mNavigationView.getMenu();
final MenuItem allContacts = menu.findItem(R.id.nav_all_contacts);
@@ -596,6 +590,14 @@
setTitle(getString(R.string.contactsList));
}
+ protected void resetFilter() {
+ final Intent intent = new Intent();
+ final ContactListFilter filter = AccountFilterUtil.createContactsFilter(this);
+ intent.putExtra(AccountFilterActivity.EXTRA_CONTACT_LIST_FILTER, filter);
+ AccountFilterUtil.handleAccountFilterResult(
+ mContactListFilterController, AppCompatActivity.RESULT_OK, intent);
+ }
+
protected abstract void launchFindDuplicates();
protected abstract DefaultContactBrowseListFragment getAllFragment();
@@ -645,7 +647,8 @@
@Override
public void onAccountChosen(AccountWithDataSet account, Bundle extraArgs) {
mNewGroupAccount = account;
- GroupNameEditDialogFragment.newInstanceForCreation(mNewGroupAccount, ACTION_CREATE_GROUP)
+ GroupNameEditDialogFragment.newInstanceForCreation(
+ mNewGroupAccount, GroupUtil.ACTION_CREATE_GROUP)
.show(getFragmentManager(), TAG_GROUP_NAME_EDIT_DIALOG);
}