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

Commit 8fe411d7 authored by Mady Mellor's avatar Mady Mellor
Browse files

Update BubbleExpandedView inset & height

The inset code for the IME would be too big if there was a notch. This CL
changes the displaySize to be the "real" displaySize, which makes
calculations more obvious & fixes notch issue.

Fixes an issue where the max height of the view was subtracting the
"manage" button height twice. Also subtracts the bottom inset from max
height since we're using the "real" display size.

Removes some obsolete code that was needed when bubbles were at the bottom,
this fixes a weird animation glitch with the height when expanding bubbles.

Fixes: 139002444
Test: manual - expand a bubble, make it max height, focus the IME
             - repeat above with all the different notch configurations
               in developer options
             - also toggle the different nav options (navbar & gesture)

Change-Id: I59e60864369d1bd3a15480c56b7b3fbe98b2fc16
parent 6e9cd4cd
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -193,7 +193,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        mPm = context.getPackageManager();
        mDisplaySize = new Point();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getSize(mDisplaySize);
        // Get the real size -- this includes screen decorations (notches, statusbar, navbar).
        wm.getDefaultDisplay().getRealSize(mDisplaySize);
        Resources res = getResources();
        mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height);
        mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
@@ -313,12 +314,10 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
     */
    void updateInsets(WindowInsets insets) {
        if (usingActivityView()) {
            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 - mDisplaySize.y);
            int[] screenLoc = mActivityView.getLocationOnScreen();
            final int activityViewBottom = screenLoc[1] + mActivityView.getHeight();
            final int keyboardTop = mDisplaySize.y - insets.getSystemWindowInsetBottom();
            final int insetsBottom = Math.max(activityViewBottom - keyboardTop, 0);
            mActivityView.setForwardedInsets(Insets.of(0, 0, 0, insetsBottom));
        }
    }
@@ -415,10 +414,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            Log.d(TAG, "updateHeight: bubble=" + getBubbleKey());
        }
        if (usingActivityView()) {
            int max = getMaxExpandedHeight() - mSettingsIconHeight - mPointerHeight
                    - mPointerMargin;
            float desiredHeight = Math.max(mBubble.getDesiredHeight(mContext), mMinHeight);
            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;
@@ -438,7 +435,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList

    private int getMaxExpandedHeight() {
        int[] windowLocation = mActivityView.getLocationOnScreen();
        return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight;
        int bottomInset = getRootWindowInsets() != null
                ? getRootWindowInsets().getStableInsetBottom()
                : 0;
        return mDisplaySize.y - windowLocation[1] - mSettingsIconHeight - mPointerHeight
                - mPointerMargin - bottomInset;
    }

    /**
+0 −8
Original line number Diff line number Diff line
@@ -408,14 +408,6 @@ public class BubbleStackView extends FrameLayout {
            if (!mIsExpanded || mIsExpansionAnimating) {
                return view.onApplyWindowInsets(insets);
            }

            float newY = getExpandedViewY();
            if (newY < 0) {
                // TODO: This means our expanded content is too big to fit on screen. Right now
                // we'll let it translate off but we should be clipping it & pushing the header
                // down so that it always remains visible.
            }
            mExpandedViewYAnim.animateToFinalPosition(newY);
            mExpandedAnimationController.updateYPosition(
                    // Update the insets after we're done translating otherwise position
                    // calculation for them won't be correct.