Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8d759b8 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "[PiP2] Deprecate PipMenuIconsAlgorithm" into main

parents 69938485 d9ad344f
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -243,7 +243,6 @@ public class PhonePipMenuController implements PipMenuController,
        mSystemWindows.updateViewLayout(mPipMenuView,
                getPipMenuLayoutParams(mContext, MENU_WINDOW_TITLE, destinationBounds.width(),
                        destinationBounds.height()));
        updateMenuLayout(destinationBounds);
    }

    /**
@@ -569,23 +568,6 @@ public class PhonePipMenuController implements PipMenuController,
        }
    }

    /**
     * Tell the PIP Menu to recalculate its layout given its current position on the display.
     */
    public void updateMenuLayout(Rect bounds) {
        final boolean isMenuVisible = isMenuVisible();
        if (DEBUG) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "%s: updateMenuLayout() state=%s"
                            + " isMenuVisible=%s"
                            + " callers=\n%s", TAG, mMenuState, isMenuVisible,
                    Debug.getCallers(5, "    "));
        }
        if (isMenuVisible) {
            mPipMenuView.updateMenuLayout(bounds);
        }
    }

    @Override
    public void onPipTransitionStateChanged(@PipTransitionState.TransitionState int oldState,
            @PipTransitionState.TransitionState int newState, Bundle extra) {
@@ -597,7 +579,6 @@ public class PhonePipMenuController implements PipMenuController,
                detach();
                break;
            case PipTransitionState.CHANGED_PIP_BOUNDS:
                updateMenuLayout(mPipBoundsState.getBounds());
                hideMenu();
                break;
            case PipTransitionState.CHANGING_PIP_BOUNDS:
+0 −71
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.pip2.phone;

import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

/**
 * Helper class to calculate and place the menu icons on the PIP Menu.
 */
public class PipMenuIconsAlgorithm {

    private static final String TAG = "PipMenuIconsAlgorithm";

    protected ViewGroup mViewRoot;
    protected ViewGroup mTopEndContainer;
    protected View mDragHandle;
    protected View mSettingsButton;
    protected View mDismissButton;

    protected PipMenuIconsAlgorithm(Context context) {
    }

    /**
     * Bind the necessary views.
     */
    public void bindViews(ViewGroup viewRoot, ViewGroup topEndContainer, View dragHandle,
            View settingsButton, View dismissButton) {
        mViewRoot = viewRoot;
        mTopEndContainer = topEndContainer;
        mDragHandle = dragHandle;
        mSettingsButton = settingsButton;
        mDismissButton = dismissButton;
    }

    /**
     * Updates the position of the drag handle based on where the PIP window is on the screen.
     */
    public void onBoundsChanged(Rect bounds) {
        // On phones, the menu icons are always static and will never move based on the PIP window
        // position. No need to do anything here.
    }

    /**
     * Set the gravity on the given view.
     */
    protected static void setLayoutGravity(View v, int gravity) {
        if (v.getLayoutParams() instanceof FrameLayout.LayoutParams) {
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
            params.gravity = gravity;
            v.setLayoutParams(params);
        }
    }
}
+0 −8
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ public class PipMenuView extends FrameLayout {
    protected View mSettingsButton;
    protected View mDismissButton;
    protected View mTopEndContainer;
    protected PipMenuIconsAlgorithm mPipMenuIconsAlgorithm;

    // How long the shell will wait for the app to close the PiP if a custom action is set.
    private final int mPipForceCloseDelay;
@@ -193,9 +192,6 @@ public class PipMenuView extends FrameLayout {
        mActionsGroup = findViewById(R.id.actions_group);
        mBetweenActionPaddingLand = getResources().getDimensionPixelSize(
                R.dimen.pip_between_action_padding_land);
        mPipMenuIconsAlgorithm = new PipMenuIconsAlgorithm(mContext);
        mPipMenuIconsAlgorithm.bindViews((ViewGroup) mViewRoot, (ViewGroup) mTopEndContainer,
                findViewById(R.id.resize_handle), mSettingsButton, mDismissButton);
        mDismissFadeOutDurationMs = context.getResources()
                .getInteger(R.integer.config_pipExitAnimationDuration);

@@ -339,10 +335,6 @@ public class PipMenuView extends FrameLayout {
        cancelDelayedHide();
    }

    void updateMenuLayout(Rect bounds) {
        mPipMenuIconsAlgorithm.onBoundsChanged(bounds);
    }

    void hideMenu() {
        hideMenu(null);
    }