Merge "VisD update for the PipAppIconOverlay 2/N" into tm-qpr-dev am: 3def7dfccf
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22108002 Change-Id: I7350d2f8f3a9ffb2af8709594ed37145d3cd16e1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -75,4 +75,9 @@ interface IPip {
|
|||||||
* Sets the height and visibility of the Launcher keep clear area.
|
* Sets the height and visibility of the Launcher keep clear area.
|
||||||
*/
|
*/
|
||||||
oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6;
|
oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the app icon size in pixel used by Launcher
|
||||||
|
*/
|
||||||
|
oneway void setLauncherAppIconSize(int iconSizePx) = 7;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,10 +371,11 @@ public class PipAnimationController {
|
|||||||
new PipContentOverlay.PipSnapshotOverlay(snapshot, sourceRectHint));
|
new PipContentOverlay.PipSnapshotOverlay(snapshot, sourceRectHint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo) {
|
void setAppIconContentOverlay(Context context, Rect bounds, ActivityInfo activityInfo,
|
||||||
|
int appIconSizePx) {
|
||||||
reattachContentOverlay(
|
reattachContentOverlay(
|
||||||
new PipContentOverlay.PipAppIconOverlay(context, bounds,
|
new PipContentOverlay.PipAppIconOverlay(context, bounds,
|
||||||
() -> new IconProvider(context).getIcon(activityInfo)));
|
new IconProvider(context).getIcon(activityInfo), appIconSizePx));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reattachContentOverlay(PipContentOverlay overlay) {
|
private void reattachContentOverlay(PipContentOverlay overlay) {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class PipBoundsState {
|
|||||||
private int mStashedState = STASH_TYPE_NONE;
|
private int mStashedState = STASH_TYPE_NONE;
|
||||||
private int mStashOffset;
|
private int mStashOffset;
|
||||||
private @Nullable PipReentryState mPipReentryState;
|
private @Nullable PipReentryState mPipReentryState;
|
||||||
|
private final LauncherState mLauncherState = new LauncherState();
|
||||||
private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler;
|
private final @Nullable PipSizeSpecHandler mPipSizeSpecHandler;
|
||||||
private @Nullable ComponentName mLastPipComponentName;
|
private @Nullable ComponentName mLastPipComponentName;
|
||||||
private int mDisplayId = Display.DEFAULT_DISPLAY;
|
private int mDisplayId = Display.DEFAULT_DISPLAY;
|
||||||
@@ -497,6 +498,10 @@ public class PipBoundsState {
|
|||||||
mOnPipExclusionBoundsChangeCallbacks.remove(onPipExclusionBoundsChangeCallback);
|
mOnPipExclusionBoundsChangeCallbacks.remove(onPipExclusionBoundsChangeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LauncherState getLauncherState() {
|
||||||
|
return mLauncherState;
|
||||||
|
}
|
||||||
|
|
||||||
/** Source of truth for the current bounds of PIP that may be in motion. */
|
/** Source of truth for the current bounds of PIP that may be in motion. */
|
||||||
public static class MotionBoundsState {
|
public static class MotionBoundsState {
|
||||||
/** The bounds used when PIP is in motion (e.g. during a drag or animation) */
|
/** The bounds used when PIP is in motion (e.g. during a drag or animation) */
|
||||||
@@ -549,6 +554,25 @@ public class PipBoundsState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Data class for Launcher state. */
|
||||||
|
public static final class LauncherState {
|
||||||
|
private int mAppIconSizePx;
|
||||||
|
|
||||||
|
public void setAppIconSizePx(int appIconSizePx) {
|
||||||
|
mAppIconSizePx = appIconSizePx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAppIconSizePx() {
|
||||||
|
return mAppIconSizePx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump(PrintWriter pw, String prefix) {
|
||||||
|
final String innerPrefix = prefix + " ";
|
||||||
|
pw.println(prefix + LauncherState.class.getSimpleName());
|
||||||
|
pw.println(innerPrefix + "getAppIconSizePx=" + getAppIconSizePx());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static final class PipReentryState {
|
static final class PipReentryState {
|
||||||
private static final String TAG = PipReentryState.class.getSimpleName();
|
private static final String TAG = PipReentryState.class.getSimpleName();
|
||||||
|
|
||||||
@@ -603,6 +627,7 @@ public class PipBoundsState {
|
|||||||
} else {
|
} else {
|
||||||
mPipReentryState.dump(pw, innerPrefix);
|
mPipReentryState.dump(pw, innerPrefix);
|
||||||
}
|
}
|
||||||
|
mLauncherState.dump(pw, innerPrefix);
|
||||||
mMotionBoundsState.dump(pw, innerPrefix);
|
mMotionBoundsState.dump(pw, innerPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import android.view.SurfaceControl;
|
|||||||
import android.view.SurfaceSession;
|
import android.view.SurfaceSession;
|
||||||
import android.window.TaskSnapshot;
|
import android.window.TaskSnapshot;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the content overlay used during the entering PiP animation.
|
* Represents the content overlay used during the entering PiP animation.
|
||||||
*/
|
*/
|
||||||
@@ -176,9 +174,8 @@ public abstract class PipContentOverlay {
|
|||||||
/** A {@link PipContentOverlay} shows app icon on solid color background. */
|
/** A {@link PipContentOverlay} shows app icon on solid color background. */
|
||||||
public static final class PipAppIconOverlay extends PipContentOverlay {
|
public static final class PipAppIconOverlay extends PipContentOverlay {
|
||||||
private static final String TAG = PipAppIconOverlay.class.getSimpleName();
|
private static final String TAG = PipAppIconOverlay.class.getSimpleName();
|
||||||
// Align with the practical / reasonable launcher:iconImageSize as in
|
// The maximum size for app icon in pixel.
|
||||||
// vendor/unbundled_google/packages/NexusLauncher/res/xml/device_profiles.xml
|
private static final int MAX_APP_ICON_SIZE_DP = 72;
|
||||||
private static final int APP_ICON_SIZE_DP = 66;
|
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final int mAppIconSizePx;
|
private final int mAppIconSizePx;
|
||||||
@@ -188,14 +185,16 @@ public abstract class PipContentOverlay {
|
|||||||
|
|
||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
|
|
||||||
public PipAppIconOverlay(Context context, Rect appBounds, Supplier<Drawable> iconSupplier) {
|
public PipAppIconOverlay(Context context, Rect appBounds,
|
||||||
|
Drawable appIcon, int appIconSizePx) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, APP_ICON_SIZE_DP,
|
final int maxAppIconSizePx = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP,
|
||||||
context.getResources().getDisplayMetrics());
|
MAX_APP_ICON_SIZE_DP, context.getResources().getDisplayMetrics());
|
||||||
|
mAppIconSizePx = Math.min(maxAppIconSizePx, appIconSizePx);
|
||||||
mAppBounds = new Rect(appBounds);
|
mAppBounds = new Rect(appBounds);
|
||||||
mBitmap = Bitmap.createBitmap(appBounds.width(), appBounds.height(),
|
mBitmap = Bitmap.createBitmap(appBounds.width(), appBounds.height(),
|
||||||
Bitmap.Config.ARGB_8888);
|
Bitmap.Config.ARGB_8888);
|
||||||
prepareAppIconOverlay(iconSupplier);
|
prepareAppIconOverlay(appIcon);
|
||||||
mLeash = new SurfaceControl.Builder(new SurfaceSession())
|
mLeash = new SurfaceControl.Builder(new SurfaceSession())
|
||||||
.setCallsite(TAG)
|
.setCallsite(TAG)
|
||||||
.setName(LAYER_NAME)
|
.setName(LAYER_NAME)
|
||||||
@@ -238,7 +237,7 @@ public abstract class PipContentOverlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareAppIconOverlay(Supplier<Drawable> iconSupplier) {
|
private void prepareAppIconOverlay(Drawable appIcon) {
|
||||||
final Canvas canvas = new Canvas();
|
final Canvas canvas = new Canvas();
|
||||||
canvas.setBitmap(mBitmap);
|
canvas.setBitmap(mBitmap);
|
||||||
final TypedArray ta = mContext.obtainStyledAttributes(new int[] {
|
final TypedArray ta = mContext.obtainStyledAttributes(new int[] {
|
||||||
@@ -252,7 +251,6 @@ public abstract class PipContentOverlay {
|
|||||||
} finally {
|
} finally {
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
}
|
}
|
||||||
final Drawable appIcon = iconSupplier.get();
|
|
||||||
final Rect appIconBounds = new Rect(
|
final Rect appIconBounds = new Rect(
|
||||||
mAppBounds.centerX() - mAppIconSizePx / 2,
|
mAppBounds.centerX() - mAppIconSizePx / 2,
|
||||||
mAppBounds.centerY() - mAppIconSizePx / 2,
|
mAppBounds.centerY() - mAppIconSizePx / 2,
|
||||||
|
|||||||
@@ -1610,7 +1610,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
if (SystemProperties.getBoolean(
|
if (SystemProperties.getBoolean(
|
||||||
"persist.wm.debug.enable_pip_app_icon_overlay", true)) {
|
"persist.wm.debug.enable_pip_app_icon_overlay", true)) {
|
||||||
animator.setAppIconContentOverlay(
|
animator.setAppIconContentOverlay(
|
||||||
mContext, currentBounds, mTaskInfo.topActivityInfo);
|
mContext, currentBounds, mTaskInfo.topActivityInfo,
|
||||||
|
mPipBoundsState.getLauncherState().getAppIconSizePx());
|
||||||
} else {
|
} else {
|
||||||
animator.setColorContentOverlay(mContext);
|
animator.setColorContentOverlay(mContext);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -813,7 +813,8 @@ public class PipTransition extends PipTransitionController {
|
|||||||
"persist.wm.debug.enable_pip_app_icon_overlay", true)
|
"persist.wm.debug.enable_pip_app_icon_overlay", true)
|
||||||
&& hasTopActivityInfo) {
|
&& hasTopActivityInfo) {
|
||||||
animator.setAppIconContentOverlay(
|
animator.setAppIconContentOverlay(
|
||||||
mContext, currentBounds, taskInfo.topActivityInfo);
|
mContext, currentBounds, taskInfo.topActivityInfo,
|
||||||
|
mPipBoundsState.getLauncherState().getAppIconSizePx());
|
||||||
} else {
|
} else {
|
||||||
animator.setColorContentOverlay(mContext);
|
animator.setColorContentOverlay(mContext);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -937,6 +937,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setLauncherAppIconSize(int iconSizePx) {
|
||||||
|
mPipBoundsState.getLauncherState().setAppIconSizePx(iconSizePx);
|
||||||
|
}
|
||||||
|
|
||||||
private void setOnIsInPipStateChangedListener(Consumer<Boolean> callback) {
|
private void setOnIsInPipStateChangedListener(Consumer<Boolean> callback) {
|
||||||
mOnIsInPipStateChangedListener = callback;
|
mOnIsInPipStateChangedListener = callback;
|
||||||
if (mOnIsInPipStateChangedListener != null) {
|
if (mOnIsInPipStateChangedListener != null) {
|
||||||
@@ -1285,26 +1289,26 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
public void stopSwipePipToHome(int taskId, ComponentName componentName,
|
public void stopSwipePipToHome(int taskId, ComponentName componentName,
|
||||||
Rect destinationBounds, SurfaceControl overlay) {
|
Rect destinationBounds, SurfaceControl overlay) {
|
||||||
executeRemoteCallWithTaskPermission(mController, "stopSwipePipToHome",
|
executeRemoteCallWithTaskPermission(mController, "stopSwipePipToHome",
|
||||||
(controller) -> {
|
(controller) -> controller.stopSwipePipToHome(
|
||||||
controller.stopSwipePipToHome(taskId, componentName, destinationBounds,
|
taskId, componentName, destinationBounds, overlay));
|
||||||
overlay);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setShelfHeight(boolean visible, int height) {
|
public void setShelfHeight(boolean visible, int height) {
|
||||||
executeRemoteCallWithTaskPermission(mController, "setShelfHeight",
|
executeRemoteCallWithTaskPermission(mController, "setShelfHeight",
|
||||||
(controller) -> {
|
(controller) -> controller.setShelfHeight(visible, height));
|
||||||
controller.setShelfHeight(visible, height);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLauncherKeepClearAreaHeight(boolean visible, int height) {
|
public void setLauncherKeepClearAreaHeight(boolean visible, int height) {
|
||||||
executeRemoteCallWithTaskPermission(mController, "setLauncherKeepClearAreaHeight",
|
executeRemoteCallWithTaskPermission(mController, "setLauncherKeepClearAreaHeight",
|
||||||
(controller) -> {
|
(controller) -> controller.setLauncherKeepClearAreaHeight(visible, height));
|
||||||
controller.setLauncherKeepClearAreaHeight(visible, height);
|
}
|
||||||
});
|
|
||||||
|
@Override
|
||||||
|
public void setLauncherAppIconSize(int iconSizePx) {
|
||||||
|
executeRemoteCallWithTaskPermission(mController, "setLauncherAppIconSize",
|
||||||
|
(controller) -> controller.setLauncherAppIconSize(iconSizePx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1322,9 +1326,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
@Override
|
@Override
|
||||||
public void setPipAnimationTypeToAlpha() {
|
public void setPipAnimationTypeToAlpha() {
|
||||||
executeRemoteCallWithTaskPermission(mController, "setPipAnimationTypeToAlpha",
|
executeRemoteCallWithTaskPermission(mController, "setPipAnimationTypeToAlpha",
|
||||||
(controller) -> {
|
(controller) -> controller.setPinnedStackAnimationType(ANIM_TYPE_ALPHA));
|
||||||
controller.setPinnedStackAnimationType(ANIM_TYPE_ALPHA);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user