Merge "Removing tracing for a gone flake" into ub-launcher3-master
diff --git a/res/drawable/ic_allapps_search.xml b/res/drawable/ic_allapps_search.xml
index 2aeb947..c0e20f1 100644
--- a/res/drawable/ic_allapps_search.xml
+++ b/res/drawable/ic_allapps_search.xml
@@ -19,6 +19,6 @@
     android:viewportHeight="24.0"
     android:viewportWidth="24.0">
     <path
-        android:fillColor="?android:attr/colorAccent"
+        android:fillColor="?android:attr/textColorTertiary"
         android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
 </vector>
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 67ec664..0041c9a 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2016 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.
@@ -16,8 +15,7 @@
 <!-- The top and bottom paddings are defined in this container, but since we want
      the list view to span the full width (for touch interception purposes), we
      will bake the left/right padding into that view's background itself. -->
-<com.android.launcher3.allapps.LauncherAllAppsContainerView
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.allapps.LauncherAllAppsContainerView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/apps_view"
     android:theme="?attr/allAppsTheme"
     android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6ab8150..6c58c0e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -59,7 +59,7 @@
     <!-- Search bar text in the apps view. [CHAR_LIMIT=50] -->
     <string name="all_apps_search_bar_hint">Search apps</string>
     <!-- Search bar text in the apps view. [CHAR_LIMIT=50] -->
-    <string name="all_apps_on_device_search_bar_hint">Search this phone and more...</string>
+    <string name="all_apps_on_device_search_bar_hint">Search this phone and more…</string>
     <!-- Loading apps text. [CHAR_LIMIT=50] -->
     <string name="all_apps_loading_message">Loading apps&#8230;</string>
     <!-- No-search-results text. [CHAR_LIMIT=50] -->
diff --git a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
index 0214c35..f2a1f85 100644
--- a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
+++ b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
@@ -101,8 +101,8 @@
      * Handles grouping and drawing of items in the same all apps sections.
      */
     public static class SectionDecorationHandler {
-        private static final int FILL_ALPHA = (int) (.3f * 255);
-        private static final int FOCUS_ALPHA = (int) (.8f * 255);
+        private static final int FILL_ALPHA = 0;
+        private static final int FOCUS_ALPHA = (int) (.9f * 255);
 
         protected RectF mBounds = new RectF();
         private final boolean mIsFullWidth;
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index 77cec80..15ff2f5 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -42,7 +42,7 @@
  */
 public class ScrimView<T extends Launcher> extends View implements Insettable, OnChangeListener {
 
-    private static final float SCRIM_ALPHA = .75f;
+    private static final float SCRIM_ALPHA = .8f;
     protected final T mLauncher;
     private final WallpaperColorInfo mWallpaperColorInfo;
     protected final int mEndScrim;
diff --git a/src/com/android/launcher3/views/SearchResultPeopleView.java b/src/com/android/launcher3/views/SearchResultPeopleView.java
index 0c9a22f..f20b080 100644
--- a/src/com/android/launcher3/views/SearchResultPeopleView.java
+++ b/src/com/android/launcher3/views/SearchResultPeopleView.java
@@ -23,9 +23,12 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
+import android.graphics.Canvas;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
+import android.os.Build;
 import android.os.Bundle;
+import android.os.Process;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.ImageButton;
@@ -41,7 +44,8 @@
 import com.android.launcher3.R;
 import com.android.launcher3.allapps.AllAppsGridAdapter;
 import com.android.launcher3.allapps.search.AllAppsSearchBarController;
-import com.android.launcher3.util.Themes;
+import com.android.launcher3.icons.BitmapInfo;
+import com.android.launcher3.icons.LauncherIcons;
 import com.android.systemui.plugins.AllAppsSearchPlugin;
 import com.android.systemui.plugins.shared.SearchTarget;
 import com.android.systemui.plugins.shared.SearchTargetEvent;
@@ -105,15 +109,14 @@
         mPlugin = adapterItemWithPayload.getPlugin();
         mTitleView.setText(payload.getString("title"));
         mIntent = payload.getParcelable("intent");
-        Bitmap icon = payload.getParcelable("icon");
-        if (icon != null) {
-            RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
-            float radius = Themes.getDialogCornerRadius(getContext());
-            d.setCornerRadius(radius);
-            d.setBounds(0, 0, mIconSize, mIconSize);
-            BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
-                    Bitmap.createScaledBitmap(icon, mIconSize, mIconSize, false));
-            mIconView.setBackground(d);
+        Bitmap contactIcon = payload.getParcelable("icon");
+        try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
+            BitmapInfo badgeInfo = li.createBadgedIconBitmap(
+                    getAppIcon(mIntent.getPackage()), Process.myUserHandle(),
+                    Build.VERSION.SDK_INT);
+            setIcon(li.badgeBitmap(roundBitmap(contactIcon), badgeInfo).icon, false);
+        } catch (Exception e) {
+            setIcon(contactIcon, true);
         }
 
         ArrayList<Bundle> providers = payload.getParcelableArrayList("providers");
@@ -123,17 +126,14 @@
                 Bundle provider = providers.get(i);
                 Intent intent = provider.getParcelable("intent");
                 setupProviderButton(button, provider, intent, adapterItemWithPayload);
-                String pkg = provider.getString("package_name");
                 UI_HELPER_EXECUTOR.post(() -> {
-                    try {
-                        ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
-                                pkg, 0);
-                        Drawable appIcon = applicationInfo.loadIcon(mPackageManager);
+                    String pkg = provider.getString("package_name");
+                    Drawable appIcon = getAppIcon(pkg);
+                    if (appIcon != null) {
                         MAIN_EXECUTOR.post(() -> button.setImageDrawable(appIcon));
-                    } catch (PackageManager.NameNotFoundException ignored) {
                     }
-
                 });
+                button.setVisibility(VISIBLE);
             } else {
                 button.setVisibility(GONE);
             }
@@ -141,6 +141,45 @@
         adapterItemWithPayload.setSelectionHandler(this::handleSelection);
     }
 
+    /**
+     *  Normalizes the bitmap to look like rounded App Icon
+     *  TODO(b/170234747) to support styling, generate adaptive icon drawable and generate
+     *  bitmap from it.
+     */
+    private Bitmap roundBitmap(Bitmap icon) {
+        final RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
+        d.setCornerRadius(R.attr.folderIconRadius);
+        d.setBounds(0, 0, mIconSize, mIconSize);
+        final Bitmap bitmap = Bitmap.createBitmap(d.getBounds().width(), d.getBounds().height(),
+                Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+        d.draw(canvas);
+        return bitmap;
+    }
+
+    private void setIcon(Bitmap icon, Boolean round) {
+        if (round) {
+            RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
+            d.setCornerRadius(R.attr.folderIconRadius);
+            d.setBounds(0, 0, mIconSize, mIconSize);
+            mIconView.setBackground(d);
+        } else {
+            mIconView.setBackground(new BitmapDrawable(getResources(), icon));
+        }
+    }
+
+
+    private Drawable getAppIcon(String pkg) {
+        try {
+            ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
+                    pkg, 0);
+            return applicationInfo.loadIcon(mPackageManager);
+        } catch (PackageManager.NameNotFoundException ignored) {
+            return null;
+        }
+    }
+
     @Override
     public Object[] getTargetInfo() {
         return mTargetInfo;
@@ -155,7 +194,8 @@
                     SearchTarget.ItemType.PEOPLE,
                     SearchTargetEvent.CHILD_SELECT);
             searchTargetEvent.bundle = new Bundle();
-            searchTargetEvent.bundle.putParcelable("intent", mIntent);
+            searchTargetEvent.bundle.putParcelable("intent", intent);
+            searchTargetEvent.bundle.putString("title", mTitleView.getText().toString());
             searchTargetEvent.bundle.putBundle("provider", provider);
             if (mPlugin != null) {
                 mPlugin.notifySearchTargetEvent(searchTargetEvent);
@@ -172,6 +212,7 @@
                     eventType);
             searchTargetEvent.bundle = new Bundle();
             searchTargetEvent.bundle.putParcelable("intent", mIntent);
+            searchTargetEvent.bundle.putString("title", mTitleView.getText().toString());
             if (mPlugin != null) {
                 mPlugin.notifySearchTargetEvent(searchTargetEvent);
             }