DO NOT MERGE Make labels view have grey app bar

Bug: 31268067

Test: manual
  - navigate b/w fragments + rotate screen
  - create a new label and delete a label
  - enter/exit edit mode of group fragment and contacts fragment

Change-Id: Ie4bc38456dae8840df3ae511c2fbbd0d336038bc
(cherry picked from commit 3dd13761f1c2c615004af129afa5ebc56efe8ada)
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index b810eec..3fc3c9d 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -54,6 +54,7 @@
 import com.android.contacts.common.util.AccountFilterUtil;
 import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
 import com.android.contacts.common.util.ImplicitIntentsUtil;
+import com.android.contacts.common.util.MaterialColorMapUtils;
 import com.android.contacts.common.util.ViewUtil;
 import com.android.contacts.editor.ContactEditorFragment;
 import com.android.contacts.editor.SelectAccountDialogFragment;
@@ -134,6 +135,7 @@
             // another fragment in navigation drawer, the current search/selection mode will be
             // overlaid by the action bar of the newly-created fragment.
             stopSearchAndSelection();
+            updateStatusBarBackground();
         }
 
         private void stopSearchAndSelection() {
@@ -170,7 +172,7 @@
             super.onDrawerStateChanged(newState);
             // Set transparent status bar when drawer starts to move.
             if (newState != DrawerLayout.STATE_IDLE) {
-                makeStatusBarTransparent();
+                updateStatusBarBackground();
             }
             if (mRunnable != null && newState == DrawerLayout.STATE_IDLE) {
                 mRunnable.run();
@@ -285,17 +287,23 @@
     protected void onResume() {
         super.onResume();
         if (mDrawer.isDrawerOpen(GravityCompat.START)) {
-            makeStatusBarTransparent();
+            updateStatusBarBackground();
         }
     }
 
-    private void makeStatusBarTransparent() {
-        // Avoid making status bar transparent when action bar's selection mode is on.
-        if (getWindow().getStatusBarColor() !=
-                ContextCompat.getColor(this, R.color.contextual_selection_bar_status_bar_color)
-                        && CompatUtils.isLollipopCompatible()) {
-            getWindow().setStatusBarColor(Color.TRANSPARENT);
+    public void updateStatusBarBackground() {
+        updateStatusBarBackground(/* color */ -1);
+    }
+
+    public void updateStatusBarBackground(int color) {
+        if (!CompatUtils.isLollipopCompatible()) return;
+        if (color == -1) {
+            mDrawer.setStatusBarBackgroundColor(MaterialColorMapUtils.getStatusBarColor(this));
+        } else {
+            mDrawer.setStatusBarBackgroundColor(color);
         }
+        mDrawer.invalidate();
+        getWindow().setStatusBarColor(Color.TRANSPARENT);
     }
 
     // Set up fragment manager to load groups and filters.
@@ -417,7 +425,7 @@
         return null;
     }
 
-    protected boolean isGroupView() {
+    public boolean isGroupView() {
         return mCurrentView == ContactsView.GROUP_VIEW;
     }