Merge "Cancel Old SpeedDial contact loaders when they are reset."
diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
index 3b27d31..3739588 100644
--- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
+++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
@@ -32,7 +32,6 @@
 import com.android.dialer.callintent.CallInitiationType;
 import com.android.dialer.callintent.CallSpecificAppData;
 import com.android.dialer.callintent.SpeedDialContactType;
-import com.android.dialer.common.LogUtil;
 import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest;
 import com.android.dialer.lettertile.LetterTileDrawable;
 import com.android.dialer.logging.InteractionEvent;
@@ -192,21 +191,17 @@
     this.position = position;
   }
 
+  private ContactLoader loader;
+
   /**
    * Send a notification using a {@link ContactLoader} to inform the sync adapter that we are
    * viewing a particular contact, so that it can download the high-res photo.
    */
-  private static void sendViewNotification(Context context, Uri contactUri) {
-    ContactLoader loader = new ContactLoader(context, contactUri, true /* postViewNotification */);
-    loader.registerListener(
-        0,
-        (loader1, contact) -> {
-          try {
-            loader1.reset();
-          } catch (RuntimeException e) {
-            LogUtil.e("PhoneFavoriteTileView.onLoadComplete", "error resetting loader", e);
-          }
-        });
+  private void sendViewNotification(Context context, Uri contactUri) {
+    if (loader != null) {
+      loader.cancelLoad();
+    }
+    loader = new ContactLoader(context, contactUri, true /* postViewNotification */);
     loader.startLoading();
   }
 }
diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java
index 2c1b4f5..2519d23 100644
--- a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java
+++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java
@@ -29,6 +29,7 @@
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import com.android.dialer.common.Assert;
+import com.android.dialer.configprovider.ConfigProviderBindings;
 
 /** Navigation item in a bottom nav. */
 final class BottomNavItem extends LinearLayout {
@@ -68,7 +69,17 @@
     if (count == 0) {
       notificationBadge.setVisibility(View.INVISIBLE);
     } else {
-      String countString = count > 99 ? "99+" : String.format(Integer.toString(count));
+      String countString = String.format(Integer.toString(count));
+
+      boolean use99PlusCount =
+          ConfigProviderBindings.get(getContext()).getBoolean("use_99_plus", false);
+      boolean use9Plus = !use99PlusCount;
+
+      if (use99PlusCount && count > 99) {
+        countString = getContext().getString(R.string.bottom_nav_count_99_plus);
+      } else if (use9Plus && count > 9) {
+        countString = getContext().getString(R.string.bottom_nav_count_9_plus);
+      }
       notificationBadge.setVisibility(View.VISIBLE);
       notificationBadge.setText(countString);
 
diff --git a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml
index 5dddd3d..d319b2e 100644
--- a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml
+++ b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml
@@ -32,7 +32,7 @@
         android:id="@+id/bottom_nav_item_image"
         android:layout_width="24dp"
         android:layout_height="24dp"
-        android:layout_marginTop="7dp"/>
+        android:layout_marginTop="4dp"/>
 
     <TextView
         android:id="@+id/notification_badge"
diff --git a/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml b/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml
index ca5db1f..6d38869 100644
--- a/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml
+++ b/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml
@@ -23,4 +23,10 @@
   <string name="tab_title_voicemail">Voicemail</string>
   <!-- Tab text to show users their contacts  [CHAR LIMIT=10] -->
   <string name="tab_title_contacts">Contacts</string>
+
+  <!-- Notification badge indicating that there are more than 9 notifications for the user [CHAR LIMIT=3] -->
+  <string name="bottom_nav_count_9_plus">9+</string>
+
+  <!-- Notification badge indicating that there are more than 9 notifications for the user [CHAR LIMIT=3] -->
+  <string name="bottom_nav_count_99_plus">99+</string>
 </resources>
\ No newline at end of file
diff --git a/java/com/android/dialer/main/impl/res/values-v27/styles.xml b/java/com/android/dialer/main/impl/res/values-v27/styles.xml
index c91cba2..86e6f28 100644
--- a/java/com/android/dialer/main/impl/res/values-v27/styles.xml
+++ b/java/com/android/dialer/main/impl/res/values-v27/styles.xml
@@ -20,7 +20,7 @@
   <style name="NuiActivityTheme" parent="NuiActivityThemeBase">
     <!-- Used to change the navigation bar color -->
     <item name="android:windowLightNavigationBar">true</item>
-    <item name="android:navigationBarColor">?android:windowBackground</item>
+    <item name="android:navigationBarColor">@color/background_dialer_white</item>
     <item name="android:navigationBarDividerColor">#E0E0E0</item>
   </style>
 </resources>
\ No newline at end of file
diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
index 37ffb97..78cabf7 100644
--- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
+++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
@@ -133,6 +133,7 @@
               searchBox.setText(text.get());
             }
             searchBox.requestFocus();
+            setBackgroundResource(R.drawable.search_bar_background);
           }
         });
     animator.start();
@@ -164,6 +165,7 @@
             super.onAnimationEnd(animation);
             searchBox.setText("");
             searchBoxExpanded.setVisibility(INVISIBLE);
+            setBackgroundResource(R.drawable.search_bar_background_rounded_corners);
           }
         });
     animator.start();
diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml
new file mode 100644
index 0000000..8767057
--- /dev/null
+++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2018 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+  android:shape="rectangle">
+  <solid android:color="@color/background_dialer_white"/>
+</shape>
diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml
similarity index 100%
rename from java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml
rename to java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml
diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
index 378b20f..3ab20c1 100644
--- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
+++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
@@ -28,7 +28,7 @@
       android:layout_height="wrap_content"
       android:layout_margin="@dimen/search_bar_margin"
       android:minHeight="@dimen/collapsed_search_bar_height"
-      android:background="@drawable/rounded_corner"
+      android:background="@drawable/search_bar_background_rounded_corners"
       android:elevation="4dp">
 
     <RelativeLayout