Merge "Cleanup some unused code and update resources on config change" into rvc-dev
This commit is contained in:
@@ -1006,6 +1006,9 @@
|
|||||||
<!-- The corner radius for PiP window. -->
|
<!-- The corner radius for PiP window. -->
|
||||||
<dimen name="pip_corner_radius">8dp</dimen>
|
<dimen name="pip_corner_radius">8dp</dimen>
|
||||||
|
|
||||||
|
<!-- The buffer to use when calculating whether the pip is in an adjust zone. -->
|
||||||
|
<dimen name="pip_bottom_offset_buffer">1dp</dimen>
|
||||||
|
|
||||||
<dimen name="default_gear_space">18dp</dimen>
|
<dimen name="default_gear_space">18dp</dimen>
|
||||||
<dimen name="cell_overlay_padding">18dp</dimen>
|
<dimen name="cell_overlay_padding">18dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -500,6 +500,5 @@ public class PipBoundsHandler {
|
|||||||
pw.println(innerPrefix + "mImeHeight=" + mImeHeight);
|
pw.println(innerPrefix + "mImeHeight=" + mImeHeight);
|
||||||
pw.println(innerPrefix + "mIsShelfShowing=" + mIsShelfShowing);
|
pw.println(innerPrefix + "mIsShelfShowing=" + mIsShelfShowing);
|
||||||
pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
|
pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
|
||||||
mSnapAlgorithm.dump(pw, innerPrefix);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,11 @@
|
|||||||
package com.android.systemui.pip;
|
package com.android.systemui.pip;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,8 +36,6 @@ public class PipSnapAlgorithm {
|
|||||||
private final float mMinAspectRatioForMinSize;
|
private final float mMinAspectRatioForMinSize;
|
||||||
private final float mMaxAspectRatioForMinSize;
|
private final float mMaxAspectRatioForMinSize;
|
||||||
|
|
||||||
private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PipSnapAlgorithm(Context context) {
|
public PipSnapAlgorithm(Context context) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
@@ -50,15 +45,6 @@ public class PipSnapAlgorithm {
|
|||||||
mMaxAspectRatioForMinSize = res.getFloat(
|
mMaxAspectRatioForMinSize = res.getFloat(
|
||||||
com.android.internal.R.dimen.config_pictureInPictureAspectRatioLimitForMinSize);
|
com.android.internal.R.dimen.config_pictureInPictureAspectRatioLimitForMinSize);
|
||||||
mMinAspectRatioForMinSize = 1f / mMaxAspectRatioForMinSize;
|
mMinAspectRatioForMinSize = 1f / mMaxAspectRatioForMinSize;
|
||||||
onConfigurationChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the snap algorithm when the configuration changes.
|
|
||||||
*/
|
|
||||||
public void onConfigurationChanged() {
|
|
||||||
Resources res = mContext.getResources();
|
|
||||||
mOrientation = res.getConfiguration().orientation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,10 +207,4 @@ public class PipSnapAlgorithm {
|
|||||||
boundsOut.offsetTo(boundedLeft, movementBounds.bottom);
|
boundsOut.offsetTo(boundedLeft, movementBounds.bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(PrintWriter pw, String prefix) {
|
|
||||||
final String innerPrefix = prefix + " ";
|
|
||||||
pw.println(prefix + PipSnapAlgorithm.class.getSimpleName());
|
|
||||||
pw.println(innerPrefix + "mOrientation=" + mOrientation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.graphics.RectF;
|
|||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -32,10 +33,11 @@ import javax.inject.Singleton;
|
|||||||
* Abstracts the common operations on {@link SurfaceControl.Transaction} for PiP transition.
|
* Abstracts the common operations on {@link SurfaceControl.Transaction} for PiP transition.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PipSurfaceTransactionHelper {
|
public class PipSurfaceTransactionHelper implements ConfigurationController.ConfigurationListener {
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
private final boolean mEnableCornerRadius;
|
private final boolean mEnableCornerRadius;
|
||||||
private final int mCornerRadius;
|
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();
|
||||||
@@ -44,9 +46,16 @@ public class PipSurfaceTransactionHelper {
|
|||||||
private final RectF mTmpDestinationRectF = new RectF();
|
private final RectF mTmpDestinationRectF = new RectF();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PipSurfaceTransactionHelper(Context context) {
|
public PipSurfaceTransactionHelper(Context context, ConfigurationController configController) {
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
|
mContext = context;
|
||||||
mEnableCornerRadius = res.getBoolean(R.bool.config_pipEnableRoundCorner);
|
mEnableCornerRadius = res.getBoolean(R.bool.config_pipEnableRoundCorner);
|
||||||
|
configController.addCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDensityOrFontScaleChanged() {
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
mCornerRadius = res.getDimensionPixelSize(R.dimen.pip_corner_radius);
|
mCornerRadius = res.getDimensionPixelSize(R.dimen.pip_corner_radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import androidx.dynamicanimation.animation.SpringForce;
|
|||||||
|
|
||||||
import com.android.systemui.pip.PipSnapAlgorithm;
|
import com.android.systemui.pip.PipSnapAlgorithm;
|
||||||
import com.android.systemui.pip.PipTaskOrganizer;
|
import com.android.systemui.pip.PipTaskOrganizer;
|
||||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
|
||||||
import com.android.systemui.util.FloatingContentCoordinator;
|
import com.android.systemui.util.FloatingContentCoordinator;
|
||||||
import com.android.systemui.util.animation.FloatProperties;
|
import com.android.systemui.util.animation.FloatProperties;
|
||||||
import com.android.systemui.util.animation.PhysicsAnimator;
|
import com.android.systemui.util.animation.PhysicsAnimator;
|
||||||
@@ -60,8 +59,6 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
private PipMenuActivityController mMenuController;
|
private PipMenuActivityController mMenuController;
|
||||||
private PipSnapAlgorithm mSnapAlgorithm;
|
private PipSnapAlgorithm mSnapAlgorithm;
|
||||||
|
|
||||||
private final Rect mStableInsets = new Rect();
|
|
||||||
|
|
||||||
/** PIP's current bounds on the screen. */
|
/** PIP's current bounds on the screen. */
|
||||||
private final Rect mBounds = new Rect();
|
private final Rect mBounds = new Rect();
|
||||||
|
|
||||||
@@ -148,7 +145,6 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
mMenuController = menuController;
|
mMenuController = menuController;
|
||||||
mSnapAlgorithm = snapAlgorithm;
|
mSnapAlgorithm = snapAlgorithm;
|
||||||
mFloatingContentCoordinator = floatingContentCoordinator;
|
mFloatingContentCoordinator = floatingContentCoordinator;
|
||||||
onConfigurationChanged();
|
|
||||||
mPipTaskOrganizer.registerPipTransitionCallback(mPipTransitionCallback);
|
mPipTaskOrganizer.registerPipTransitionCallback(mPipTransitionCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,14 +165,6 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
animateToBounds(bounds, mConflictResolutionSpringConfig);
|
animateToBounds(bounds, mConflictResolutionSpringConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates whenever the configuration changes.
|
|
||||||
*/
|
|
||||||
void onConfigurationChanged() {
|
|
||||||
mSnapAlgorithm.onConfigurationChanged();
|
|
||||||
WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronizes the current bounds with the pinned stack, cancelling any ongoing animations.
|
* Synchronizes the current bounds with the pinned stack, cancelling any ongoing animations.
|
||||||
*/
|
*/
|
||||||
@@ -530,6 +518,5 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
|||||||
final String innerPrefix = prefix + " ";
|
final String innerPrefix = prefix + " ";
|
||||||
pw.println(prefix + TAG);
|
pw.println(prefix + TAG);
|
||||||
pw.println(innerPrefix + "mBounds=" + mBounds);
|
pw.println(innerPrefix + "mBounds=" + mBounds);
|
||||||
pw.println(innerPrefix + "mStableInsets=" + mStableInsets);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import android.hardware.input.InputManager;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.InputChannel;
|
import android.view.InputChannel;
|
||||||
import android.view.InputEvent;
|
import android.view.InputEvent;
|
||||||
import android.view.InputEventReceiver;
|
import android.view.InputEventReceiver;
|
||||||
@@ -56,7 +55,7 @@ public class PipResizeGestureHandler {
|
|||||||
|
|
||||||
private static final String TAG = "PipResizeGestureHandler";
|
private static final String TAG = "PipResizeGestureHandler";
|
||||||
|
|
||||||
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
|
private final Context mContext;
|
||||||
private final PipBoundsHandler mPipBoundsHandler;
|
private final PipBoundsHandler mPipBoundsHandler;
|
||||||
private final PipMotionHelper mMotionHelper;
|
private final PipMotionHelper mMotionHelper;
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
@@ -74,10 +73,10 @@ public class PipResizeGestureHandler {
|
|||||||
private final Rect mTmpBottomLeftCorner = new Rect();
|
private final Rect mTmpBottomLeftCorner = new Rect();
|
||||||
private final Rect mTmpBottomRightCorner = new Rect();
|
private final Rect mTmpBottomRightCorner = new Rect();
|
||||||
private final Rect mDisplayBounds = new Rect();
|
private final Rect mDisplayBounds = new Rect();
|
||||||
private final int mDelta;
|
|
||||||
private final Supplier<Rect> mMovementBoundsSupplier;
|
private final Supplier<Rect> mMovementBoundsSupplier;
|
||||||
private final Runnable mUpdateMovementBoundsRunnable;
|
private final Runnable mUpdateMovementBoundsRunnable;
|
||||||
|
|
||||||
|
private int mDelta;
|
||||||
private boolean mAllowGesture;
|
private boolean mAllowGesture;
|
||||||
private boolean mIsAttached;
|
private boolean mIsAttached;
|
||||||
private boolean mIsEnabled;
|
private boolean mIsEnabled;
|
||||||
@@ -93,8 +92,7 @@ public class PipResizeGestureHandler {
|
|||||||
PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
|
PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
|
||||||
PipTaskOrganizer pipTaskOrganizer, Supplier<Rect> movementBoundsSupplier,
|
PipTaskOrganizer pipTaskOrganizer, Supplier<Rect> movementBoundsSupplier,
|
||||||
Runnable updateMovementBoundsRunnable) {
|
Runnable updateMovementBoundsRunnable) {
|
||||||
final Resources res = context.getResources();
|
mContext = context;
|
||||||
context.getDisplay().getMetrics(mDisplayMetrics);
|
|
||||||
mDisplayId = context.getDisplayId();
|
mDisplayId = context.getDisplayId();
|
||||||
mMainExecutor = context.getMainExecutor();
|
mMainExecutor = context.getMainExecutor();
|
||||||
mPipBoundsHandler = pipBoundsHandler;
|
mPipBoundsHandler = pipBoundsHandler;
|
||||||
@@ -102,9 +100,8 @@ public class PipResizeGestureHandler {
|
|||||||
mPipTaskOrganizer = pipTaskOrganizer;
|
mPipTaskOrganizer = pipTaskOrganizer;
|
||||||
mMovementBoundsSupplier = movementBoundsSupplier;
|
mMovementBoundsSupplier = movementBoundsSupplier;
|
||||||
mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable;
|
mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable;
|
||||||
|
|
||||||
context.getDisplay().getRealSize(mMaxSize);
|
context.getDisplay().getRealSize(mMaxSize);
|
||||||
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
|
reloadResources();
|
||||||
|
|
||||||
mEnableUserResize = DeviceConfig.getBoolean(
|
mEnableUserResize = DeviceConfig.getBoolean(
|
||||||
DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
@@ -122,6 +119,15 @@ public class PipResizeGestureHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onConfigurationChanged() {
|
||||||
|
reloadResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reloadResources() {
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
|
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
|
||||||
|
}
|
||||||
|
|
||||||
private void resetDragCorners() {
|
private void resetDragCorners() {
|
||||||
mDragCornerSize.set(0, 0, mDelta, mDelta);
|
mDragCornerSize.set(0, 0, mDelta, mDelta);
|
||||||
mTmpTopLeftCorner.set(mDragCornerSize);
|
mTmpTopLeftCorner.set(mDragCornerSize);
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import com.android.systemui.pip.PipBoundsHandler;
|
|||||||
import com.android.systemui.pip.PipSnapAlgorithm;
|
import com.android.systemui.pip.PipSnapAlgorithm;
|
||||||
import com.android.systemui.pip.PipTaskOrganizer;
|
import com.android.systemui.pip.PipTaskOrganizer;
|
||||||
import com.android.systemui.shared.system.InputConsumerController;
|
import com.android.systemui.shared.system.InputConsumerController;
|
||||||
import com.android.systemui.statusbar.FlingAnimationUtils;
|
|
||||||
import com.android.systemui.util.DeviceConfigProxy;
|
import com.android.systemui.util.DeviceConfigProxy;
|
||||||
import com.android.systemui.util.DismissCircleView;
|
import com.android.systemui.util.DismissCircleView;
|
||||||
import com.android.systemui.util.FloatingContentCoordinator;
|
import com.android.systemui.util.FloatingContentCoordinator;
|
||||||
@@ -77,9 +76,6 @@ import java.io.PrintWriter;
|
|||||||
public class PipTouchHandler {
|
public class PipTouchHandler {
|
||||||
private static final String TAG = "PipTouchHandler";
|
private static final String TAG = "PipTouchHandler";
|
||||||
|
|
||||||
private static final int SHOW_DISMISS_AFFORDANCE_DELAY = 225;
|
|
||||||
private static final int BOTTOM_OFFSET_BUFFER_DP = 1;
|
|
||||||
|
|
||||||
// Allow dragging the PIP to a location to close it
|
// Allow dragging the PIP to a location to close it
|
||||||
private final boolean mEnableDismissDragToEdge;
|
private final boolean mEnableDismissDragToEdge;
|
||||||
// Allow PIP to resize to a slightly bigger state upon touch
|
// Allow PIP to resize to a slightly bigger state upon touch
|
||||||
@@ -161,6 +157,7 @@ public class PipTouchHandler {
|
|||||||
private boolean mIsShelfShowing;
|
private boolean mIsShelfShowing;
|
||||||
private int mShelfHeight;
|
private int mShelfHeight;
|
||||||
private int mMovementBoundsExtraOffsets;
|
private int mMovementBoundsExtraOffsets;
|
||||||
|
private int mBottomOffsetBufferPx;
|
||||||
private float mSavedSnapFraction = -1f;
|
private float mSavedSnapFraction = -1f;
|
||||||
private boolean mSendingHoverAccessibilityEvents;
|
private boolean mSendingHoverAccessibilityEvents;
|
||||||
private boolean mMovementWithinDismiss;
|
private boolean mMovementWithinDismiss;
|
||||||
@@ -168,7 +165,6 @@ public class PipTouchHandler {
|
|||||||
|
|
||||||
// Touch state
|
// Touch state
|
||||||
private final PipTouchState mTouchState;
|
private final PipTouchState mTouchState;
|
||||||
private final FlingAnimationUtils mFlingAnimationUtils;
|
|
||||||
private final FloatingContentCoordinator mFloatingContentCoordinator;
|
private final FloatingContentCoordinator mFloatingContentCoordinator;
|
||||||
private PipMotionHelper mMotionHelper;
|
private PipMotionHelper mMotionHelper;
|
||||||
private PipTouchGesture mGesture;
|
private PipTouchGesture mGesture;
|
||||||
@@ -225,8 +221,6 @@ public class PipTouchHandler {
|
|||||||
mMenuController = menuController;
|
mMenuController = menuController;
|
||||||
mMenuController.addListener(new PipMenuListener());
|
mMenuController.addListener(new PipMenuListener());
|
||||||
mSnapAlgorithm = pipSnapAlgorithm;
|
mSnapAlgorithm = pipSnapAlgorithm;
|
||||||
mFlingAnimationUtils = new FlingAnimationUtils(context.getResources().getDisplayMetrics(),
|
|
||||||
2.5f);
|
|
||||||
mGesture = new DefaultPipTouchGesture();
|
mGesture = new DefaultPipTouchGesture();
|
||||||
mMotionHelper = new PipMotionHelper(mContext, pipTaskOrganizer, mMenuController,
|
mMotionHelper = new PipMotionHelper(mContext, pipTaskOrganizer, mMenuController,
|
||||||
mSnapAlgorithm, floatingContentCoordinator);
|
mSnapAlgorithm, floatingContentCoordinator);
|
||||||
@@ -239,13 +233,9 @@ public class PipTouchHandler {
|
|||||||
true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()));
|
true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()));
|
||||||
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
mExpandedShortestEdgeSize = res.getDimensionPixelSize(
|
|
||||||
R.dimen.pip_expanded_shortest_edge_size);
|
|
||||||
mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset);
|
|
||||||
mDismissAreaHeight = res.getDimensionPixelSize(R.dimen.floating_dismiss_gradient_height);
|
|
||||||
|
|
||||||
mEnableDismissDragToEdge = res.getBoolean(R.bool.config_pipEnableDismissDragToEdge);
|
mEnableDismissDragToEdge = res.getBoolean(R.bool.config_pipEnableDismissDragToEdge);
|
||||||
mEnableResize = res.getBoolean(R.bool.config_pipEnableResizeForMenu);
|
mEnableResize = res.getBoolean(R.bool.config_pipEnableResizeForMenu);
|
||||||
|
reloadResources();
|
||||||
|
|
||||||
// Register the listener for input consumer touch events
|
// Register the listener for input consumer touch events
|
||||||
inputConsumerController.setInputListener(this::handleTouchEvent);
|
inputConsumerController.setInputListener(this::handleTouchEvent);
|
||||||
@@ -256,22 +246,14 @@ public class PipTouchHandler {
|
|||||||
mConnection = new PipAccessibilityInteractionConnection(mMotionHelper,
|
mConnection = new PipAccessibilityInteractionConnection(mMotionHelper,
|
||||||
this::onAccessibilityShowMenu, mHandler);
|
this::onAccessibilityShowMenu, mHandler);
|
||||||
|
|
||||||
final int targetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size);
|
|
||||||
mTargetView = new DismissCircleView(context);
|
mTargetView = new DismissCircleView(context);
|
||||||
final FrameLayout.LayoutParams newParams =
|
|
||||||
new FrameLayout.LayoutParams(targetSize, targetSize);
|
|
||||||
newParams.gravity = Gravity.CENTER;
|
|
||||||
mTargetView.setLayoutParams(newParams);
|
|
||||||
|
|
||||||
mTargetViewContainer = new FrameLayout(context);
|
mTargetViewContainer = new FrameLayout(context);
|
||||||
mTargetViewContainer.setClipChildren(false);
|
mTargetViewContainer.setClipChildren(false);
|
||||||
mTargetViewContainer.addView(mTargetView);
|
mTargetViewContainer.addView(mTargetView);
|
||||||
|
|
||||||
mMagnetizedPip = mMotionHelper.getMagnetizedPip();
|
mMagnetizedPip = mMotionHelper.getMagnetizedPip();
|
||||||
mMagneticTarget = mMagnetizedPip.addTarget(mTargetView, 0);
|
mMagneticTarget = mMagnetizedPip.addTarget(mTargetView, 0);
|
||||||
|
updateMagneticTargetSize();
|
||||||
// Set the magnetic field radius equal to twice the size of the target.
|
|
||||||
mMagneticTarget.setMagneticFieldRadiusPx(targetSize * 2);
|
|
||||||
|
|
||||||
mMagnetizedPip.setPhysicsAnimatorUpdateListener(mMotionHelper.mResizePipUpdateListener);
|
mMagnetizedPip.setPhysicsAnimatorUpdateListener(mMotionHelper.mResizePipUpdateListener);
|
||||||
mMagnetizedPip.setMagnetListener(new MagnetizedObject.MagnetListener() {
|
mMagnetizedPip.setMagnetListener(new MagnetizedObject.MagnetListener() {
|
||||||
@@ -311,8 +293,34 @@ public class PipTouchHandler {
|
|||||||
mMagneticTargetAnimator = PhysicsAnimator.getInstance(mTargetView);
|
mMagneticTargetAnimator = PhysicsAnimator.getInstance(mTargetView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reloadResources() {
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
|
mBottomOffsetBufferPx = res.getDimensionPixelSize(R.dimen.pip_bottom_offset_buffer);
|
||||||
|
mExpandedShortestEdgeSize = res.getDimensionPixelSize(
|
||||||
|
R.dimen.pip_expanded_shortest_edge_size);
|
||||||
|
mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset);
|
||||||
|
mDismissAreaHeight = res.getDimensionPixelSize(R.dimen.floating_dismiss_gradient_height);
|
||||||
|
updateMagneticTargetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMagneticTargetSize() {
|
||||||
|
if (mTargetView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
|
final int targetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size);
|
||||||
|
final FrameLayout.LayoutParams newParams =
|
||||||
|
new FrameLayout.LayoutParams(targetSize, targetSize);
|
||||||
|
newParams.gravity = Gravity.CENTER;
|
||||||
|
mTargetView.setLayoutParams(newParams);
|
||||||
|
|
||||||
|
// Set the magnetic field radius equal to twice the size of the target.
|
||||||
|
mMagneticTarget.setMagneticFieldRadiusPx(targetSize * 2);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldShowResizeHandle() {
|
private boolean shouldShowResizeHandle() {
|
||||||
return !mPipBoundsHandler.hasSaveReentryBounds();
|
return !mPipBoundsHandler.hasSaveReentryBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTouchGesture(PipTouchGesture gesture) {
|
public void setTouchGesture(PipTouchGesture gesture) {
|
||||||
@@ -371,8 +379,9 @@ public class PipTouchHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onConfigurationChanged() {
|
public void onConfigurationChanged() {
|
||||||
mMotionHelper.onConfigurationChanged();
|
mPipResizeGestureHandler.onConfigurationChanged();
|
||||||
mMotionHelper.synchronizePinnedStackBounds();
|
mMotionHelper.synchronizePinnedStackBounds();
|
||||||
|
reloadResources();
|
||||||
|
|
||||||
// Recreate the dismiss target for the new orientation.
|
// Recreate the dismiss target for the new orientation.
|
||||||
createOrUpdateDismissTarget();
|
createOrUpdateDismissTarget();
|
||||||
@@ -436,8 +445,6 @@ public class PipTouchHandler {
|
|||||||
// Defer the update of the current movement bounds until after the user finishes
|
// Defer the update of the current movement bounds until after the user finishes
|
||||||
// touching the screen
|
// touching the screen
|
||||||
} else {
|
} else {
|
||||||
final float offsetBufferPx = BOTTOM_OFFSET_BUFFER_DP
|
|
||||||
* mContext.getResources().getDisplayMetrics().density;
|
|
||||||
final boolean isExpanded = mMenuState == MENU_STATE_FULL && willResizeMenu();
|
final boolean isExpanded = mMenuState == MENU_STATE_FULL && willResizeMenu();
|
||||||
final Rect toMovementBounds = isExpanded
|
final Rect toMovementBounds = isExpanded
|
||||||
? new Rect(expandedMovementBounds)
|
? new Rect(expandedMovementBounds)
|
||||||
@@ -453,8 +460,9 @@ public class PipTouchHandler {
|
|||||||
mSavedSnapFraction);
|
mSavedSnapFraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Math.min(prevBottom, toBottom) - offsetBufferPx) <= curBounds.top
|
if ((Math.min(prevBottom, toBottom) - mBottomOffsetBufferPx) <= curBounds.top
|
||||||
&& curBounds.top <= (Math.max(prevBottom, toBottom) + offsetBufferPx)) {
|
&& curBounds.top <= (Math.max(prevBottom, toBottom)
|
||||||
|
+ mBottomOffsetBufferPx)) {
|
||||||
mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top);
|
mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -997,7 +1005,6 @@ public class PipTouchHandler {
|
|||||||
pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
|
pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
|
||||||
pw.println(innerPrefix + "mSavedSnapFraction=" + mSavedSnapFraction);
|
pw.println(innerPrefix + "mSavedSnapFraction=" + mSavedSnapFraction);
|
||||||
pw.println(innerPrefix + "mEnableDragToEdgeDismiss=" + mEnableDismissDragToEdge);
|
pw.println(innerPrefix + "mEnableDragToEdgeDismiss=" + mEnableDismissDragToEdge);
|
||||||
mSnapAlgorithm.dump(pw, innerPrefix);
|
|
||||||
mTouchState.dump(pw, innerPrefix);
|
mTouchState.dump(pw, innerPrefix);
|
||||||
mMotionHelper.dump(pw, innerPrefix);
|
mMotionHelper.dump(pw, innerPrefix);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTI
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
@@ -33,6 +34,7 @@ import android.view.SurfaceControl;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -59,7 +61,8 @@ public class PipAnimationControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mPipAnimationController = new PipAnimationController(
|
mPipAnimationController = new PipAnimationController(
|
||||||
mContext, new PipSurfaceTransactionHelper(mContext));
|
mContext, new PipSurfaceTransactionHelper(mContext,
|
||||||
|
mock(ConfigurationController.class)));
|
||||||
mLeash = new SurfaceControl.Builder()
|
mLeash = new SurfaceControl.Builder()
|
||||||
.setContainerLayer()
|
.setContainerLayer()
|
||||||
.setName("FakeLeash")
|
.setName("FakeLeash")
|
||||||
|
|||||||
Reference in New Issue
Block a user