diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-08-25 11:57:58 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-08-25 15:52:06 -0700 |
commit | cbe05df145b800118f3ca45f61ea486fad1cca08 (patch) | |
tree | e5ed25803b25e6aef4b5c9e2276bd4043c15d84d /src | |
parent | 92536ac3ba54aa13d28b1af957e78d4d3af798a1 (diff) | |
download | packages_apps_Contacts-cbe05df145b800118f3ca45f61ea486fad1cca08.tar.gz packages_apps_Contacts-cbe05df145b800118f3ca45f61ea486fad1cca08.tar.bz2 packages_apps_Contacts-cbe05df145b800118f3ca45f61ea486fad1cca08.zip |
Let Phone UI reload filter on onStart()
This is workaround for bug 5165507: Contacts to Display filter loses
its setting when going from People to Phone app
- call ContactListFilterController#onStart() or its variant.
Not calling it is an apparent bug in DialpadActivity
- instead of checking local filter cache, load it from preferences
every time, only on Phone UI
The root problem is that People and Phone UI don't share one
controller insntance and thus they don't receive the same
filter change event. When the user changes the filter in People,
Phone UI won't receieve the event, for example.
On Phone UI, back button doesn't introduce Activity#finish(), which
makes the whole issue more prominent in People -> Phone case
(set filter on People, and go to Phone), but it does exist in the
opposite case (set filter on Phone, and go to People). The latter
case causes the problem only when People is in background (with
Home button, for example).
This will fix:
- display filter change isn't reflected in Phone, when going from
People to Phone (what reported in bug 5165507)
This won't fix:
- display filter change isn't reflected when it is modified in
Phone UI, while People is in background (with Home button event)
(what caused by the root problem behind that bug)
A more fundementaly fix would be to share one single
ContactListFilterController, which would be more complicated and
a bit too risky at this point.
Bug: 5165507
Change-Id: Ie7968deb99c07597c35e3bb1531461f0a42c326a
Diffstat (limited to 'src')
3 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java index c604e9981..276a06b0f 100644 --- a/src/com/android/contacts/activities/DialtactsActivity.java +++ b/src/com/android/contacts/activities/DialtactsActivity.java @@ -409,6 +409,20 @@ public class DialtactsActivity extends Activity { } } + @Override + public void onStart() { + super.onStart(); + // Force filter reload to reflect possible filter changes done via People UI. + // + // Ideally both (People/Phone) UI should share the same instance for + // ContactListFilterController and they should be able to receive filter change event + // from the same controller (Bug 5165507) + mContactListFilterController.onStart(true); + if (mSearchFragment != null) { + mSearchFragment.setFilter(mContactListFilterController.getFilter()); + } + } + private void prepareSearchView() { final View searchViewLayout = getLayoutInflater().inflate(R.layout.dialtacts_custom_action_bar, null); diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java index a03f83f6d..66bc5f5da 100644 --- a/src/com/android/contacts/activities/PeopleActivity.java +++ b/src/com/android/contacts/activities/PeopleActivity.java @@ -427,7 +427,7 @@ public class PeopleActivity extends ContactsActivity */ configureFragments(!mIsRecreatedInstance); } - mContactListFilterController.onStart(); + mContactListFilterController.onStart(false); super.onStart(); } diff --git a/src/com/android/contacts/list/ContactListFilterController.java b/src/com/android/contacts/list/ContactListFilterController.java index 87228a2a4..ead3a60ff 100644 --- a/src/com/android/contacts/list/ContactListFilterController.java +++ b/src/com/android/contacts/list/ContactListFilterController.java @@ -43,11 +43,15 @@ public class ContactListFilterController { mContext = activity; } - public void onStart() { - if (mFilter == null) { + /** + * @param forceFilterReload when true filter is reloaded even when there's already a cache + * for it. + */ + public void onStart(boolean forceFilterReload) { + if (mFilter == null || forceFilterReload) { mFilter = ContactListFilter.restoreDefaultPreferences(getSharedPreferences()); - mIsInitialized = true; } + mIsInitialized = true; } public boolean isInitialized() { |