VisD update for the PipAppIconOverlay
- Use the same IconProvider Launcher is using to ensure the identical shadow / elevation is set - Use the same icon size (66dp) Launcher is using for practical / reasonable device profile Video: http://recall/-/aaaaaabFQoRHlzixHdtY/blaCMAiD9NQCIFj1V4i8qQ video: http://recall/-/aaaaaabFQoRHlzixHdtY/gqHVRIePASh13Kk7wMeewa Bug: 271912318 Test: manual in both light and dark thems, see the videos Change-Id: I45e45e7ade5c0d4af031969ea783c24afdb6b412
This commit is contained in:
@@ -36,6 +36,7 @@ import android.window.TaskSnapshot;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
|
||||
import com.android.launcher3.icons.IconProvider;
|
||||
import com.android.wm.shell.animation.Interpolators;
|
||||
import com.android.wm.shell.transition.Transitions;
|
||||
|
||||
@@ -372,7 +373,8 @@ public class PipAnimationController {
|
||||
|
||||
void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo) {
|
||||
reattachContentOverlay(
|
||||
new PipContentOverlay.PipAppIconOverlay(context, bounds, activityInfo));
|
||||
new PipContentOverlay.PipAppIconOverlay(context, bounds,
|
||||
() -> new IconProvider(context).getIcon(activityInfo)));
|
||||
}
|
||||
|
||||
private void reattachContentOverlay(PipContentOverlay overlay) {
|
||||
|
||||
@@ -20,9 +20,6 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -35,6 +32,8 @@ import android.view.SurfaceControl;
|
||||
import android.view.SurfaceSession;
|
||||
import android.window.TaskSnapshot;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Represents the content overlay used during the entering PiP animation.
|
||||
*/
|
||||
@@ -177,7 +176,9 @@ public abstract class PipContentOverlay {
|
||||
/** A {@link PipContentOverlay} shows app icon on solid color background. */
|
||||
public static final class PipAppIconOverlay extends PipContentOverlay {
|
||||
private static final String TAG = PipAppIconOverlay.class.getSimpleName();
|
||||
private static final int APP_ICON_SIZE_DP = 48;
|
||||
// Align with the practical / reasonable launcher:iconImageSize as in
|
||||
// vendor/unbundled_google/packages/NexusLauncher/res/xml/device_profiles.xml
|
||||
private static final int APP_ICON_SIZE_DP = 66;
|
||||
|
||||
private final Context mContext;
|
||||
private final int mAppIconSizePx;
|
||||
@@ -187,14 +188,14 @@ public abstract class PipContentOverlay {
|
||||
|
||||
private Bitmap mBitmap;
|
||||
|
||||
public PipAppIconOverlay(Context context, Rect appBounds, ActivityInfo activityInfo) {
|
||||
public PipAppIconOverlay(Context context, Rect appBounds, Supplier<Drawable> iconSupplier) {
|
||||
mContext = context;
|
||||
mAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, APP_ICON_SIZE_DP,
|
||||
context.getResources().getDisplayMetrics());
|
||||
mAppBounds = new Rect(appBounds);
|
||||
mBitmap = Bitmap.createBitmap(appBounds.width(), appBounds.height(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
prepareAppIconOverlay(activityInfo);
|
||||
prepareAppIconOverlay(iconSupplier);
|
||||
mLeash = new SurfaceControl.Builder(new SurfaceSession())
|
||||
.setCallsite(TAG)
|
||||
.setName(LAYER_NAME)
|
||||
@@ -237,7 +238,7 @@ public abstract class PipContentOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareAppIconOverlay(ActivityInfo activityInfo) {
|
||||
private void prepareAppIconOverlay(Supplier<Drawable> iconSupplier) {
|
||||
final Canvas canvas = new Canvas();
|
||||
canvas.setBitmap(mBitmap);
|
||||
final TypedArray ta = mContext.obtainStyledAttributes(new int[] {
|
||||
@@ -251,8 +252,7 @@ public abstract class PipContentOverlay {
|
||||
} finally {
|
||||
ta.recycle();
|
||||
}
|
||||
final Drawable appIcon = loadActivityInfoIcon(activityInfo,
|
||||
mContext.getResources().getConfiguration().densityDpi);
|
||||
final Drawable appIcon = iconSupplier.get();
|
||||
final Rect appIconBounds = new Rect(
|
||||
mAppBounds.centerX() - mAppIconSizePx / 2,
|
||||
mAppBounds.centerY() - mAppIconSizePx / 2,
|
||||
@@ -262,24 +262,5 @@ public abstract class PipContentOverlay {
|
||||
appIcon.draw(canvas);
|
||||
mBitmap = mBitmap.copy(Bitmap.Config.HARDWARE, false /* mutable */);
|
||||
}
|
||||
|
||||
// Copied from com.android.launcher3.icons.IconProvider#loadActivityInfoIcon
|
||||
private Drawable loadActivityInfoIcon(ActivityInfo ai, int density) {
|
||||
final int iconRes = ai.getIconResource();
|
||||
Drawable icon = null;
|
||||
// Get the preferred density icon from the app's resources
|
||||
if (density != 0 && iconRes != 0) {
|
||||
try {
|
||||
final Resources resources = mContext.getPackageManager()
|
||||
.getResourcesForApplication(ai.applicationInfo);
|
||||
icon = resources.getDrawableForDensity(iconRes, density);
|
||||
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException exc) { }
|
||||
}
|
||||
// Get the default density icon
|
||||
if (icon == null) {
|
||||
icon = ai.loadIcon(mContext.getPackageManager());
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user