Merge "Hide PiP menu when expanding" into rvc-dev

This commit is contained in:
Hongwei Wang
2020-05-27 04:23:30 +00:00
committed by Android (Google) Code Review
2 changed files with 39 additions and 1 deletions

View File

@@ -99,6 +99,7 @@ public class PipMenuActivity extends Activity {
public static final int MESSAGE_ANIMATION_ENDED = 6; public static final int MESSAGE_ANIMATION_ENDED = 6;
public static final int MESSAGE_POINTER_EVENT = 7; public static final int MESSAGE_POINTER_EVENT = 7;
public static final int MESSAGE_MENU_EXPANDED = 8; public static final int MESSAGE_MENU_EXPANDED = 8;
public static final int MESSAGE_FADE_OUT_MENU = 9;
private static final int INITIAL_DISMISS_DELAY = 3500; private static final int INITIAL_DISMISS_DELAY = 3500;
private static final int POST_INTERACTION_DISMISS_DELAY = 2000; private static final int POST_INTERACTION_DISMISS_DELAY = 2000;
@@ -182,6 +183,10 @@ public class PipMenuActivity extends Activity {
mMenuContainerAnimator.start(); mMenuContainerAnimator.start();
break; break;
} }
case MESSAGE_FADE_OUT_MENU: {
fadeOutMenu();
break;
}
} }
} }
}; };
@@ -409,6 +414,18 @@ public class PipMenuActivity extends Activity {
} }
} }
/**
* Different from {@link #hideMenu()}, this function does not try to finish this menu activity
* and instead, it fades out the controls by setting the alpha to 0 directly without menu
* visibility callbacks invoked.
*/
private void fadeOutMenu() {
mMenuContainer.setAlpha(0f);
mSettingsButton.setAlpha(0f);
mDismissButton.setAlpha(0f);
mResizeHandle.setAlpha(0f);
}
private void hideMenu() { private void hideMenu() {
hideMenu(null); hideMenu(null);
} }

View File

@@ -262,6 +262,9 @@ public class PipMenuActivityController {
*/ */
public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout, public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout,
boolean willResizeMenu, boolean showResizeHandle) { 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();
showMenuInternal(menuState, stackBounds, allowMenuTimeout, willResizeMenu, showMenuInternal(menuState, stackBounds, allowMenuTimeout, willResizeMenu,
true /* withDelay */, showResizeHandle); true /* withDelay */, showResizeHandle);
} }
@@ -347,6 +350,23 @@ public class PipMenuActivityController {
} }
} }
private void fadeOutMenu() {
if (DEBUG) {
Log.d(TAG, "fadeOutMenu() state=" + mMenuState
+ " hasActivity=" + (mToActivityMessenger != null)
+ " callers=\n" + Debug.getCallers(5, " "));
}
if (mToActivityMessenger != null) {
Message m = Message.obtain();
m.what = PipMenuActivity.MESSAGE_FADE_OUT_MENU;
try {
mToActivityMessenger.send(m);
} catch (RemoteException e) {
Log.e(TAG, "Could not notify menu to fade out", e);
}
}
}
/** /**
* Hides the menu activity. * Hides the menu activity.
*/ */
@@ -513,7 +533,8 @@ public class PipMenuActivityController {
private void onMenuStateChanged(int menuState, boolean resize, Runnable callback) { private void onMenuStateChanged(int menuState, boolean resize, Runnable callback) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onMenuStateChanged() mMenuState=" + mMenuState Log.d(TAG, "onMenuStateChanged() mMenuState=" + mMenuState
+ " menuState=" + menuState + " resize=" + resize); + " menuState=" + menuState + " resize=" + resize
+ " callers=\n" + Debug.getCallers(5, " "));
} }
if (menuState != mMenuState) { if (menuState != mMenuState) {