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

Commit 97bfd2f9 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Modify the default position of bubbles on tablet to be centered" into...

Merge "Modify the default position of bubbles on tablet to be centered" into udc-qpr-dev am: 1f496165

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24315280



Change-Id: I80fde9a5b6b61621800f8727258c8e40816a34bf
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4669e724 1f496165
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -661,14 +661,26 @@ public class BubblePositioner {
        final boolean startOnLeft =
                mContext.getResources().getConfiguration().getLayoutDirection()
                        != LAYOUT_DIRECTION_RTL;
        final RectF allowableStackPositionRegion = getAllowableStackPositionRegion(
                1 /* default starts with 1 bubble */);
        if (isLargeScreen()) {
            // We want the stack to be visually centered on the edge, so we need to base it
            // of a rect that includes insets.
            final float desiredY = mScreenRect.height() / 2f - (mBubbleSize / 2f);
            final float offset = desiredY / mScreenRect.height();
            return new BubbleStackView.RelativeStackPosition(
                    startOnLeft,
                    offset)
                    .getAbsolutePositionInRegion(allowableStackPositionRegion);
        } else {
            final float startingVerticalOffset = mContext.getResources().getDimensionPixelOffset(
                    R.dimen.bubble_stack_starting_offset_y);
            // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge
            return new BubbleStackView.RelativeStackPosition(
                    startOnLeft,
                    startingVerticalOffset / mPositionRect.height())
                .getAbsolutePositionInRegion(getAllowableStackPositionRegion(
                        1 /* default starts with 1 bubble */));
                    .getAbsolutePositionInRegion(allowableStackPositionRegion);
        }
    }

    /**
+12 −2
Original line number Diff line number Diff line
@@ -209,9 +209,19 @@ public class BubblePositionerTest extends ShellTestCase {
     * {@link BubbleStackView.RelativeStackPosition}.
     */
    private float getDefaultYPosition() {
        final float desiredY = mContext.getResources().getDimensionPixelOffset(
        final boolean isTablet = mPositioner.isLargeScreen();

        // On tablet the position is centered, on phone it is an offset from the top.
        final float desiredY = isTablet
                ? mPositioner.getScreenRect().height() / 2f - (mPositioner.getBubbleSize() / 2f)
                : mContext.getResources().getDimensionPixelOffset(
                        R.dimen.bubble_stack_starting_offset_y);
        float offsetPercent = desiredY / mPositioner.getAvailableRect().height();
        // Since we're visually centering the bubbles on tablet, use total screen height rather
        // than the available height.
        final float height = isTablet
                ? mPositioner.getScreenRect().height()
                : mPositioner.getAvailableRect().height();
        float offsetPercent = desiredY / height;
        offsetPercent = Math.max(0f, Math.min(1f, offsetPercent));
        final RectF allowableStackRegion =
                mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */);