From 54561fe6a1e2090e6dd16904ee31b0cde1fcb706 Mon Sep 17 00:00:00 2001 From: Jacqueline Bronger Date: Thu, 30 Mar 2023 16:36:57 +0200 Subject: [PATCH] TV PiP: fix menu buttons orientation Fixes the PiP menu buttons orientation after double pressing expand/collapse by only setting the orientation after the transition has finished. Bug: 274750024 Test: manual - start expanded PiP with regular PiP orientation being different from the expanded one. Press collapse once: orientation should change with the PiP, double click: orientation should still match the PiP. Change-Id: I3bfbe7d68f73b31a5ccb199c1e6c6c6a4d8dd3e2 --- .../wm/shell/pip/tv/TvPipMenuView.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java index ccf65c2996136..6eb719ba60a36 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java @@ -92,7 +92,6 @@ public class TvPipMenuView extends FrameLayout implements TvPipActionsProvider.L private @TvPipMenuController.TvPipMenuMode int mCurrentMenuMode = MODE_NO_MENU; private final Rect mCurrentPipBounds = new Rect(); private int mCurrentPipGravity; - private boolean mSwitchingOrientation; private final AccessibilityManager mA11yManager; private final Handler mMainHandler; @@ -176,17 +175,12 @@ public class TvPipMenuView extends FrameLayout implements TvPipActionsProvider.L } if (mCurrentMenuMode == MODE_ALL_ACTIONS_MENU) { - mSwitchingOrientation = true; + // Fade out while orientation change is ongoing and fade back in once transition is + // finished. mActionButtonsRecyclerView.animate() .alpha(0) .setInterpolator(TvPipInterpolators.EXIT) - .setDuration(mResizeAnimationDuration / 2) - .withEndAction(() -> { - mButtonLayoutManager.setOrientation(vertical - ? LinearLayoutManager.VERTICAL : LinearLayoutManager.HORIZONTAL); - // Only make buttons visible again in onPipTransitionFinished to keep in - // sync with PiP content alpha animation. - }); + .setDuration(mResizeAnimationDuration / 2); } else { mButtonLayoutManager.setOrientation(vertical ? LinearLayoutManager.VERTICAL : LinearLayoutManager.HORIZONTAL); @@ -208,13 +202,16 @@ public class TvPipMenuView extends FrameLayout implements TvPipActionsProvider.L mEduTextDrawer.init(); } - if (mSwitchingOrientation) { + mButtonLayoutManager.setOrientation( + mCurrentPipBounds.height() > mCurrentPipBounds.width() + ? LinearLayoutManager.VERTICAL : LinearLayoutManager.HORIZONTAL); + if (mCurrentMenuMode == MODE_ALL_ACTIONS_MENU + && mActionButtonsRecyclerView.getAlpha() != 1f) { mActionButtonsRecyclerView.animate() .alpha(1) .setInterpolator(TvPipInterpolators.ENTER) .setDuration(mResizeAnimationDuration / 2); } - mSwitchingOrientation = false; } /**