Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +3 −3 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public class PipResizeGestureHandler { // For pinch-resize private boolean mThresholdCrossed0; private boolean mThresholdCrossed1; private boolean mUsingPinchToZoom = false; private boolean mUsingPinchToZoom = true; private float mAngle = 0; int mFirstIndex = -1; int mSecondIndex = -1; Loading Loading @@ -139,7 +139,7 @@ public class PipResizeGestureHandler { mEnablePinchResize = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SYSTEMUI, PIP_PINCH_RESIZE, /* defaultValue = */ false); /* defaultValue = */ true); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, mMainExecutor, new DeviceConfig.OnPropertiesChangedListener() { Loading @@ -147,7 +147,7 @@ public class PipResizeGestureHandler { public void onPropertiesChanged(DeviceConfig.Properties properties) { if (properties.getKeyset().contains(PIP_PINCH_RESIZE)) { mEnablePinchResize = properties.getBoolean( PIP_PINCH_RESIZE, /* defaultValue = */ false); PIP_PINCH_RESIZE, /* defaultValue = */ true); } } }); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -63,8 +63,9 @@ import java.util.function.Consumer; * the PIP. */ public class PipTouchHandler { @VisibleForTesting static final float MINIMUM_SIZE_PERCENT = 0.4f; private static final String TAG = "PipTouchHandler"; private static final float MINIMUM_SIZE_PERCENT = 0.4f; private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f; // Allow PIP to resize to a slightly bigger state upon touch Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java +28 −34 Original line number Diff line number Diff line Loading @@ -22,16 +22,14 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.graphics.Point; import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.Size; import androidx.test.filters.SmallTest; import com.android.wm.shell.R; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.FloatingContentCoordinator; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.pip.PipBoundsAlgorithm; Loading Loading @@ -59,6 +57,9 @@ import org.mockito.MockitoAnnotations; @TestableLooper.RunWithLooper(setAsMainLooper = true) public class PipTouchHandlerTest extends ShellTestCase { private static final int INSET = 10; private static final int PIP_LENGTH = 100; private PipTouchHandler mPipTouchHandler; @Mock Loading @@ -85,8 +86,9 @@ public class PipTouchHandlerTest extends ShellTestCase { private PipMotionHelper mMotionHelper; private PipResizeGestureHandler mPipResizeGestureHandler; private DisplayLayout mDisplayLayout; private Rect mInsetBounds; private Rect mMinBounds; private Rect mPipBounds; private Rect mCurBounds; private boolean mFromImeAdjustment; private boolean mFromShelfAdjustment; Loading @@ -109,12 +111,18 @@ public class PipTouchHandlerTest extends ShellTestCase { mPipTouchHandler.setPipMotionHelper(mMotionHelper); mPipTouchHandler.setPipResizeGestureHandler(mPipResizeGestureHandler); // Assume a display of 1000 x 1000 // inset of 10 mInsetBounds = new Rect(10, 10, 990, 990); mDisplayLayout = new DisplayLayout(mContext, mContext.getDisplay()); mPipBoundsState.setDisplayLayout(mDisplayLayout); mInsetBounds = new Rect(mPipBoundsState.getDisplayBounds().left + INSET, mPipBoundsState.getDisplayBounds().top + INSET, mPipBoundsState.getDisplayBounds().right - INSET, mPipBoundsState.getDisplayBounds().bottom - INSET); // minBounds of 100x100 bottom right corner mMinBounds = new Rect(890, 890, 990, 990); mCurBounds = new Rect(mMinBounds); mPipBounds = new Rect(mPipBoundsState.getDisplayBounds().right - INSET - PIP_LENGTH, mPipBoundsState.getDisplayBounds().bottom - INSET - PIP_LENGTH, mPipBoundsState.getDisplayBounds().right - INSET, mPipBoundsState.getDisplayBounds().bottom - INSET); mCurBounds = new Rect(mPipBounds); mFromImeAdjustment = false; mFromShelfAdjustment = false; mDisplayRotation = 0; Loading @@ -122,37 +130,23 @@ public class PipTouchHandlerTest extends ShellTestCase { } @Test public void updateMovementBounds_minBounds() { Rect expectedMinMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(mMinBounds, mInsetBounds, expectedMinMovementBounds, public void updateMovementBounds_minMaxBounds() { final int shorterLength = Math.min(mPipBoundsState.getDisplayBounds().width(), mPipBoundsState.getDisplayBounds().height()); Rect expectedMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(mPipBounds, mInsetBounds, expectedMovementBounds, 0); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); assertEquals(expectedMinMovementBounds, mPipBoundsState.getNormalMovementBounds()); assertEquals(expectedMovementBounds, mPipBoundsState.getNormalMovementBounds()); verify(mPipResizeGestureHandler, times(1)) .updateMinSize(mMinBounds.width(), mMinBounds.height()); } @Test public void updateMovementBounds_maxBounds() { Point displaySize = new Point(); mContext.getDisplay().getRealSize(displaySize); Size maxSize = mPipBoundsAlgorithm.getSizeForAspectRatio(1, mContext.getResources().getDimensionPixelSize( R.dimen.pip_expanded_shortest_edge_size), displaySize.x, displaySize.y); Rect maxBounds = new Rect(0, 0, maxSize.getWidth(), maxSize.getHeight()); Rect expectedMaxMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(maxBounds, mInsetBounds, expectedMaxMovementBounds, 0); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); .updateMinSize(mPipBounds.width(), mPipBounds.height()); assertEquals(expectedMaxMovementBounds, mPipBoundsState.getExpandedMovementBounds()); verify(mPipResizeGestureHandler, times(1)) .updateMaxSize(maxBounds.width(), maxBounds.height()); .updateMaxSize(shorterLength - 2 * mInsetBounds.left, shorterLength - 2 * mInsetBounds.left); } @Test Loading @@ -160,7 +154,7 @@ public class PipTouchHandlerTest extends ShellTestCase { mFromImeAdjustment = true; mPipTouchHandler.onImeVisibilityChanged(true /* imeVisible */, mImeHeight); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); verify(mMotionHelper, times(1)).animateToOffset(any(), anyInt()); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +3 −3 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public class PipResizeGestureHandler { // For pinch-resize private boolean mThresholdCrossed0; private boolean mThresholdCrossed1; private boolean mUsingPinchToZoom = false; private boolean mUsingPinchToZoom = true; private float mAngle = 0; int mFirstIndex = -1; int mSecondIndex = -1; Loading Loading @@ -139,7 +139,7 @@ public class PipResizeGestureHandler { mEnablePinchResize = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SYSTEMUI, PIP_PINCH_RESIZE, /* defaultValue = */ false); /* defaultValue = */ true); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, mMainExecutor, new DeviceConfig.OnPropertiesChangedListener() { Loading @@ -147,7 +147,7 @@ public class PipResizeGestureHandler { public void onPropertiesChanged(DeviceConfig.Properties properties) { if (properties.getKeyset().contains(PIP_PINCH_RESIZE)) { mEnablePinchResize = properties.getBoolean( PIP_PINCH_RESIZE, /* defaultValue = */ false); PIP_PINCH_RESIZE, /* defaultValue = */ true); } } }); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -63,8 +63,9 @@ import java.util.function.Consumer; * the PIP. */ public class PipTouchHandler { @VisibleForTesting static final float MINIMUM_SIZE_PERCENT = 0.4f; private static final String TAG = "PipTouchHandler"; private static final float MINIMUM_SIZE_PERCENT = 0.4f; private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f; // Allow PIP to resize to a slightly bigger state upon touch Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java +28 −34 Original line number Diff line number Diff line Loading @@ -22,16 +22,14 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.graphics.Point; import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.Size; import androidx.test.filters.SmallTest; import com.android.wm.shell.R; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.FloatingContentCoordinator; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.pip.PipBoundsAlgorithm; Loading Loading @@ -59,6 +57,9 @@ import org.mockito.MockitoAnnotations; @TestableLooper.RunWithLooper(setAsMainLooper = true) public class PipTouchHandlerTest extends ShellTestCase { private static final int INSET = 10; private static final int PIP_LENGTH = 100; private PipTouchHandler mPipTouchHandler; @Mock Loading @@ -85,8 +86,9 @@ public class PipTouchHandlerTest extends ShellTestCase { private PipMotionHelper mMotionHelper; private PipResizeGestureHandler mPipResizeGestureHandler; private DisplayLayout mDisplayLayout; private Rect mInsetBounds; private Rect mMinBounds; private Rect mPipBounds; private Rect mCurBounds; private boolean mFromImeAdjustment; private boolean mFromShelfAdjustment; Loading @@ -109,12 +111,18 @@ public class PipTouchHandlerTest extends ShellTestCase { mPipTouchHandler.setPipMotionHelper(mMotionHelper); mPipTouchHandler.setPipResizeGestureHandler(mPipResizeGestureHandler); // Assume a display of 1000 x 1000 // inset of 10 mInsetBounds = new Rect(10, 10, 990, 990); mDisplayLayout = new DisplayLayout(mContext, mContext.getDisplay()); mPipBoundsState.setDisplayLayout(mDisplayLayout); mInsetBounds = new Rect(mPipBoundsState.getDisplayBounds().left + INSET, mPipBoundsState.getDisplayBounds().top + INSET, mPipBoundsState.getDisplayBounds().right - INSET, mPipBoundsState.getDisplayBounds().bottom - INSET); // minBounds of 100x100 bottom right corner mMinBounds = new Rect(890, 890, 990, 990); mCurBounds = new Rect(mMinBounds); mPipBounds = new Rect(mPipBoundsState.getDisplayBounds().right - INSET - PIP_LENGTH, mPipBoundsState.getDisplayBounds().bottom - INSET - PIP_LENGTH, mPipBoundsState.getDisplayBounds().right - INSET, mPipBoundsState.getDisplayBounds().bottom - INSET); mCurBounds = new Rect(mPipBounds); mFromImeAdjustment = false; mFromShelfAdjustment = false; mDisplayRotation = 0; Loading @@ -122,37 +130,23 @@ public class PipTouchHandlerTest extends ShellTestCase { } @Test public void updateMovementBounds_minBounds() { Rect expectedMinMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(mMinBounds, mInsetBounds, expectedMinMovementBounds, public void updateMovementBounds_minMaxBounds() { final int shorterLength = Math.min(mPipBoundsState.getDisplayBounds().width(), mPipBoundsState.getDisplayBounds().height()); Rect expectedMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(mPipBounds, mInsetBounds, expectedMovementBounds, 0); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); assertEquals(expectedMinMovementBounds, mPipBoundsState.getNormalMovementBounds()); assertEquals(expectedMovementBounds, mPipBoundsState.getNormalMovementBounds()); verify(mPipResizeGestureHandler, times(1)) .updateMinSize(mMinBounds.width(), mMinBounds.height()); } @Test public void updateMovementBounds_maxBounds() { Point displaySize = new Point(); mContext.getDisplay().getRealSize(displaySize); Size maxSize = mPipBoundsAlgorithm.getSizeForAspectRatio(1, mContext.getResources().getDimensionPixelSize( R.dimen.pip_expanded_shortest_edge_size), displaySize.x, displaySize.y); Rect maxBounds = new Rect(0, 0, maxSize.getWidth(), maxSize.getHeight()); Rect expectedMaxMovementBounds = new Rect(); mPipBoundsAlgorithm.getMovementBounds(maxBounds, mInsetBounds, expectedMaxMovementBounds, 0); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); .updateMinSize(mPipBounds.width(), mPipBounds.height()); assertEquals(expectedMaxMovementBounds, mPipBoundsState.getExpandedMovementBounds()); verify(mPipResizeGestureHandler, times(1)) .updateMaxSize(maxBounds.width(), maxBounds.height()); .updateMaxSize(shorterLength - 2 * mInsetBounds.left, shorterLength - 2 * mInsetBounds.left); } @Test Loading @@ -160,7 +154,7 @@ public class PipTouchHandlerTest extends ShellTestCase { mFromImeAdjustment = true; mPipTouchHandler.onImeVisibilityChanged(true /* imeVisible */, mImeHeight); mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mMinBounds, mCurBounds, mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds, mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); verify(mMotionHelper, times(1)).animateToOffset(any(), anyInt()); Loading