From 8074af74464a162e01296cc2b0b707f1c9d12bb7 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Fri, 16 Feb 2018 13:20:56 -0800 Subject: Fix a few UI issues based around multiselect in new nav. - No longer crashes when entering mw-mode while in multiselect - Configuration changes now properly restore bottom nav visibility - toolbar shadow is now only visible in search Bug: 72525324 Test: MainActivityOldPeerSearchIntegrationTest PiperOrigin-RevId: 186037379 Change-Id: I5fc00c8091e85fc67482b2131944fb776626d06f --- .../android/dialer/app/calllog/CallLogFragment.java | 15 +++++++++++++-- .../dialer/main/impl/MainSearchController.java | 16 +++++++++------- .../android/dialer/main/impl/OldMainActivityPeer.java | 19 +++++++++++++++---- .../dialer/main/impl/res/layout/main_activity.xml | 4 +++- 4 files changed, 40 insertions(+), 14 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 7f635dbca..6b6b92297 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -661,8 +661,19 @@ public class CallLogFragment extends Fragment multiSelectUnSelectAllViewContent.setVisibility(show ? View.VISIBLE : View.GONE); multiSelectUnSelectAllViewContent.setAlpha(show ? 0 : 1); multiSelectUnSelectAllViewContent.animate().alpha(show ? 1 : 0).start(); - FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class) - .showMultiSelectRemoveView(show); + if (show) { + FragmentUtils.getParentUnsafe(this, CallLogFragmentListener.class) + .showMultiSelectRemoveView(true); + } else { + // This method is called after onDestroy. In DialtactsActivity, ListsFragment implements this + // interface and never goes away with configuration changes so this is safe. MainActivity + // removes that extra layer though, so we need to check if the parent is still there. + CallLogFragmentListener listener = + FragmentUtils.getParent(this, CallLogFragmentListener.class); + if (listener != null) { + listener.showMultiSelectRemoveView(false); + } + } } @Override diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 9b734f40c..8d9e784a7 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -68,8 +68,7 @@ import java.util.ArrayList; public class MainSearchController implements SearchBarListener { private static final String KEY_IS_FAB_HIDDEN = "is_fab_hidden"; - private static final String KEY_CURRENT_TAB = "current_tab"; - private static final String KEY_BOTTOM_NAV_VISIBILITY = "bottom_nav_visibility"; + private static final String KEY_TOOLBAR_SHADOW_VISIBILITY = "toolbar_shadow_visibility"; private static final String KEY_IS_TOOLBAR_EXPANDED = "is_toolbar_expanded"; private static final String KEY_IS_TOOLBAR_SLIDE_UP = "is_toolbar_slide_up"; @@ -80,16 +79,19 @@ public class MainSearchController implements SearchBarListener { private final BottomNavBar bottomNav; private final FloatingActionButton fab; private final MainToolbar toolbar; + private final View toolbarShadow; public MainSearchController( MainActivity mainActivity, BottomNavBar bottomNav, FloatingActionButton fab, - MainToolbar toolbar) { + MainToolbar toolbar, + View toolbarShadow) { this.mainActivity = mainActivity; this.bottomNav = bottomNav; this.fab = fab; this.toolbar = toolbar; + this.toolbarShadow = toolbarShadow; } /** Should be called if we're showing the dialpad because of a new ACTION_DIAL intent. */ @@ -266,6 +268,7 @@ public class MainSearchController implements SearchBarListener { } showBottomNav(); toolbar.collapse(animate); + toolbarShadow.setVisibility(View.GONE); mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); // Clear the dialpad so the phone number isn't persisted between search sessions. @@ -319,6 +322,7 @@ public class MainSearchController implements SearchBarListener { fab.hide(); toolbar.expand(/* animate=*/ true, query); toolbar.showKeyboard(); + toolbarShadow.setVisibility(View.VISIBLE); hideBottomNav(); FragmentTransaction transaction = mainActivity.getFragmentManager().beginTransaction(); @@ -396,15 +400,13 @@ public class MainSearchController implements SearchBarListener { public void onSaveInstanceState(Bundle bundle) { bundle.putBoolean(KEY_IS_FAB_HIDDEN, !fab.isShown()); - bundle.putInt(KEY_CURRENT_TAB, bottomNav.getSelectedTab()); - bundle.putInt(KEY_BOTTOM_NAV_VISIBILITY, bottomNav.getVisibility()); + bundle.putInt(KEY_TOOLBAR_SHADOW_VISIBILITY, toolbarShadow.getVisibility()); bundle.putBoolean(KEY_IS_TOOLBAR_EXPANDED, toolbar.isExpanded()); bundle.putBoolean(KEY_IS_TOOLBAR_SLIDE_UP, toolbar.isSlideUp()); } public void onRestoreInstanceState(Bundle savedInstanceState) { - bottomNav.selectTab(savedInstanceState.getInt(KEY_CURRENT_TAB)); - bottomNav.setVisibility(savedInstanceState.getInt(KEY_BOTTOM_NAV_VISIBILITY)); + toolbarShadow.setVisibility(savedInstanceState.getInt(KEY_TOOLBAR_SHADOW_VISIBILITY)); if (savedInstanceState.getBoolean(KEY_IS_FAB_HIDDEN, false)) { fab.hide(); } diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 07c7185ae..7d9216c3f 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -196,7 +196,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen mainActivity, mainActivity.getContentResolver(), bottomNav, toolbar); bottomNav.addOnTabSelectedListener(callLogFragmentListener); - searchController = getNewMainSearchController(bottomNav, fab, toolbar); + searchController = + getNewMainSearchController( + bottomNav, fab, toolbar, mainActivity.findViewById(R.id.toolbar_shadow)); toolbar.setSearchBarListener(searchController); onDialpadQueryChangedListener = getNewOnDialpadQueryChangedListener(searchController); @@ -284,6 +286,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen .getDatabaseHelper(mainActivity) .startSmartDialUpdateThread(forceUpdate); showPostCallPrompt(); + + if (searchController.isInSearch() + || callLogAdapterOnActionModeStateChangedListener.isActionModeStateEnabled()) { + bottomNav.setVisibility(View.GONE); + } else { + bottomNav.setVisibility(View.VISIBLE); + } } @Override @@ -375,8 +384,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } public MainSearchController getNewMainSearchController( - BottomNavBar bottomNavBar, FloatingActionButton fab, MainToolbar mainToolbar) { - return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar); + BottomNavBar bottomNavBar, + FloatingActionButton fab, + MainToolbar mainToolbar, + View toolbarShadow) { + return new MainSearchController(mainActivity, bottomNavBar, fab, mainToolbar, toolbarShadow); } public MainOnDialpadQueryChangedListener getNewOnDialpadQueryChangedListener( @@ -482,7 +494,6 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } /** @see CallLogAdapter.OnActionModeStateChangedListener */ - // TODO(calderwoodra): What is the purpose of this listener? private static final class MainCallLogAdapterOnActionModeStateChangedListener implements CallLogAdapter.OnActionModeStateChangedListener { diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index d8b13a6c2..4f0284126 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -68,11 +68,13 @@ layout="@layout/toolbar_layout"/> + android:layout_below="@+id/toolbar" + android:visibility="gone"/> -- cgit v1.2.3