Merge "Add more information to the TV PiP notification" into tm-dev am: b6de832709 am: c3a74edbb8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17197863

Change-Id: I22a08cccd3bcca7ecafab5874de7828d8ec4de6d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jacqueline Bronger
2022-05-06 14:20:42 +00:00
committed by Automerger Merge Worker
5 changed files with 318 additions and 74 deletions

View File

@@ -137,6 +137,18 @@ public class ImageUtils {
*/
public static Bitmap buildScaledBitmap(Drawable drawable, int maxWidth,
int maxHeight) {
return buildScaledBitmap(drawable, maxWidth, maxHeight, false);
}
/**
* Convert a drawable to a bitmap, scaled to fit within maxWidth and maxHeight.
*
* @param allowUpscaling if true, the drawable will not only be scaled down, but also scaled up
* to fit within the maximum size given. This is useful for converting
* vectorized icons which usually have a very small intrinsic size.
*/
public static Bitmap buildScaledBitmap(Drawable drawable, int maxWidth,
int maxHeight, boolean allowUpscaling) {
if (drawable == null) {
return null;
}
@@ -155,7 +167,9 @@ public class ImageUtils {
// a large notification icon if necessary
float ratio = Math.min((float) maxWidth / (float) originalWidth,
(float) maxHeight / (float) originalHeight);
ratio = Math.min(1.0f, ratio);
if (!allowUpscaling) {
ratio = Math.min(1.0f, ratio);
}
int scaledWidth = (int) (ratio * originalWidth);
int scaledHeight = (int) (ratio * originalHeight);
Bitmap result = Bitmap.createBitmap(scaledWidth, scaledHeight, Config.ARGB_8888);