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

Commit a96c9ed4 authored by Mady Mellor's avatar Mady Mellor
Browse files

Allow activity view to be max height

When we had the bubbles at the bottom we had to account for PIP dismiss
height but now they're at the top. Code can be simplified a lil now that
we're not bottom aligned.

Also adjusts the arrow to be invisible rather than gone which prevents a
small "jump" in the UI first time you expand a bubble

Fixes: 134155107
Test: manual - create a bubble, adjust slider to be 100%, observe that
               activity view height is as big as possible with space for
               "manage" button and bottom navigation (test gesture nav on
               and 2 or 3 button on)

Change-Id: Ifb9d3e23a6a0daa53372dca14ddba0cda8007952
parent 3d593f7c
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.util.StatsLog;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.android.internal.policy.ScreenDecorationsUtils;
@@ -80,6 +81,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
    private boolean mKeyboardVisible;
    private boolean mNeedsNewHeight;

    private Point mDisplaySize;
    private int mMinHeight;
    private int mSettingsIconHeight;
    private int mBubbleHeight;
@@ -149,6 +151,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mPm = context.getPackageManager();
        mDisplaySize = new Point();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getSize(mDisplaySize);
        mMinHeight = getResources().getDimensionPixelSize(
                R.dimen.bubble_expanded_default_height);
        mPointerMargin = getResources().getDimensionPixelSize(R.dimen.bubble_pointer_margin);
@@ -173,7 +178,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        mPointerDrawable = new ShapeDrawable(TriangleShape.create(
                mPointerWidth, mPointerHeight, true /* pointUp */));
        mPointerView.setBackground(mPointerDrawable);
        mPointerView.setVisibility(GONE);
        mPointerView.setVisibility(INVISIBLE);

        mSettingsIconHeight = getContext().getResources().getDimensionPixelSize(
                R.dimen.bubble_expanded_header_height);
@@ -259,14 +264,12 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
     */
    void updateInsets(WindowInsets insets) {
        if (usingActivityView()) {
            Point displaySize = new Point();
            mActivityView.getContext().getDisplay().getSize(displaySize);
            int[] windowLocation = mActivityView.getLocationOnScreen();
            final int windowBottom = windowLocation[1] + mActivityView.getHeight();
            final int keyboardHeight = insets.getSystemWindowInsetBottom()
                    - insets.getStableInsetBottom();
            final int insetsBottom = Math.max(0,
                    windowBottom + keyboardHeight - displaySize.y);
                    windowBottom + keyboardHeight - mDisplaySize.y);
            mActivityView.setForwardedInsets(Insets.of(0, 0, 0, insetsBottom));
        }
    }
@@ -377,7 +380,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            if (data == null) {
                // This is a contentIntent based bubble, lets allow it to be the max height
                // as it was forced into this mode and not prepared to be small
                desiredHeight = mStackView.getMaxExpandedHeight();
                desiredHeight = getMaxExpandedHeight();
            } else {
                boolean useRes = data.getDesiredHeightResId() != 0;
                float desiredPx;
@@ -391,9 +394,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
                }
                desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight;
            }
            int max = mStackView.getMaxExpandedHeight() - mSettingsIconHeight - mPointerHeight
                    - mPointerMargin;
            float height = Math.min(desiredHeight, max);
            float height = Math.min(desiredHeight, getMaxExpandedHeight());
            height = Math.max(height, mMinHeight);
            LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams();
            mNeedsNewHeight =  lp.height != height;
@@ -410,6 +411,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        }
    }

    private int getMaxExpandedHeight() {
        int[] windowLocation = mActivityView.getLocationOnScreen();
        return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight;
    }

    @Override
    public void onClick(View view) {
        if (mEntry == null) {
+0 −11
Original line number Diff line number Diff line
@@ -1292,17 +1292,6 @@ public class BubbleStackView extends FrameLayout {
                        : 0f);
    }

    /**
     * Calculates how large the expanded view of the bubble can be. This takes into account the
     * y position when the bubbles are expanded as well as the bounds of the dismiss target.
     */
    int getMaxExpandedHeight() {
        int expandedY = (int) mExpandedAnimationController.getExpandedY();
        // PIP dismiss view uses FLAG_LAYOUT_IN_SCREEN so we need to subtract the bottom inset
        int pipDismissHeight = mPipDismissHeight - getBottomInset();
        return mDisplaySize.y - expandedY - mBubbleSize - pipDismissHeight;
    }

    /**
     * Calculates the y position of the expanded view when it is expanded.
     */