Merge "Move attach/detach PiP menu calls to onTaskAppear/Vanish."

This commit is contained in:
Ben Lin
2020-11-06 19:07:15 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 7 deletions

View File

@@ -495,6 +495,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mOnDisplayIdChangeCallback.accept(info.displayId);
}
mMenuActivityController.onTaskAppeared();
if (mShouldIgnoreEnteringPipTransition) {
final Rect destinationBounds = mPipBoundsState.getBounds();
// animation is finished in the Launcher and here we directly apply the final touch.
@@ -666,6 +668,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mPictureInPictureParams = null;
mState = State.UNDEFINED;
mPipUiEventLoggerLogger.setTaskInfo(null);
mMenuActivityController.onTaskVanished();
}
@Override

View File

@@ -277,7 +277,6 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
mMainExecutor.execute(() -> {
mTouchHandler.onActivityPinned();
mMediaController.onActivityPinned();
mMenuController.onActivityPinned();
mAppOpsListener.onActivityPinned(packageName);
});
}
@@ -285,7 +284,6 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
@Override
public void onActivityUnpinned(ComponentName topActivity) {
mMainExecutor.execute(() -> {
mMenuController.onActivityUnpinned();
mTouchHandler.onActivityUnpinned(topActivity);
mAppOpsListener.onActivityUnpinned();
});

View File

@@ -135,15 +135,22 @@ public class PipMenuActivityController {
return mPipMenuView != null && mMenuState != MENU_STATE_NONE;
}
public void onActivityPinned() {
/**
* Attach the menu when the PiP task first appears.
*/
public void onTaskAppeared() {
attachPipMenuView();
}
public void onActivityUnpinned() {
/**
* Detach the menu when the PiP task is gone.
*/
public void onTaskVanished() {
hideMenu();
detachPipMenuView();
}
public void onPinnedStackAnimationEnded() {
if (isMenuVisible()) {
mPipMenuView.onPipAnimationEnded();
@@ -151,10 +158,11 @@ public class PipMenuActivityController {
}
private void attachPipMenuView() {
if (mPipMenuView == null) {
mPipMenuView = new PipMenuView(mContext, this);
// In case detach was not called (e.g. PIP unexpectedly closed)
if (mPipMenuView != null) {
detachPipMenuView();
}
mPipMenuView = new PipMenuView(mContext, this);
mSystemWindows.addView(mPipMenuView, getPipMenuLayoutParams(0, 0), 0, SHELL_ROOT_LAYER_PIP);
}