Revert PredictionRow shuoldDraw check
+ Show Rounded play result icons
Bug: 168805872
Test: Manual
Change-Id: I663c7f7ca1f1ac072e5e9c441deabef7c3fbd97b
diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
index b5ba8a6..dbdfd8d 100644
--- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java
@@ -184,7 +184,7 @@
@Override
public boolean shouldDraw() {
- return getVisibility() == VISIBLE;
+ return getVisibility() != GONE;
}
@Override
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index d7fa5bc..82c4db4 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -114,7 +114,7 @@
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
- if (actionId == EditorInfo.IME_ACTION_SEARCH) {
+ if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) {
// selectFocusedView should return SearchTargetEvent that is passed onto onClick
if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) {
return true;
diff --git a/src/com/android/launcher3/views/SearchResultPlayItem.java b/src/com/android/launcher3/views/SearchResultPlayItem.java
index ff3ecc8..d05a29e 100644
--- a/src/com/android/launcher3/views/SearchResultPlayItem.java
+++ b/src/com/android/launcher3/views/SearchResultPlayItem.java
@@ -21,6 +21,11 @@
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
@@ -38,6 +43,7 @@
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
+import com.android.launcher3.icons.BitmapRenderer;
import com.android.systemui.plugins.AllAppsSearchPlugin;
import com.android.systemui.plugins.shared.SearchTarget;
import com.android.systemui.plugins.shared.SearchTargetEvent;
@@ -50,6 +56,10 @@
*/
public class SearchResultPlayItem extends LinearLayout implements
AllAppsSearchBarController.PayloadResultHandler<Bundle> {
+
+ private static final int BITMAP_CROP_MASK_COLOR = 0xff424242;
+ private static final float ICON_RADIUS_FACTOR = .5f;
+
private final DeviceProfile mDeviceProfile;
private View mIconView;
private TextView mTitleView;
@@ -60,6 +70,8 @@
private AllAppsSearchPlugin mPlugin;
private final Object[] mTargetInfo = createTargetInfo();
+ final Paint mIconPaint = new Paint();
+
public SearchResultPlayItem(Context context) {
this(context, null, 0);
@@ -109,7 +121,6 @@
// TODO: Should use a generic type to get values b/165320033
showIfNecessary(mDetailViews[0], bundle.getString("price"));
showIfNecessary(mDetailViews[1], bundle.getString("rating"));
- showIfNecessary(mDetailViews[2], bundle.getString("category"));
mIconView.setBackgroundResource(R.drawable.ic_deepshortcut_placeholder);
UI_HELPER_EXECUTOR.execute(() -> {
@@ -118,8 +129,9 @@
URL url = new URL(bundle.getString("icon_url"));
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
- Bitmap.createScaledBitmap(bitmap, mDeviceProfile.allAppsIconSizePx,
- mDeviceProfile.allAppsIconSizePx, false));
+ Bitmap.createScaledBitmap(getRoundedBitmap(bitmap),
+ mDeviceProfile.allAppsIconSizePx, mDeviceProfile.allAppsIconSizePx,
+ false));
mIconView.post(() -> mIconView.setBackground(bitmapDrawable));
} catch (IOException e) {
e.printStackTrace();
@@ -127,6 +139,29 @@
});
}
+
+ private Bitmap getRoundedBitmap(Bitmap bitmap) {
+ int iconSize = bitmap.getWidth();
+
+ Bitmap output = BitmapRenderer.createHardwareBitmap(iconSize, iconSize, (canvas) -> {
+ final Rect rect = new Rect(0, 0, iconSize, iconSize);
+ final RectF rectF = new RectF(rect);
+
+ mIconPaint.setAntiAlias(true);
+ canvas.drawARGB(0, 0, 0, 0);
+ mIconPaint.setColor(BITMAP_CROP_MASK_COLOR);
+ int radius = (int) (iconSize * ICON_RADIUS_FACTOR);
+ canvas.drawRoundRect(rectF, radius, radius, mIconPaint);
+
+ mIconPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
+ canvas.drawBitmap(bitmap, rect, rect, mIconPaint);
+ });
+
+ return output;
+
+ }
+
+
@Override
public Object[] getTargetInfo() {
return mTargetInfo;