Make a Singleton for ContactListFilterController
Better fix for issue 5165507 "Contacts to Display filter loses its
setting when going from People to Phone app". Now the whole app
has one instance and People and Phone UIs share it. All notification
will be delivered to both Activities, and thus no hack on onStart()
will be needed.
Also fixes issue 5299160 "Account filter header not updated when account
is removed from device". We need to update filter after
AccountTypeManager finishes its reload operation.
Now filter settings should be saved only from the controller, so this
change removes the code saving filter settings to SharedPreferences from
Activity/Fragment.
Bug: 5165507
Bug: 5299160
Change-Id: I4118271f1a78976af6cb3d432b1dd7b30c18eb7a
diff --git a/src/com/android/contacts/ContactsApplication.java b/src/com/android/contacts/ContactsApplication.java
index eb8ffa9..f806c1d 100644
--- a/src/com/android/contacts/ContactsApplication.java
+++ b/src/com/android/contacts/ContactsApplication.java
@@ -16,14 +16,13 @@
package com.android.contacts;
+import com.android.contacts.list.ContactListFilterController;
import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.test.InjectedServices;
import com.android.contacts.util.Constants;
import com.google.common.annotations.VisibleForTesting;
import android.app.Application;
-import android.app.FragmentManager;
-import android.app.LoaderManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
@@ -35,6 +34,7 @@
private static InjectedServices sInjectedServices;
private AccountTypeManager mAccountTypeManager;
private ContactPhotoManager mContactPhotoManager;
+ private ContactListFilterController mContactListFilterController;
/**
* Overrides the system services with mocks for testing.
@@ -95,6 +95,14 @@
return mContactPhotoManager;
}
+ if (ContactListFilterController.CONTACT_LIST_FILTER_SERVICE.equals(name)) {
+ if (mContactListFilterController == null) {
+ mContactListFilterController =
+ ContactListFilterController.createContactListFilterController(this);
+ }
+ return mContactListFilterController;
+ }
+
return super.getSystemService(name);
}