Merge "Hide the expand container when it's not visible" into sc-dev

This commit is contained in:
Winson Chung
2021-03-10 18:27:14 +00:00
committed by Android (Google) Code Review

View File

@@ -32,7 +32,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.Nullable;
import android.app.PendingIntent.CanceledException; import android.app.PendingIntent.CanceledException;
import android.app.RemoteAction; import android.app.RemoteAction;
import android.content.ComponentName; import android.content.ComponentName;
@@ -52,10 +51,8 @@ import android.util.Size;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@@ -197,6 +194,11 @@ public class PipMenuView extends FrameLayout {
return super.onKeyUp(keyCode, event); return super.onKeyUp(keyCode, event);
} }
@Override
public boolean shouldDelayChildPressedState() {
return true;
}
@Override @Override
public boolean dispatchTouchEvent(MotionEvent ev) { public boolean dispatchTouchEvent(MotionEvent ev) {
if (!mAllowTouches) { if (!mAllowTouches) {
@@ -287,18 +289,6 @@ public class PipMenuView extends FrameLayout {
} }
} }
@Nullable SurfaceControl getWindowSurfaceControl() {
final ViewRootImpl root = getViewRootImpl();
if (root == null) {
return null;
}
final SurfaceControl out = root.getSurfaceControl();
if (out != null && out.isValid()) {
return out;
}
return null;
}
/** /**
* Different from {@link #hideMenu()}, this function does not try to finish this menu 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 * and instead, it fades out the controls by setting the alpha to 0 directly without menu
@@ -398,8 +388,20 @@ public class PipMenuView extends FrameLayout {
return true; return true;
}); });
// Update the expand button only if it should show with the menu
expandContainer.setVisibility(mMenuState == MENU_STATE_FULL
? View.VISIBLE
: View.INVISIBLE);
FrameLayout.LayoutParams expandedLp =
(FrameLayout.LayoutParams) expandContainer.getLayoutParams();
if (mActions.isEmpty() || mMenuState == MENU_STATE_CLOSE || mMenuState == MENU_STATE_NONE) { if (mActions.isEmpty() || mMenuState == MENU_STATE_CLOSE || mMenuState == MENU_STATE_NONE) {
actionsContainer.setVisibility(View.INVISIBLE); actionsContainer.setVisibility(View.INVISIBLE);
// Update the expand container margin to adjust the center of the expand button to
// account for the existence of the action container
expandedLp.topMargin = 0;
expandedLp.bottomMargin = 0;
} else { } else {
actionsContainer.setVisibility(View.VISIBLE); actionsContainer.setVisibility(View.VISIBLE);
if (mActionsGroup != null) { if (mActionsGroup != null) {
@@ -455,14 +457,12 @@ public class PipMenuView extends FrameLayout {
// Update the expand container margin to adjust the center of the expand button to // Update the expand container margin to adjust the center of the expand button to
// account for the existence of the action container // account for the existence of the action container
FrameLayout.LayoutParams expandedLp =
(FrameLayout.LayoutParams) expandContainer.getLayoutParams();
expandedLp.topMargin = getResources().getDimensionPixelSize( expandedLp.topMargin = getResources().getDimensionPixelSize(
R.dimen.pip_action_padding); R.dimen.pip_action_padding);
expandedLp.bottomMargin = getResources().getDimensionPixelSize( expandedLp.bottomMargin = getResources().getDimensionPixelSize(
R.dimen.pip_expand_container_edge_margin); R.dimen.pip_expand_container_edge_margin);
expandContainer.requestLayout();
} }
expandContainer.requestLayout();
} }
private void notifyMenuStateChange(int menuState, boolean resize, Runnable callback) { private void notifyMenuStateChange(int menuState, boolean resize, Runnable callback) {