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

Commit 4c722acb authored by Ivan Tkachenko's avatar Ivan Tkachenko Committed by Android (Google) Code Review
Browse files

Merge changes from topic "b302520752-user-education-position" into main

* changes:
  Fix bubble user education if bubble is on the right (part 2)
  Fix bubble user education if bubble is on the right (part 1)
parents 32a0d2ff c9aae16b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@
    android:layout_width="wrap_content"
    android:paddingTop="48dp"
    android:paddingBottom="48dp"
    android:paddingEnd="@dimen/bubble_user_education_padding_end"
    android:layout_marginEnd="@dimen/bubble_user_education_margin_end"
    android:paddingHorizontal="@dimen/bubble_user_education_padding_horizontal"
    android:layout_marginEnd="@dimen/bubble_user_education_margin_horizontal"
    android:orientation="vertical"
    android:background="@drawable/bubble_stack_user_education_bg"
    >
+2 −2
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@
    android:clickable="true"
    android:paddingTop="28dp"
    android:paddingBottom="16dp"
    android:paddingEnd="@dimen/bubble_user_education_padding_end"
    android:layout_marginEnd="@dimen/bubble_user_education_margin_end"
    android:paddingEnd="@dimen/bubble_user_education_padding_horizontal"
    android:layout_marginEnd="@dimen/bubble_user_education_margin_horizontal"
    android:orientation="vertical"
    android:background="@drawable/bubble_stack_user_education_bg"
    >
+2 −2
Original line number Diff line number Diff line
@@ -224,9 +224,9 @@
    <dimen name="bubbles_user_education_width">480dp</dimen>
    <!-- Margin applied to the end of the user education views (really only matters for phone
         since the width is match parent). -->
    <dimen name="bubble_user_education_margin_end">24dp</dimen>
    <dimen name="bubble_user_education_margin_horizontal">24dp</dimen>
    <!-- Padding applied to the end of the user education view. -->
    <dimen name="bubble_user_education_padding_end">58dp</dimen>
    <dimen name="bubble_user_education_padding_horizontal">58dp</dimen>
    <!-- Padding between the bubble and the user education text. -->
    <dimen name="bubble_user_education_stack_padding">16dp</dimen>
    <!-- Max width for the bubble popup view. -->
+17 −2
Original line number Diff line number Diff line
@@ -46,6 +46,12 @@ public class BubblePositioner {
            ? "BubblePositioner"
            : BubbleDebugConfig.TAG_BUBBLES;

    /** The screen edge the bubble stack is pinned to */
    public enum StackPinnedEdge {
        LEFT,
        RIGHT
    }

    /** When the bubbles are collapsed in a stack only some of them are shown, this is how many. **/
    public static final int NUM_VISIBLE_WHEN_RESTING = 2;
    /** Indicates a bubble's height should be the maximum available space. **/
@@ -694,6 +700,15 @@ public class BubblePositioner {
        final boolean startOnLeft = isAppBubble
                ? layoutDirection == LAYOUT_DIRECTION_RTL
                : layoutDirection != LAYOUT_DIRECTION_RTL;
        return getStartPosition(startOnLeft ? StackPinnedEdge.LEFT : StackPinnedEdge.RIGHT);
    }

    /**
     * The stack position to use if user education is being shown.
     *
     * @param stackPinnedEdge the screen edge the stack is pinned to.
     */
    public PointF getStartPosition(StackPinnedEdge stackPinnedEdge) {
        final RectF allowableStackPositionRegion = getAllowableStackPositionRegion(
                1 /* default starts with 1 bubble */);
        if (isLargeScreen()) {
@@ -702,7 +717,7 @@ public class BubblePositioner {
            final float desiredY = mScreenRect.height() / 2f - (mBubbleSize / 2f);
            final float offset = desiredY / mScreenRect.height();
            return new BubbleStackView.RelativeStackPosition(
                    startOnLeft,
                    stackPinnedEdge == StackPinnedEdge.LEFT,
                    offset)
                    .getAbsolutePositionInRegion(allowableStackPositionRegion);
        } else {
@@ -710,7 +725,7 @@ public class BubblePositioner {
                    R.dimen.bubble_stack_starting_offset_y);
            // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge
            return new BubbleStackView.RelativeStackPosition(
                    startOnLeft,
                    stackPinnedEdge == StackPinnedEdge.LEFT,
                    startingVerticalOffset / mPositionRect.height())
                    .getAbsolutePositionInRegion(allowableStackPositionRegion);
        }
+30 −8
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_STACK_
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubblePositioner.NUM_VISIBLE_WHEN_RESTING;
import static com.android.wm.shell.bubbles.BubblePositioner.StackPinnedEdge.LEFT;
import static com.android.wm.shell.bubbles.BubblePositioner.StackPinnedEdge.RIGHT;
import static com.android.wm.shell.common.bubbles.BubbleConstants.BUBBLE_EXPANDED_SCRIM_ALPHA;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES;

@@ -1296,6 +1298,9 @@ public class BubbleStackView extends FrameLayout
        return shouldShow;
    }

    /**
     * Show manage education if should show and was not showing before.
     */
    private void maybeShowManageEdu() {
        if (!shouldShowManageEdu()) {
            return;
@@ -1304,7 +1309,16 @@ public class BubbleStackView extends FrameLayout
            mManageEduView = new ManageEducationView(mContext, mPositioner);
            addView(mManageEduView);
        }
        mManageEduView.show(mExpandedBubble.getExpandedView());
        showManageEdu();
    }

    /**
     * Show manage education if was not showing before.
     */
    private void showManageEdu() {
        if (mExpandedBubble == null || mExpandedBubble.getExpandedView() == null) return;
        mManageEduView.show(mExpandedBubble.getExpandedView(),
                mStackAnimationController.isStackOnLeftSide());
    }

    @VisibleForTesting
@@ -1350,10 +1364,21 @@ public class BubbleStackView extends FrameLayout
            mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController);
            addView(mStackEduView);
        }
        return showStackEdu();
    }

    /**
     * @return true if education view for the collapsed stack was not showing before.
     */
    private boolean showStackEdu() {
        // Stack appears on top of the education views
        mBubbleContainer.bringToFront();
        // Ensure the stack is in the correct spot
        mStackAnimationController.setStackPosition(mPositioner.getDefaultStartPosition());
        return mStackEduView.show(mPositioner.getDefaultStartPosition());
        PointF position = mPositioner.getStartPosition(
                mStackAnimationController.isStackOnLeftSide() ? LEFT : RIGHT);
        // Animate stack to the position
        mStackAnimationController.springStackAfterFling(position.x, position.y);
        return mStackEduView.show(position);
    }

    @VisibleForTesting
@@ -1367,16 +1392,13 @@ public class BubbleStackView extends FrameLayout
            removeView(mStackEduView);
            mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController);
            addView(mStackEduView);
            mBubbleContainer.bringToFront(); // Stack appears on top of the stack education
            // Ensure the stack is in the correct spot
            mStackAnimationController.setStackPosition(mPositioner.getDefaultStartPosition());
            mStackEduView.show(mPositioner.getDefaultStartPosition());
            showStackEdu();
        }
        if (isManageEduVisible()) {
            removeView(mManageEduView);
            mManageEduView = new ManageEducationView(mContext, mPositioner);
            addView(mManageEduView);
            mManageEduView.show(mExpandedBubble.getExpandedView());
            showManageEdu();
        }
    }

Loading