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

Commit 0dc09244 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Adjust the estimated minimum size of PiP menu

Use the similar measurement from PipMenuView#updateActionViews

Video: http://rcll/aaaaaabFQoRHlzixHdtY/g1YgomInywOHbZcKdsegcf
Bug: 175055101
Test: See video
Change-Id: I2a52f46c2208b9e164f0898fff0e43cbb3eb8b96
parent cfe4cef6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -212,8 +212,8 @@ public class PhonePipMenuController implements PipMenuController {
    }

    @Nullable
    Size getEstimatedMenuSize() {
        return mPipMenuView == null ? null : mPipMenuView.getEstimatedMenuSize();
    Size getEstimatedMinMenuSize() {
        return mPipMenuView == null ? null : mPipMenuView.getEstimatedMinMenuSize();
    }

    /**
+10 −8
Original line number Diff line number Diff line
@@ -367,15 +367,17 @@ public class PipMenuView extends FrameLayout {
    }

    /**
     * @return estimated {@link Size} for which the width is based on number of actions and
     *         height based on the height of expand button + top and bottom action bar.
     * @return Estimated minimum {@link Size} to hold the actions.
     *         See also {@link #updateActionViews(Rect)}
     */
    Size getEstimatedMenuSize() {
        final int pipActionSize = mContext.getResources().getDimensionPixelSize(
                R.dimen.pip_action_size);
        final int width = mActions.size() * pipActionSize;
        final int height = pipActionSize * 2 + mContext.getResources().getDimensionPixelSize(
                R.dimen.pip_expand_action_size);
    Size getEstimatedMinMenuSize() {
        final int pipActionSize = getResources().getDimensionPixelSize(R.dimen.pip_action_size);
        // the minimum width would be (2 * pipActionSize) since we have settings and dismiss button
        // on the top action container.
        final int width = Math.max(2, mActions.size()) * pipActionSize;
        final int height = getResources().getDimensionPixelSize(R.dimen.pip_expand_action_size)
                + getResources().getDimensionPixelSize(R.dimen.pip_action_padding)
                + getResources().getDimensionPixelSize(R.dimen.pip_expand_container_edge_margin);
        return new Size(width, height);
    }

+4 −5
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Handler;
import android.provider.DeviceConfig;
import android.util.Log;
import android.util.Size;
@@ -932,14 +931,14 @@ public class PipTouchHandler {
        if (!mEnableResize) {
            return false;
        }
        final Size estimatedMenuSize = mMenuController.getEstimatedMenuSize();
        if (estimatedMenuSize == null) {
        final Size estimatedMinMenuSize = mMenuController.getEstimatedMinMenuSize();
        if (estimatedMinMenuSize == null) {
            Log.wtf(TAG, "Failed to get estimated menu size");
            return false;
        }
        final Rect currentBounds = mPipBoundsState.getBounds();
        return currentBounds.width() < estimatedMenuSize.getWidth()
                || currentBounds.height() < estimatedMenuSize.getHeight();
        return currentBounds.width() < estimatedMinMenuSize.getWidth()
                || currentBounds.height() < estimatedMinMenuSize.getHeight();
    }

    /**