Prevent action-bar icons from changing while QuickContacts active.
We were setting a flag in onPause() to ensure that we re-initialize the UI
properly in onResume(). However, this was causing a side-effect when the
background PeopleActivity received loader-notifications that were triggered
by the foreground QuickContactsActivity, because the code triggered by the
loader-notification was looking at the flag set in onPause().
To fix this, showContactsUnavailableFragmentIfNecessary(), gains a boolean
"forceUpdate" argument, which more directly reflects the intended usage.
Also, rename sCUFIN() to updateViewConfiguration(). It's cleaner. And more
accurate.
Bug: 6117162
Change-Id: I35b9f06c0deeffe94d5cf80d4df58a9866387792
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 1194a5e..bcceff4 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -150,7 +150,7 @@
private ContactsUnavailableFragment mContactsUnavailableFragment;
private ProviderStatusWatcher mProviderStatusWatcher;
- private int mProviderStatus = -1;
+ private int mProviderStatus;
private boolean mOptionsMenuContactsAvailable;
@@ -490,8 +490,6 @@
@Override
protected void onPause() {
mOptionsMenuContactsAvailable = false;
-
- mProviderStatus = -1;
mProviderStatusWatcher.stop();
super.onPause();
}
@@ -499,8 +497,9 @@
@Override
protected void onResume() {
super.onResume();
+
mProviderStatusWatcher.start();
- showContactsUnavailableFragmentIfNecessary();
+ updateViewConfiguration(true);
// Re-register the listener, which may have been cleared when onSaveInstanceState was
// called. See also: onSaveInstanceState
@@ -983,15 +982,12 @@
@Override
public void onProviderStatusChange() {
- showContactsUnavailableFragmentIfNecessary();
+ updateViewConfiguration(false);
}
- private void showContactsUnavailableFragmentIfNecessary() {
+ private void updateViewConfiguration(boolean forceUpdate) {
int providerStatus = mProviderStatusWatcher.getProviderStatus();
- if (providerStatus == mProviderStatus) {
- return;
- }
-
+ if (!forceUpdate && (providerStatus == mProviderStatus)) return;
mProviderStatus = providerStatus;
View contactsUnavailableView = findViewById(R.id.contacts_unavailable_view);