Merge "Minor pip menu changes" into sc-dev

This commit is contained in:
Winson Chung
2021-03-30 22:33:43 +00:00
committed by Android (Google) Code Review
4 changed files with 29 additions and 19 deletions

View File

@@ -15,7 +15,13 @@
limitations under the License.
-->
<resources>
<!-- Animation duration for resizing of PIP when entering/exiting. -->
<!-- Animation duration for PIP when entering. -->
<integer name="config_pipEnterAnimationDuration">425</integer>
<!-- Animation duration for PIP when exiting. -->
<integer name="config_pipExitAnimationDuration">250</integer>
<!-- Animation duration for resizing of PIP. -->
<integer name="config_pipResizeAnimationDuration">425</integer>
<!-- Allow dragging the PIP to a location to close it -->

View File

@@ -63,6 +63,7 @@ import android.window.WindowContainerTransaction;
import com.android.internal.annotations.VisibleForTesting;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
@@ -131,7 +132,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
private final PipAnimationController mPipAnimationController;
private final PipTransitionController mPipTransitionController;
private final PipUiEventLogger mPipUiEventLoggerLogger;
private final int mEnterExitAnimationDuration;
private final int mEnterAnimationDuration;
private final int mExitAnimationDuration;
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
private final Optional<LegacySplitScreenController> mSplitScreenOptional;
protected final ShellTaskOrganizer mTaskOrganizer;
@@ -225,8 +227,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mPipBoundsAlgorithm = boundsHandler;
mPipMenuController = pipMenuController;
mPipTransitionController = pipTransitionController;
mEnterExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipResizeAnimationDuration);
mEnterAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipEnterAnimationDuration);
mExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipExitAnimationDuration);
mSurfaceTransactionHelper = surfaceTransactionHelper;
mPipAnimationController = pipAnimationController;
mPipUiEventLoggerLogger = pipUiEventLogger;
@@ -378,12 +382,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
}
// removePipImmediately is expected when the following animation finishes.
mPipAnimationController
ValueAnimator animator = mPipAnimationController
.getAnimator(mTaskInfo, mLeash, mPipBoundsState.getBounds(), 1f, 0f)
.setTransitionDirection(TRANSITION_DIRECTION_REMOVE_STACK)
.setPipAnimationCallback(mPipAnimationCallback)
.setDuration(mEnterExitAnimationDuration)
.start();
.setPipAnimationCallback(mPipAnimationCallback);
animator.setDuration(mExitAnimationDuration);
animator.setInterpolator(Interpolators.ALPHA_OUT);
animator.start();
mState = State.EXITING_PIP;
}
@@ -465,11 +470,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
final Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
info.pictureInPictureParams, currentBounds);
scheduleAnimateResizePip(currentBounds, destinationBounds, 0 /* startingAngle */,
sourceHintRect, TRANSITION_DIRECTION_TO_PIP, mEnterExitAnimationDuration,
sourceHintRect, TRANSITION_DIRECTION_TO_PIP, mEnterAnimationDuration,
null /* updateBoundsCallback */);
mState = State.ENTERING_PIP;
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
enterPipWithAlphaAnimation(destinationBounds, mEnterExitAnimationDuration);
enterPipWithAlphaAnimation(destinationBounds, mEnterAnimationDuration);
mOneShotAnimationType = ANIM_TYPE_BOUNDS;
} else {
throw new RuntimeException("Unrecognized animation type: " + mOneShotAnimationType);
@@ -596,7 +601,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
final Rect destinationBounds = mPipBoundsAlgorithm.getAdjustedDestinationBounds(
mPipBoundsState.getBounds(), mPipBoundsState.getAspectRatio());
Objects.requireNonNull(destinationBounds, "Missing destination bounds");
scheduleAnimateResizePip(destinationBounds, mEnterExitAnimationDuration,
scheduleAnimateResizePip(destinationBounds, mEnterAnimationDuration,
null /* updateBoundsCallback */);
}
@@ -965,7 +970,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mMainExecutor.execute(() -> {
// Start animation to fade out the snapshot.
final ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0.0f);
animator.setDuration(mEnterExitAnimationDuration);
animator.setDuration(mEnterAnimationDuration);
animator.addUpdateListener(animation -> {
final float alpha = (float) animation.getAnimatedValue();
final SurfaceControl.Transaction transaction =

View File

@@ -244,9 +244,11 @@ public class PhonePipMenuController implements PipMenuController {
*/
public void showMenuWithPossibleDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout,
boolean willResizeMenu, boolean showResizeHandle) {
// hide all visible controls including close button and etc. first, this is to ensure
// menu is totally invisible during the transition to eliminate unpleasant artifacts
fadeOutMenu();
if (willResizeMenu) {
// hide all visible controls including close button and etc. first, this is to ensure
// menu is totally invisible during the transition to eliminate unpleasant artifacts
fadeOutMenu();
}
showMenuInternal(menuState, stackBounds, allowMenuTimeout, willResizeMenu,
willResizeMenu /* withDelay=willResizeMenu here */, showResizeHandle);
}

View File

@@ -76,7 +76,6 @@ public class PipMenuView extends FrameLayout {
private static final int INITIAL_DISMISS_DELAY = 3500;
private static final int POST_INTERACTION_DISMISS_DELAY = 2000;
private static final long MENU_FADE_DURATION = 125;
private static final long MENU_SLOW_FADE_DURATION = 175;
private static final long MENU_SHOW_ON_EXPAND_START_DELAY = 30;
private static final float MENU_BACKGROUND_ALPHA = 0.3f;
@@ -253,9 +252,7 @@ public class PipMenuView extends FrameLayout {
mMenuContainerAnimator.playTogether(dismissAnim, resizeAnim);
}
mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN);
mMenuContainerAnimator.setDuration(menuState == MENU_STATE_CLOSE
? MENU_FADE_DURATION
: MENU_SLOW_FADE_DURATION);
mMenuContainerAnimator.setDuration(MENU_FADE_DURATION);
if (allowMenuTimeout) {
mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() {
@Override