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

Commit ef7cb2c0 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Fix size of parcelled TextClassification icons.

Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationTest
Change-Id: I02d659c127ebccb16d0150b7b70587a9d786331e
parent bcaeb104
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
@@ -378,7 +379,7 @@ public final class TextClassification implements Parcelable {
        final List<Drawable> drawables = new ArrayList<>(bitmaps.size());
        for (Bitmap bitmap : bitmaps) {
            if (bitmap != null) {
                drawables.add(new BitmapDrawable(null, bitmap));
                drawables.add(new BitmapDrawable(Resources.getSystem(), bitmap));
            } else {
                drawables.add(null);
            }
@@ -681,7 +682,8 @@ public final class TextClassification implements Parcelable {
    private TextClassification(Parcel in) {
        mText = in.readString();
        mPrimaryIcon = in.readInt() == 0
                ? null : new BitmapDrawable(null, Bitmap.CREATOR.createFromParcel(in));
                ? null
                : new BitmapDrawable(Resources.getSystem(), Bitmap.CREATOR.createFromParcel(in));
        mPrimaryLabel = in.readString();
        mPrimaryIntent = in.readInt() == 0 ? null : Intent.CREATOR.createFromParcel(in);
        mPrimaryOnClickListener = null;  // not parcelable
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view.textclassifier;
import static org.junit.Assert.assertEquals;

import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
@@ -47,7 +48,7 @@ public class TextClassificationTest {
            colors[i] = colorValue;
        }
        final Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888);
        final BitmapDrawable drawable = new BitmapDrawable(null, bitmap);
        final BitmapDrawable drawable = new BitmapDrawable(Resources.getSystem(), bitmap);
        drawable.setTargetDensity(bitmap.getDensity());
        return drawable;
    }