Merge "Make PipMotionHelper injectable" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6b7f69ef38
@@ -57,9 +57,10 @@ public class PipBoundsAlgorithm {
|
|||||||
private int mOverridableMinSize;
|
private int mOverridableMinSize;
|
||||||
private Point mScreenEdgeInsets;
|
private Point mScreenEdgeInsets;
|
||||||
|
|
||||||
public PipBoundsAlgorithm(Context context, @NonNull PipBoundsState pipBoundsState) {
|
public PipBoundsAlgorithm(Context context, @NonNull PipBoundsState pipBoundsState,
|
||||||
|
@NonNull PipSnapAlgorithm pipSnapAlgorithm) {
|
||||||
mPipBoundsState = pipBoundsState;
|
mPipBoundsState = pipBoundsState;
|
||||||
mSnapAlgorithm = new PipSnapAlgorithm();
|
mSnapAlgorithm = pipSnapAlgorithm;
|
||||||
reloadResources(context);
|
reloadResources(context);
|
||||||
// Initialize the aspect ratio to the default aspect ratio. Don't do this in reload
|
// Initialize the aspect ratio to the default aspect ratio. Don't do this in reload
|
||||||
// resources as it would clobber mAspectRatio when entering PiP from fullscreen which
|
// resources as it would clobber mAspectRatio when entering PiP from fullscreen which
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import com.android.wm.shell.pip.PipAnimationController;
|
|||||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||||
import com.android.wm.shell.pip.PipBoundsState;
|
import com.android.wm.shell.pip.PipBoundsState;
|
||||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||||
import com.android.wm.shell.pip.PipTransitionController;
|
|
||||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -158,7 +157,7 @@ public class PipTouchHandler {
|
|||||||
PipBoundsAlgorithm pipBoundsAlgorithm,
|
PipBoundsAlgorithm pipBoundsAlgorithm,
|
||||||
@NonNull PipBoundsState pipBoundsState,
|
@NonNull PipBoundsState pipBoundsState,
|
||||||
PipTaskOrganizer pipTaskOrganizer,
|
PipTaskOrganizer pipTaskOrganizer,
|
||||||
PipTransitionController pipTransitionController,
|
PipMotionHelper pipMotionHelper,
|
||||||
FloatingContentCoordinator floatingContentCoordinator,
|
FloatingContentCoordinator floatingContentCoordinator,
|
||||||
PipUiEventLogger pipUiEventLogger,
|
PipUiEventLogger pipUiEventLogger,
|
||||||
ShellExecutor mainExecutor) {
|
ShellExecutor mainExecutor) {
|
||||||
@@ -173,9 +172,7 @@ public class PipTouchHandler {
|
|||||||
mFloatingContentCoordinator = floatingContentCoordinator;
|
mFloatingContentCoordinator = floatingContentCoordinator;
|
||||||
mMenuController.addListener(new PipMenuListener());
|
mMenuController.addListener(new PipMenuListener());
|
||||||
mGesture = new DefaultPipTouchGesture();
|
mGesture = new DefaultPipTouchGesture();
|
||||||
mMotionHelper = new PipMotionHelper(mContext, pipBoundsState, pipTaskOrganizer,
|
mMotionHelper = pipMotionHelper;
|
||||||
mMenuController, mPipBoundsAlgorithm.getSnapAlgorithm(), pipTransitionController,
|
|
||||||
floatingContentCoordinator);
|
|
||||||
mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger,
|
mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger,
|
||||||
mMotionHelper, mainExecutor);
|
mMotionHelper, mainExecutor);
|
||||||
mPipResizeGestureHandler =
|
mPipResizeGestureHandler =
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.testing.AndroidTestingRunner;
|
|||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.testing.TestableResources;
|
import android.testing.TestableResources;
|
||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
import android.view.Display;
|
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
|
||||||
@@ -58,11 +57,13 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
|
|||||||
private DisplayInfo mDefaultDisplayInfo;
|
private DisplayInfo mDefaultDisplayInfo;
|
||||||
private PipBoundsState mPipBoundsState;
|
private PipBoundsState mPipBoundsState;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
initializeMockResources();
|
initializeMockResources();
|
||||||
mPipBoundsState = new PipBoundsState(mContext);
|
mPipBoundsState = new PipBoundsState(mContext);
|
||||||
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState);
|
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState,
|
||||||
|
new PipSnapAlgorithm());
|
||||||
|
|
||||||
mPipBoundsState.setDisplayLayout(
|
mPipBoundsState.setDisplayLayout(
|
||||||
new DisplayLayout(mDefaultDisplayInfo, mContext.getResources(), true, true));
|
new DisplayLayout(mDefaultDisplayInfo, mContext.getResources(), true, true));
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ public class PipTaskOrganizerTest extends ShellTestCase {
|
|||||||
mComponent1 = new ComponentName(mContext, "component1");
|
mComponent1 = new ComponentName(mContext, "component1");
|
||||||
mComponent2 = new ComponentName(mContext, "component2");
|
mComponent2 = new ComponentName(mContext, "component2");
|
||||||
mPipBoundsState = new PipBoundsState(mContext);
|
mPipBoundsState = new PipBoundsState(mContext);
|
||||||
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState);
|
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState,
|
||||||
|
new PipSnapAlgorithm());
|
||||||
mMainExecutor = new TestShellExecutor();
|
mMainExecutor = new TestShellExecutor();
|
||||||
mSpiedPipTaskOrganizer = spy(new PipTaskOrganizer(mContext,
|
mSpiedPipTaskOrganizer = spy(new PipTaskOrganizer(mContext,
|
||||||
mMockSyncTransactionQueue, mPipBoundsState,
|
mMockSyncTransactionQueue, mPipBoundsState,
|
||||||
|
|||||||
@@ -99,12 +99,14 @@ public class PipTouchHandlerTest extends ShellTestCase {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mPipBoundsState = new PipBoundsState(mContext);
|
mPipBoundsState = new PipBoundsState(mContext);
|
||||||
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState);
|
|
||||||
mPipSnapAlgorithm = mPipBoundsAlgorithm.getSnapAlgorithm();
|
|
||||||
mPipSnapAlgorithm = new PipSnapAlgorithm();
|
mPipSnapAlgorithm = new PipSnapAlgorithm();
|
||||||
|
mPipBoundsAlgorithm = new PipBoundsAlgorithm(mContext, mPipBoundsState, mPipSnapAlgorithm);
|
||||||
|
PipMotionHelper pipMotionHelper = new PipMotionHelper(mContext, mPipBoundsState,
|
||||||
|
mPipTaskOrganizer, mPhonePipMenuController, mPipSnapAlgorithm,
|
||||||
|
mMockPipTransitionController, mFloatingContentCoordinator);
|
||||||
mPipTouchHandler = new PipTouchHandler(mContext, mPhonePipMenuController,
|
mPipTouchHandler = new PipTouchHandler(mContext, mPhonePipMenuController,
|
||||||
mPipBoundsAlgorithm, mPipBoundsState, mPipTaskOrganizer,
|
mPipBoundsAlgorithm, mPipBoundsState, mPipTaskOrganizer,
|
||||||
mMockPipTransitionController, mFloatingContentCoordinator, mPipUiEventLogger,
|
pipMotionHelper, mFloatingContentCoordinator, mPipUiEventLogger,
|
||||||
mMainExecutor);
|
mMainExecutor);
|
||||||
mPipTouchHandler.init();
|
mPipTouchHandler.init();
|
||||||
mMotionHelper = Mockito.spy(mPipTouchHandler.getMotionHelper());
|
mMotionHelper = Mockito.spy(mPipTouchHandler.getMotionHelper());
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.android.wm.shell.pip.PipAnimationController;
|
|||||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||||
import com.android.wm.shell.pip.PipBoundsState;
|
import com.android.wm.shell.pip.PipBoundsState;
|
||||||
import com.android.wm.shell.pip.PipMediaController;
|
import com.android.wm.shell.pip.PipMediaController;
|
||||||
|
import com.android.wm.shell.pip.PipSnapAlgorithm;
|
||||||
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||||
import com.android.wm.shell.pip.PipTransitionController;
|
import com.android.wm.shell.pip.PipTransitionController;
|
||||||
@@ -85,9 +86,15 @@ public abstract class TvPipModule {
|
|||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
@Provides
|
@Provides
|
||||||
static PipBoundsAlgorithm providePipBoundsHandler(Context context,
|
static PipSnapAlgorithm providePipSnapAlgorithm() {
|
||||||
PipBoundsState pipBoundsState) {
|
return new PipSnapAlgorithm();
|
||||||
return new PipBoundsAlgorithm(context, pipBoundsState);
|
}
|
||||||
|
|
||||||
|
@WMSingleton
|
||||||
|
@Provides
|
||||||
|
static PipBoundsAlgorithm providePipBoundsAlgorithm(Context context,
|
||||||
|
PipBoundsState pipBoundsState, PipSnapAlgorithm pipSnapAlgorithm) {
|
||||||
|
return new PipBoundsAlgorithm(context, pipBoundsState, pipSnapAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import com.android.wm.shell.pip.PipAnimationController;
|
|||||||
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
import com.android.wm.shell.pip.PipBoundsAlgorithm;
|
||||||
import com.android.wm.shell.pip.PipBoundsState;
|
import com.android.wm.shell.pip.PipBoundsState;
|
||||||
import com.android.wm.shell.pip.PipMediaController;
|
import com.android.wm.shell.pip.PipMediaController;
|
||||||
|
import com.android.wm.shell.pip.PipSnapAlgorithm;
|
||||||
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
|
||||||
import com.android.wm.shell.pip.PipTaskOrganizer;
|
import com.android.wm.shell.pip.PipTaskOrganizer;
|
||||||
import com.android.wm.shell.pip.PipTransition;
|
import com.android.wm.shell.pip.PipTransition;
|
||||||
@@ -51,6 +52,7 @@ import com.android.wm.shell.pip.PipUiEventLogger;
|
|||||||
import com.android.wm.shell.pip.phone.PhonePipMenuController;
|
import com.android.wm.shell.pip.phone.PhonePipMenuController;
|
||||||
import com.android.wm.shell.pip.phone.PipAppOpsListener;
|
import com.android.wm.shell.pip.phone.PipAppOpsListener;
|
||||||
import com.android.wm.shell.pip.phone.PipController;
|
import com.android.wm.shell.pip.phone.PipController;
|
||||||
|
import com.android.wm.shell.pip.phone.PipMotionHelper;
|
||||||
import com.android.wm.shell.pip.phone.PipTouchHandler;
|
import com.android.wm.shell.pip.phone.PipTouchHandler;
|
||||||
import com.android.wm.shell.transition.Transitions;
|
import com.android.wm.shell.transition.Transitions;
|
||||||
|
|
||||||
@@ -140,9 +142,15 @@ public class WMShellModule {
|
|||||||
|
|
||||||
@WMSingleton
|
@WMSingleton
|
||||||
@Provides
|
@Provides
|
||||||
static PipBoundsAlgorithm providesPipBoundsHandler(Context context,
|
static PipSnapAlgorithm providePipSnapAlgorithm() {
|
||||||
PipBoundsState pipBoundsState) {
|
return new PipSnapAlgorithm();
|
||||||
return new PipBoundsAlgorithm(context, pipBoundsState);
|
}
|
||||||
|
|
||||||
|
@WMSingleton
|
||||||
|
@Provides
|
||||||
|
static PipBoundsAlgorithm providesPipBoundsAlgorithm(Context context,
|
||||||
|
PipBoundsState pipBoundsState, PipSnapAlgorithm pipSnapAlgorithm) {
|
||||||
|
return new PipBoundsAlgorithm(context, pipBoundsState, pipSnapAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler is used by Icon.loadDrawableAsync
|
// Handler is used by Icon.loadDrawableAsync
|
||||||
@@ -162,12 +170,12 @@ public class WMShellModule {
|
|||||||
PhonePipMenuController menuPhoneController, PipBoundsAlgorithm pipBoundsAlgorithm,
|
PhonePipMenuController menuPhoneController, PipBoundsAlgorithm pipBoundsAlgorithm,
|
||||||
PipBoundsState pipBoundsState,
|
PipBoundsState pipBoundsState,
|
||||||
PipTaskOrganizer pipTaskOrganizer,
|
PipTaskOrganizer pipTaskOrganizer,
|
||||||
PipTransitionController pipTransitionController,
|
PipMotionHelper pipMotionHelper,
|
||||||
FloatingContentCoordinator floatingContentCoordinator,
|
FloatingContentCoordinator floatingContentCoordinator,
|
||||||
PipUiEventLogger pipUiEventLogger,
|
PipUiEventLogger pipUiEventLogger,
|
||||||
@ShellMainThread ShellExecutor mainExecutor) {
|
@ShellMainThread ShellExecutor mainExecutor) {
|
||||||
return new PipTouchHandler(context, menuPhoneController, pipBoundsAlgorithm,
|
return new PipTouchHandler(context, menuPhoneController, pipBoundsAlgorithm,
|
||||||
pipBoundsState, pipTaskOrganizer, pipTransitionController,
|
pipBoundsState, pipTaskOrganizer, pipMotionHelper,
|
||||||
floatingContentCoordinator, pipUiEventLogger, mainExecutor);
|
floatingContentCoordinator, pipUiEventLogger, mainExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,4 +216,16 @@ public class WMShellModule {
|
|||||||
return new PipTransition(context, pipBoundsState, pipMenuController,
|
return new PipTransition(context, pipBoundsState, pipMenuController,
|
||||||
pipBoundsAlgorithm, pipAnimationController, transitions, shellTaskOrganizer);
|
pipBoundsAlgorithm, pipAnimationController, transitions, shellTaskOrganizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WMSingleton
|
||||||
|
@Provides
|
||||||
|
static PipMotionHelper providePipMotionHelper(Context context,
|
||||||
|
PipBoundsState pipBoundsState, PipTaskOrganizer pipTaskOrganizer,
|
||||||
|
PhonePipMenuController menuController, PipSnapAlgorithm pipSnapAlgorithm,
|
||||||
|
PipTransitionController pipTransitionController,
|
||||||
|
FloatingContentCoordinator floatingContentCoordinator) {
|
||||||
|
return new PipMotionHelper(context, pipBoundsState, pipTaskOrganizer,
|
||||||
|
menuController, pipSnapAlgorithm, pipTransitionController,
|
||||||
|
floatingContentCoordinator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user