Implemented multiselect in NUI for VisualVoicemailFragment.

This solution has a couple hacks in it because the DialtactsActivity has a
non-support ActionBar and MainActivity has a support Toolbar. When multiselect
is implemented for NewVoicemailFragment, we should be careful to use support
action mode instead of non-support action mode so that the transitions and
styling are seamless and consistent.

Bug: 72722083
Test: manual
PiperOrigin-RevId: 184343414
Change-Id: Id16652de2d0add7b7c304d1cedb429fe9b1cf338
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
index 489de1a..c7410d5 100644
--- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java
+++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
@@ -30,6 +30,7 @@
 import android.provider.ContactsContract.QuickContact;
 import android.support.annotation.Nullable;
 import android.support.design.widget.FloatingActionButton;
+import android.support.v7.widget.Toolbar;
 import android.view.View;
 import android.widget.ImageView;
 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
@@ -159,7 +160,8 @@
     bottomNav.addOnTabSelectedListener(bottomNavTabListener);
 
     callLogFragmentListener =
-        new MainCallLogFragmentListener(mainActivity, mainActivity.getContentResolver(), bottomNav);
+        new MainCallLogFragmentListener(
+            mainActivity, mainActivity.getContentResolver(), bottomNav, toolbar);
     bottomNav.addOnTabSelectedListener(callLogFragmentListener);
 
     searchController = new MainSearchController(mainActivity, bottomNav, fab, toolbar);
@@ -388,16 +390,20 @@
   }
 
   /** @see CallLogAdapter.OnActionModeStateChangedListener */
-  // TODO(a bug): handle multiselect mode
+  // TODO(calderwoodra): What is the purpose of this listener?
   private static final class MainCallLogAdapterOnActionModeStateChangedListener
       implements CallLogAdapter.OnActionModeStateChangedListener {
 
+    private boolean isEnabled;
+
     @Override
-    public void onActionModeStateChanged(boolean isEnabled) {}
+    public void onActionModeStateChanged(boolean isEnabled) {
+      this.isEnabled = isEnabled;
+    }
 
     @Override
     public boolean isActionModeStateEnabled() {
-      return false;
+      return isEnabled;
     }
   }
 
@@ -458,18 +464,23 @@
           OnBottomNavTabSelectedListener {
 
     private final CallLogQueryHandler callLogQueryHandler;
-    private final BottomNavBar bottomNavBar;
     private final Context context;
+    private final BottomNavBar bottomNavBar;
+    private final Toolbar toolbar;
 
     private @TabIndex int currentTab = TabIndex.SPEED_DIAL;
     private long timeSelected = -1;
     private boolean activityIsAlive;
 
     MainCallLogFragmentListener(
-        Context context, ContentResolver contentResolver, BottomNavBar bottomNavBar) {
+        Context context,
+        ContentResolver contentResolver,
+        BottomNavBar bottomNavBar,
+        Toolbar toolbar) {
       callLogQueryHandler = new CallLogQueryHandler(context, contentResolver, this);
-      this.bottomNavBar = bottomNavBar;
       this.context = context;
+      this.bottomNavBar = bottomNavBar;
+      this.toolbar = toolbar;
     }
 
     @Override
@@ -480,7 +491,8 @@
 
     @Override
     public void showMultiSelectRemoveView(boolean show) {
-      // TODO(a bug): handle multiselect mode
+      bottomNavBar.setVisibility(show ? View.GONE : View.VISIBLE);
+      toolbar.setVisibility(show ? View.GONE : View.VISIBLE);
     }
 
     @Override
diff --git a/java/com/android/dialer/main/impl/res/values/styles.xml b/java/com/android/dialer/main/impl/res/values/styles.xml
index 26f880d..2865f25 100644
--- a/java/com/android/dialer/main/impl/res/values/styles.xml
+++ b/java/com/android/dialer/main/impl/res/values/styles.xml
@@ -22,5 +22,21 @@
 
     <!-- Theme needed for DialpadFragment -->
     <item name="dialpad_style">@style/Dialpad.Light</item>
+
+    <!-- Required for actionmode/multiselect to render properly. -->
+    <!-- TODO(calderwoodra): Check to see if we can remove this after NewVoicemailFragment launches -->
+    <item name="actionModeStyle">@style/ActionModeStyle</item>
+    <item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
+  </style>
+
+  <!-- Colors our actionbar in action mode to dialer theme color. -->
+  <style name="ActionModeStyle" parent="@style/Widget.AppCompat.ActionMode">
+    <item name="background">@color/dialer_theme_color</item>
+    <item name="titleTextStyle">@style/ActionModeTitleTextStyle</item>
+  </style>
+
+  <!-- Colors our actionbar text in action mode to dialer white text color. -->
+  <style name="ActionModeTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
+    <item name="android:textColor">@color/dialer_primary_text_color_white</item>
   </style>
 </resources>