Merge "Fix size of parcelled TextClassification icons."

This commit is contained in:
TreeHugger Robot
2018-02-12 12:17:58 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -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;
}