From 311c5250451bf5985761690568e3e70ca3b28664 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 27 Feb 2018 16:43:37 -0800 Subject: Fab now hides/shows correctly when you enter and leave the voicemail tab. Test: manual, going between tabs hides/shows the fab properly when ToS is (in)visible. PiperOrigin-RevId: 187253210 Change-Id: Ied9ea44892786268b9dfa68816840dfbfc74aa6e --- .../dialer/app/calllog/CallLogFragment.java | 2 +- .../calllog/VisualVoicemailCallLogFragment.java | 2 +- .../dialer/main/impl/OldMainActivityPeer.java | 37 ++++++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index d8496f106..11c249944 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -626,7 +626,7 @@ public class CallLogFragment extends Fragment @CallSuper public void onVisible() { LogUtil.enterBlock("CallLogFragment.onPageSelected"); - if (getActivity() != null && getActivity() instanceof HostInterface) { + if (getActivity() != null && FragmentUtils.getParent(this, HostInterface.class) != null) { FragmentUtils.getParentUnsafe(this, HostInterface.class) .enableFloatingButton(!isModalAlertVisible()); } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 8b504737b..f1ede8908 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -158,7 +158,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { public void onVisible() { LogUtil.enterBlock("VisualVoicemailCallLogFragment.onVisible"); super.onVisible(); - if (getActivity() != null) { + if (getActivity() != null && preSyncVoicemailStatusCheckExecutor != null) { preSyncVoicemailStatusCheckExecutor.executeParallel(getActivity()); Logger.get(getActivity()).logImpression(DialerImpression.Type.VVM_TAB_VIEWED); getActivity().setVolumeControlStream(VoicemailAudioManager.PLAYBACK_STREAM); diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 9ceea28bf..70ecb8360 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -201,7 +201,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen bottomNav = mainActivity.findViewById(R.id.bottom_nav_bar); MainBottomNavBarBottomNavTabListener bottomNavTabListener = - new MainBottomNavBarBottomNavTabListener(mainActivity, mainActivity.getFragmentManager()); + new MainBottomNavBarBottomNavTabListener( + mainActivity, mainActivity.getFragmentManager(), fab); bottomNav.addOnTabSelectedListener(bottomNavTabListener); // TODO(uabdullah): Handle case of when a sim is inserted/removed while the activity is open. boolean showVoicemailTab = canVoicemailTabBeShown(mainActivity); @@ -674,6 +675,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen @Override public void enableFloatingButton(boolean enabled) { + LogUtil.i("MainCallLogHost.enableFloatingButton", "enabled: " + enabled); if (enabled) { fab.show(); } else { @@ -972,7 +974,10 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen /** * Implementation of {@link OnBottomNavTabSelectedListener} that handles logic for showing each of - * the main tabs. + * the main tabs and FAB. + * + *

TODO(calderwoodra, uabdullah): Rethink the logic for showing/hiding the FAB when new + * voicemail is ready. */ private static final class MainBottomNavBarBottomNavTabListener implements OnBottomNavTabSelectedListener { @@ -982,17 +987,22 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private static final String CONTACTS_TAG = "contacts"; private static final String VOICEMAIL_TAG = "voicemail"; - private final FragmentManager fragmentManager; private final Context context; + private final FragmentManager fragmentManager; + private final FloatingActionButton fab; + @TabIndex private int selectedTab = -1; - private MainBottomNavBarBottomNavTabListener(Context context, FragmentManager fragmentManager) { - this.fragmentManager = fragmentManager; + private MainBottomNavBarBottomNavTabListener( + Context context, FragmentManager fragmentManager, FloatingActionButton fab) { this.context = context; + this.fragmentManager = fragmentManager; + this.fab = fab; } @Override public void onSpeedDialSelected() { + LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onSpeedDialSelected"); if (selectedTab != TabIndex.SPEED_DIAL) { Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_FAVORITE); selectedTab = TabIndex.SPEED_DIAL; @@ -1007,10 +1017,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } else { fragmentManager.beginTransaction().show(fragment).commit(); } + fab.show(); } @Override public void onCallLogSelected() { + LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onCallLogSelected"); if (selectedTab != TabIndex.CALL_LOG) { Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CALL_LOG); selectedTab = TabIndex.CALL_LOG; @@ -1025,10 +1037,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } else { fragmentManager.beginTransaction().show(fragment).commit(); } + fab.show(); } @Override public void onContactsSelected() { + LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onContactsSelected"); if (selectedTab != TabIndex.CONTACTS) { Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_CONTACTS); selectedTab = TabIndex.CONTACTS; @@ -1047,10 +1061,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } else { fragmentManager.beginTransaction().show(fragment).commit(); } + fab.show(); } @Override public void onVoicemailSelected() { + LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onVoicemailSelected"); if (selectedTab != TabIndex.VOICEMAIL) { Logger.get(context).logImpression(DialerImpression.Type.NUI_SWITCH_TAB_TO_VOICEMAIL); selectedTab = TabIndex.VOICEMAIL; @@ -1059,13 +1075,16 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen VisualVoicemailCallLogFragment fragment = (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG); if (fragment == null) { + fragment = new VisualVoicemailCallLogFragment(); fragmentManager .beginTransaction() - .add(R.id.fragment_container, new VisualVoicemailCallLogFragment(), VOICEMAIL_TAG) + .add(R.id.fragment_container, fragment, VOICEMAIL_TAG) .commit(); } else { fragmentManager.beginTransaction().show(fragment).commit(); } + fragment.setUserVisibleHint(true); + fragment.onVisible(); } private void hideAllFragments() { @@ -1082,7 +1101,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } if (fragmentManager.findFragmentByTag(VOICEMAIL_TAG) != null) { // Old VisualVoicemailFragment - transaction.hide(fragmentManager.findFragmentByTag(VOICEMAIL_TAG)); + VisualVoicemailCallLogFragment fragment = + (VisualVoicemailCallLogFragment) fragmentManager.findFragmentByTag(VOICEMAIL_TAG); + fragment.setUserVisibleHint(false); + fragment.onNotVisible(); + transaction.hide(fragment); } transaction.commit(); } -- cgit v1.2.3