Merge "Unify round corner radius in PipSurfaceTransactionHelper(s)" into sc-dev
This commit is contained in:
@@ -33,9 +33,6 @@
|
|||||||
<!-- Allow PIP to resize via dragging the corner of PiP. -->
|
<!-- Allow PIP to resize via dragging the corner of PiP. -->
|
||||||
<bool name="config_pipEnableDragCornerResize">false</bool>
|
<bool name="config_pipEnableDragCornerResize">false</bool>
|
||||||
|
|
||||||
<!-- Allow PIP to enable round corner, see also R.dimen.pip_corner_radius -->
|
|
||||||
<bool name="config_pipEnableRoundCorner">false</bool>
|
|
||||||
|
|
||||||
<!-- Animation duration when using long press on recents to dock -->
|
<!-- Animation duration when using long press on recents to dock -->
|
||||||
<integer name="long_press_dock_anim_duration">250</integer>
|
<integer name="long_press_dock_anim_duration">250</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -24,4 +24,12 @@ oneway interface IPipAnimationListener {
|
|||||||
* Notifies the listener that the Pip animation is started.
|
* Notifies the listener that the Pip animation is started.
|
||||||
*/
|
*/
|
||||||
void onPipAnimationStarted();
|
void onPipAnimationStarted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the listener about PiP round corner radius changes.
|
||||||
|
* Listener can expect an immediate callback the first time they attach.
|
||||||
|
*
|
||||||
|
* @param cornerRadius the pixel value of the corner radius, zero means it's disabled.
|
||||||
|
*/
|
||||||
|
void onPipCornerRadiusChanged(int cornerRadius);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.wm.shell.pip;
|
package com.android.wm.shell.pip;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
@@ -30,10 +29,6 @@ import com.android.wm.shell.R;
|
|||||||
* Abstracts the common operations on {@link SurfaceControl.Transaction} for PiP transition.
|
* Abstracts the common operations on {@link SurfaceControl.Transaction} for PiP transition.
|
||||||
*/
|
*/
|
||||||
public class PipSurfaceTransactionHelper {
|
public class PipSurfaceTransactionHelper {
|
||||||
|
|
||||||
private final boolean mEnableCornerRadius;
|
|
||||||
private int mCornerRadius;
|
|
||||||
|
|
||||||
/** for {@link #scale(SurfaceControl.Transaction, SurfaceControl, Rect, Rect)} operation */
|
/** for {@link #scale(SurfaceControl.Transaction, SurfaceControl, Rect, Rect)} operation */
|
||||||
private final Matrix mTmpTransform = new Matrix();
|
private final Matrix mTmpTransform = new Matrix();
|
||||||
private final float[] mTmpFloat9 = new float[9];
|
private final float[] mTmpFloat9 = new float[9];
|
||||||
@@ -41,11 +36,7 @@ public class PipSurfaceTransactionHelper {
|
|||||||
private final RectF mTmpDestinationRectF = new RectF();
|
private final RectF mTmpDestinationRectF = new RectF();
|
||||||
private final Rect mTmpDestinationRect = new Rect();
|
private final Rect mTmpDestinationRect = new Rect();
|
||||||
|
|
||||||
public PipSurfaceTransactionHelper(Context context) {
|
private int mCornerRadius;
|
||||||
final Resources res = context.getResources();
|
|
||||||
mEnableCornerRadius = res.getBoolean(R.bool.config_pipEnableRoundCorner)
|
|
||||||
|| SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when display size or font size of settings changed
|
* Called when display size or font size of settings changed
|
||||||
@@ -53,10 +44,10 @@ public class PipSurfaceTransactionHelper {
|
|||||||
* @param context the current context
|
* @param context the current context
|
||||||
*/
|
*/
|
||||||
public void onDensityOrFontScaleChanged(Context context) {
|
public void onDensityOrFontScaleChanged(Context context) {
|
||||||
if (mEnableCornerRadius) {
|
final boolean enableCornerRadius =
|
||||||
final Resources res = context.getResources();
|
SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
|
||||||
mCornerRadius = res.getDimensionPixelSize(R.dimen.pip_corner_radius);
|
mCornerRadius = enableCornerRadius
|
||||||
}
|
? context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,9 +185,7 @@ public class PipSurfaceTransactionHelper {
|
|||||||
*/
|
*/
|
||||||
public PipSurfaceTransactionHelper round(SurfaceControl.Transaction tx, SurfaceControl leash,
|
public PipSurfaceTransactionHelper round(SurfaceControl.Transaction tx, SurfaceControl leash,
|
||||||
boolean applyCornerRadius) {
|
boolean applyCornerRadius) {
|
||||||
if (mEnableCornerRadius) {
|
tx.setCornerRadius(leash, applyCornerRadius ? mCornerRadius : 0);
|
||||||
tx.setCornerRadius(leash, applyCornerRadius ? mCornerRadius : 0);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -50,6 +51,7 @@ import androidx.annotation.BinderThread;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.wm.shell.R;
|
||||||
import com.android.wm.shell.WindowManagerShellWrapper;
|
import com.android.wm.shell.WindowManagerShellWrapper;
|
||||||
import com.android.wm.shell.common.DisplayChangeController;
|
import com.android.wm.shell.common.DisplayChangeController;
|
||||||
import com.android.wm.shell.common.DisplayController;
|
import com.android.wm.shell.common.DisplayController;
|
||||||
@@ -428,6 +430,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
|
|
||||||
private void onDensityOrFontScaleChanged() {
|
private void onDensityOrFontScaleChanged() {
|
||||||
mPipTaskOrganizer.onDensityOrFontScaleChanged(mContext);
|
mPipTaskOrganizer.onDensityOrFontScaleChanged(mContext);
|
||||||
|
onPipCornerRadiusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOverlayChanged() {
|
private void onOverlayChanged() {
|
||||||
@@ -488,10 +491,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
mTouchHandler.getMotionHelper().expandLeavePip(false /* skipAnimation */);
|
mTouchHandler.getMotionHelper().expandLeavePip(false /* skipAnimation */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PipTouchHandler getPipTouchHandler() {
|
|
||||||
return mTouchHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the PIP menu.
|
* Hides the PIP menu.
|
||||||
*/
|
*/
|
||||||
@@ -531,6 +530,21 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
|||||||
|
|
||||||
private void setPinnedStackAnimationListener(IPipAnimationListener callback) {
|
private void setPinnedStackAnimationListener(IPipAnimationListener callback) {
|
||||||
mPinnedStackAnimationRecentsCallback = callback;
|
mPinnedStackAnimationRecentsCallback = callback;
|
||||||
|
onPipCornerRadiusChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPipCornerRadiusChanged() {
|
||||||
|
if (mPinnedStackAnimationRecentsCallback != null) {
|
||||||
|
final boolean enableCornerRadius =
|
||||||
|
SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
|
||||||
|
final int cornerRadius = enableCornerRadius
|
||||||
|
? mContext.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius) : 0;
|
||||||
|
try {
|
||||||
|
mPinnedStackAnimationRecentsCallback.onPipCornerRadiusChanged(cornerRadius);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Failed to call onPipCornerRadiusChanged", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo,
|
private Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo,
|
||||||
|
|||||||
@@ -152,9 +152,8 @@ public class PipMenuView extends FrameLayout {
|
|||||||
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
|
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
|
||||||
inflate(context, R.layout.pip_menu, this);
|
inflate(context, R.layout.pip_menu, this);
|
||||||
|
|
||||||
final boolean enableCornerRadius = mContext.getResources()
|
final boolean enableCornerRadius =
|
||||||
.getBoolean(R.bool.config_pipEnableRoundCorner)
|
SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
|
||||||
|| SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
|
|
||||||
mBackgroundDrawable = enableCornerRadius
|
mBackgroundDrawable = enableCornerRadius
|
||||||
? mContext.getDrawable(R.drawable.pip_menu_background)
|
? mContext.getDrawable(R.drawable.pip_menu_background)
|
||||||
: new ColorDrawable(Color.BLACK);
|
: new ColorDrawable(Color.BLACK);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class PipAnimationControllerTest extends ShellTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mPipAnimationController = new PipAnimationController(
|
mPipAnimationController = new PipAnimationController(
|
||||||
new PipSurfaceTransactionHelper(mContext));
|
new PipSurfaceTransactionHelper());
|
||||||
mLeash = new SurfaceControl.Builder()
|
mLeash = new SurfaceControl.Builder()
|
||||||
.setContainerLayer()
|
.setContainerLayer()
|
||||||
.setName("FakeLeash")
|
.setName("FakeLeash")
|
||||||
|
|||||||
@@ -29,15 +29,17 @@ import android.window.PictureInPictureSurfaceTransaction;
|
|||||||
* source of truth on enabling/disabling and the actual value of corner radius.
|
* source of truth on enabling/disabling and the actual value of corner radius.
|
||||||
*/
|
*/
|
||||||
public class PipSurfaceTransactionHelper {
|
public class PipSurfaceTransactionHelper {
|
||||||
/** corner radius is currently disabled. */
|
private final int mCornerRadius;
|
||||||
private final float mCornerRadius = 0f;
|
|
||||||
|
|
||||||
private final Matrix mTmpTransform = new Matrix();
|
private final Matrix mTmpTransform = new Matrix();
|
||||||
private final float[] mTmpFloat9 = new float[9];
|
private final float[] mTmpFloat9 = new float[9];
|
||||||
private final RectF mTmpSourceRectF = new RectF();
|
private final RectF mTmpSourceRectF = new RectF();
|
||||||
private final RectF mTmpDestinationRectF = new RectF();
|
private final RectF mTmpDestinationRectF = new RectF();
|
||||||
private final Rect mTmpDestinationRect = new Rect();
|
private final Rect mTmpDestinationRect = new Rect();
|
||||||
|
|
||||||
|
public PipSurfaceTransactionHelper(int cornerRadius) {
|
||||||
|
mCornerRadius = cornerRadius;
|
||||||
|
}
|
||||||
|
|
||||||
public PictureInPictureSurfaceTransaction scale(
|
public PictureInPictureSurfaceTransaction scale(
|
||||||
SurfaceControl.Transaction tx, SurfaceControl leash,
|
SurfaceControl.Transaction tx, SurfaceControl leash,
|
||||||
Rect sourceBounds, Rect destinationBounds) {
|
Rect sourceBounds, Rect destinationBounds) {
|
||||||
|
|||||||
@@ -280,8 +280,8 @@ public abstract class WMShellBaseModule {
|
|||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
@Provides
|
@Provides
|
||||||
static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper(Context context) {
|
static PipSurfaceTransactionHelper providePipSurfaceTransactionHelper() {
|
||||||
return new PipSurfaceTransactionHelper(context);
|
return new PipSurfaceTransactionHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
|
|||||||
Reference in New Issue
Block a user