summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/android/dialer/calllog/CallLogFramework.java11
-rw-r--r--java/com/android/dialer/main/impl/OldMainActivityPeer.java98
2 files changed, 83 insertions, 26 deletions
diff --git a/java/com/android/dialer/calllog/CallLogFramework.java b/java/com/android/dialer/calllog/CallLogFramework.java
index b86bfbc10..be4db0675 100644
--- a/java/com/android/dialer/calllog/CallLogFramework.java
+++ b/java/com/android/dialer/calllog/CallLogFramework.java
@@ -101,12 +101,13 @@ public final class CallLogFramework {
return Futures.transform(
Futures.allAsList(allFutures),
unused -> {
- // Send a broadcast to the OldMainActivityPeer to remove the NewCallLogFragment if it is
- // currently attached. If this is not done, user interaction with the fragment could cause
- // call log framework state to be unexpectedly written. For example scrolling could cause
- // the AnnotatedCallLog to be read (which would trigger database creation).
+ // Send a broadcast to the OldMainActivityPeer to remove the NewCallLogFragment and
+ // NewVoicemailFragment if it is currently attached. If this is not done, user interaction
+ // with the fragment could cause call log framework state to be unexpectedly written. For
+ // example scrolling could cause the AnnotatedCallLog to be read (which would trigger
+ // database creation).
LocalBroadcastManager.getInstance(appContext)
- .sendBroadcastSync(new Intent("disableNewCallLogFragment"));
+ .sendBroadcastSync(new Intent("disableCallLogFramework"));
return null;
},
uiExecutor);
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
index c15d7c1a8..d2a6fd8a4 100644
--- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java
+++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
@@ -111,6 +111,7 @@ import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.util.TransactionSafeActivity;
+import com.android.dialer.voicemail.listui.NewVoicemailFragment;
import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler;
import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source;
import com.android.dialer.voicemailstatus.VisualVoicemailEnabledChecker;
@@ -141,7 +142,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
// TODO(calderwoodra): change to AppCompatActivity once new speed dial ships
private final TransactionSafeActivity activity;
- private final BroadcastReceiver disableNewCallLogReceiver =
+ private final BroadcastReceiver disableCallLogFrameworkReceiver =
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -149,12 +150,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
return;
}
/*
- * Remove the NewCallLogFragment if it is currently attached. If this is not done, user
- * interaction with the fragment could cause call log framework state to be unexpectedly
- * written. For example scrolling could cause the AnnotatedCallLog to be read (which would
- * trigger database creation).
+ * Remove the NewCallLogFragment and NewVoicemailFragment if it is currently attached. If
+ * this is not done, user interaction with the fragment could cause call log framework
+ * state to be unexpectedly written. For example scrolling could cause the
+ * AnnotatedCallLog to be read (which would trigger database creation).
*/
bottomNavTabListener.disableNewCallLogFragment();
+ bottomNavTabListener.disableNewVoicemailFragment();
}
};
@@ -476,14 +478,16 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
* (which would trigger database creation).
*/
LocalBroadcastManager.getInstance(activity)
- .registerReceiver(disableNewCallLogReceiver, new IntentFilter("disableNewCallLogFragment"));
+ .registerReceiver(
+ disableCallLogFrameworkReceiver, new IntentFilter("disableCallLogFramework"));
/*
- * Similar to above, if the new call log is being shown and then the activity is paused, when
- * the user returns we need to remove the NewCallLogFragment if the framework has been disabled
- * in the meantime.
+ * Similar to above, if the new call log/new voicemail is being shown and then the activity is
+ * paused, when the user returns we need to remove the NewCallLogFragment if the framework has
+ * been disabled in the meantime.
*/
bottomNavTabListener.ensureCorrectCallLogShown();
+ bottomNavTabListener.ensureCorrectVoicemailShown();
if (bottomNavTabListener.newCallLogFragmentActive()) {
missedCallCountObserver.onChange(false); // Set the initial value for the badge
@@ -509,7 +513,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
@Override
public void onActivityPause() {
searchController.onActivityPause();
- LocalBroadcastManager.getInstance(activity).unregisterReceiver(disableNewCallLogReceiver);
+ LocalBroadcastManager.getInstance(activity).unregisterReceiver(disableCallLogFrameworkReceiver);
activity.getContentResolver().unregisterContentObserver(missedCallCountObserver);
}
@@ -1000,7 +1004,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
public void onActivityResume() {
activityIsAlive = true;
registerVoicemailStatusContentObserver(context);
- callLogQueryHandler.fetchVoicemailStatus();
+ if (!bottomNavTabListener.newVoicemailFragmentActive()) {
+ callLogQueryHandler.fetchVoicemailStatus();
+ }
if (!bottomNavTabListener.newCallLogFragmentActive()) {
callLogQueryHandler.fetchMissedCallsUnreadCount();
}
@@ -1267,6 +1273,24 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
}
}
+ void disableNewVoicemailFragment() {
+ LogUtil.i("MainBottomNavBarBottomNavTabListener.disableNewVoicemailFragment", "disabled");
+ android.support.v4.app.Fragment supportFragment =
+ supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ if (supportFragment != null) {
+ supportFragmentManager.beginTransaction().remove(supportFragment).commit();
+ // If the NewVoicemailFragment was showing, immediately show the old voicemail fragment
+ // instead.
+ if (selectedTab == TabIndex.VOICEMAIL) {
+ LogUtil.i(
+ "MainBottomNavBarBottomNavTabListener.disableNewVoicemailFragment", "showing old");
+ Fragment fragment = fragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ showFragment(
+ fragment == null ? new VisualVoicemailCallLogFragment() : fragment, VOICEMAIL_TAG);
+ }
+ }
+ }
+
void ensureCorrectCallLogShown() {
android.support.v4.app.Fragment supportFragment =
supportFragmentManager.findFragmentByTag(CALL_LOG_TAG);
@@ -1277,6 +1301,18 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
}
}
+ void ensureCorrectVoicemailShown() {
+ android.support.v4.app.Fragment supportFragment =
+ supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ if (supportFragment != null
+ && !CallLogConfigComponent.get(activity)
+ .callLogConfig()
+ .isNewVoicemailFragmentEnabled()) {
+ LogUtil.i("MainBottomNavBarBottomNavTabListener.ensureCorrectVoicemailShown", "disabling");
+ disableNewVoicemailFragment();
+ }
+ }
+
boolean newCallLogFragmentActive() {
return supportFragmentManager.findFragmentByTag(CALL_LOG_TAG) != null
|| (fragmentManager.findFragmentByTag(CALL_LOG_TAG) == null
@@ -1285,6 +1321,14 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
.isNewCallLogFragmentEnabled());
}
+ boolean newVoicemailFragmentActive() {
+ return supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG) != null
+ || (fragmentManager.findFragmentByTag(VOICEMAIL_TAG) == null
+ && CallLogConfigComponent.get(activity)
+ .callLogConfig()
+ .isNewVoicemailFragmentEnabled());
+ }
+
@Override
public void onContactsSelected() {
LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onContactsSelected");
@@ -1308,15 +1352,22 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
}
Logger.get(activity).logScreenView(ScreenEvent.Type.MAIN_VOICEMAIL, activity);
selectedTab = TabIndex.VOICEMAIL;
- VisualVoicemailCallLogFragment fragment =
- (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG);
- if (fragment == null) {
- fragment = new VisualVoicemailCallLogFragment();
- }
- showFragment(fragment, VOICEMAIL_TAG);
- fragment.setUserVisibleHint(true);
- fragment.onVisible();
+ if (CallLogConfigComponent.get(activity).callLogConfig().isNewVoicemailFragmentEnabled()) {
+ android.support.v4.app.Fragment supportFragment =
+ supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ showSupportFragment(
+ supportFragment == null ? new NewVoicemailFragment() : supportFragment, VOICEMAIL_TAG);
+ } else {
+ VisualVoicemailCallLogFragment fragment =
+ (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ if (fragment == null) {
+ fragment = new VisualVoicemailCallLogFragment();
+ }
+ showFragment(fragment, VOICEMAIL_TAG);
+ fragment.setUserVisibleHint(true);
+ fragment.onVisible();
+ }
}
private void showFragment(@NonNull Fragment fragment, String tag) {
@@ -1342,13 +1393,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
Fragment speedDial = fragmentManager.findFragmentByTag(SPEED_DIAL_TAG);
Fragment oldCallLog = fragmentManager.findFragmentByTag(CALL_LOG_TAG);
Fragment contacts = fragmentManager.findFragmentByTag(CONTACTS_TAG);
- Fragment voicemail = fragmentManager.findFragmentByTag(VOICEMAIL_TAG);
+ Fragment oldVoicemail = fragmentManager.findFragmentByTag(VOICEMAIL_TAG);
FragmentTransaction transaction = fragmentManager.beginTransaction();
boolean fragmentShown = showIfEqualElseHide(transaction, fragment, speedDial);
fragmentShown |= showIfEqualElseHide(transaction, fragment, oldCallLog);
fragmentShown |= showIfEqualElseHide(transaction, fragment, contacts);
- fragmentShown |= showIfEqualElseHide(transaction, fragment, voicemail);
+ fragmentShown |= showIfEqualElseHide(transaction, fragment, oldVoicemail);
if (!fragmentShown && fragment != null) {
LogUtil.i(
@@ -1361,11 +1412,16 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
// TODO(calderwoodra): Handle other new fragments.
android.support.v4.app.Fragment newCallLog =
supportFragmentManager.findFragmentByTag(CALL_LOG_TAG);
+ android.support.v4.app.Fragment newVoicemail =
+ supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG);
android.support.v4.app.FragmentTransaction supportTransaction =
supportFragmentManager.beginTransaction();
boolean supportFragmentShown =
showIfEqualElseHideSupport(supportTransaction, supportFragment, newCallLog);
+ supportFragmentShown |=
+ showIfEqualElseHideSupport(supportTransaction, supportFragment, newVoicemail);
+
if (!supportFragmentShown && supportFragment != null) {
LogUtil.i(
"MainBottomNavBarBottomNavTabListener.showFragment",