Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d5b1180 authored by Samuel Fufa's avatar Samuel Fufa
Browse files

Revert PredictionRow shuoldDraw check

+ Show Rounded play result icons

Bug: 168805872
Test: Manual
Change-Id: I663c7f7ca1f1ac072e5e9c441deabef7c3fbd97b
parent 86f8df6c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ public class PredictionRowView extends LinearLayout implements

    @Override
    public boolean shouldDraw() {
        return getVisibility() == VISIBLE;
        return getVisibility() != GONE;
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ public class AllAppsSearchBarController
    @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;
+38 −3
Original line number Diff line number Diff line
@@ -21,6 +21,11 @@ import android.content.Context;
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.Launcher;
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 @@ import java.net.URL;
 */
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 @@ public class SearchResultPlayItem extends LinearLayout implements
    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 @@ public class SearchResultPlayItem extends LinearLayout implements
//        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 @@ public class SearchResultPlayItem extends LinearLayout implements
                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 @@ public class SearchResultPlayItem extends LinearLayout implements
        });
    }


    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;