Skip to content

Commit

Permalink
Fab now hides/shows correctly when you enter and leave the voicemail …
Browse files Browse the repository at this point in the history
…tab.

Test: manual, going between tabs hides/shows the fab properly when ToS is (in)visible.
PiperOrigin-RevId: 187253210
Change-Id: Ied9ea44892786268b9dfa68816840dfbfc74aa6e
  • Loading branch information
calderwoodra authored and Copybara-Service committed Feb 28, 2018
1 parent 27b963f commit 311c525
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion java/com/android/dialer/app/calllog/CallLogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ void markMissedCallsAsReadAndRemoveNotifications() {
@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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void fetchCalls() {
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);
Expand Down
37 changes: 30 additions & 7 deletions java/com/android/dialer/main/impl/OldMainActivityPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ private void initLayout(Bundle savedInstanceState) {

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);
Expand Down Expand Up @@ -674,6 +675,7 @@ public void showDialpad() {

@Override
public void enableFloatingButton(boolean enabled) {
LogUtil.i("MainCallLogHost.enableFloatingButton", "enabled: " + enabled);
if (enabled) {
fab.show();
} else {
Expand Down Expand Up @@ -972,7 +974,10 @@ private void showRemoveView(boolean show) {

/**
* Implementation of {@link OnBottomNavTabSelectedListener} that handles logic for showing each of
* the main tabs.
* the main tabs and FAB.
*
* <p>TODO(calderwoodra, uabdullah): Rethink the logic for showing/hiding the FAB when new
* voicemail is ready.
*/
private static final class MainBottomNavBarBottomNavTabListener
implements OnBottomNavTabSelectedListener {
Expand All @@ -982,17 +987,22 @@ private static final class MainBottomNavBarBottomNavTabListener
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;
Expand All @@ -1007,10 +1017,12 @@ public void onSpeedDialSelected() {
} 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;
Expand All @@ -1025,10 +1037,12 @@ public void onCallLogSelected() {
} 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;
Expand All @@ -1047,10 +1061,12 @@ public void onContactsSelected() {
} 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;
Expand All @@ -1059,13 +1075,16 @@ public void onVoicemailSelected() {
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() {
Expand All @@ -1082,7 +1101,11 @@ private void hideAllFragments() {
}
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();
}
Expand Down

0 comments on commit 311c525

Please sign in to comment.