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

Commit e60e6524 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix issues in RTL." into rvc-dev

parents 3dce721a 519d4c1e
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -798,6 +798,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                mBubbleIconFactory = new BubbleIconFactory(mContext);
                mBubbleIconFactory = new BubbleIconFactory(mContext);
                mStackView.onDisplaySizeChanged();
                mStackView.onDisplaySizeChanged();
            }
            }

            mStackView.onLayoutDirectionChanged();
        }
        }
    }
    }


+4 −0
Original line number Original line Diff line number Diff line
@@ -316,6 +316,10 @@ public class BubbleExpandedView extends LinearLayout {


            return false;
            return false;
        });
        });

        // BubbleStackView is forced LTR, but we want to respect the locale for expanded view layout
        // so the Manage button appears on the right.
        setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
    }
    }


    private String getBubbleKey() {
    private String getBubbleKey() {
+3 −0
Original line number Original line Diff line number Diff line
@@ -186,6 +186,9 @@ public class BubbleFlyoutView extends FrameLayout {
            }
            }
        });
        });


        // Use locale direction so the text is aligned correctly.
        setLayoutDirection(LAYOUT_DIRECTION_LOCALE);

        mBgPaint.setColor(mFloatingBackgroundColor);
        mBgPaint.setColor(mFloatingBackgroundColor);


        mLeftTriangleShape =
        mLeftTriangleShape =
+31 −7
Original line number Original line Diff line number Diff line
@@ -723,6 +723,12 @@ public class BubbleStackView extends FrameLayout


        setUpUserEducation();
        setUpUserEducation();


        // Force LTR by default since most of the Bubbles UI is positioned manually by the user, or
        // is centered. It greatly simplifies translation positioning/animations. Views that will
        // actually lay out differently in RTL, such as the flyout and expanded view, will set their
        // layout direction to LOCALE.
        setLayoutDirection(LAYOUT_DIRECTION_LTR);

        mBubbleContainer = new PhysicsAnimationLayout(context);
        mBubbleContainer = new PhysicsAnimationLayout(context);
        mBubbleContainer.setActiveController(mStackAnimationController);
        mBubbleContainer.setActiveController(mStackAnimationController);
        mBubbleContainer.setElevation(elevation);
        mBubbleContainer.setElevation(elevation);
@@ -961,6 +967,9 @@ public class BubbleStackView extends FrameLayout


        mManageSettingsIcon = mManageMenu.findViewById(R.id.bubble_manage_menu_settings_icon);
        mManageSettingsIcon = mManageMenu.findViewById(R.id.bubble_manage_menu_settings_icon);
        mManageSettingsText = mManageMenu.findViewById(R.id.bubble_manage_menu_settings_name);
        mManageSettingsText = mManageMenu.findViewById(R.id.bubble_manage_menu_settings_name);

        // The menu itself should respect locale direction so the icons are on the correct side.
        mManageMenu.setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
        addView(mManageMenu);
        addView(mManageMenu);
    }
    }


@@ -1084,6 +1093,16 @@ public class BubbleStackView extends FrameLayout
        mShowingManage = false;
        mShowingManage = false;
    }
    }


    /** Tells the views with locale-dependent layout direction to resolve the new direction. */
    public void onLayoutDirectionChanged() {
        mManageMenu.resolveLayoutDirection();
        mFlyout.resolveLayoutDirection();

        if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) {
            mExpandedBubble.getExpandedView().resolveLayoutDirection();
        }
    }

    /** Respond to the display size change by recalculating view size and location. */
    /** Respond to the display size change by recalculating view size and location. */
    public void onDisplaySizeChanged() {
    public void onDisplaySizeChanged() {
        setUpOverflow();
        setUpOverflow();
@@ -2095,16 +2114,21 @@ public class BubbleStackView extends FrameLayout


        mExpandedBubble.getExpandedView().getManageButtonBoundsOnScreen(mTempRect);
        mExpandedBubble.getExpandedView().getManageButtonBoundsOnScreen(mTempRect);


        // When the menu is open, it should be at these coordinates. This will make the menu's
        final boolean isLtr =
        // bottom left corner match up with the button's bottom left corner.
                getResources().getConfiguration().getLayoutDirection() == LAYOUT_DIRECTION_LTR;
        final float targetX = mTempRect.left;

        // When the menu is open, it should be at these coordinates. The menu pops out to the right
        // in LTR and to the left in RTL.
        final float targetX = isLtr ? mTempRect.left : mTempRect.right - mManageMenu.getWidth();
        final float targetY = mTempRect.bottom - mManageMenu.getHeight();
        final float targetY = mTempRect.bottom - mManageMenu.getHeight();


        final float xOffsetForAnimation = (isLtr ? 1 : -1) * mManageMenu.getWidth() / 4f;

        if (show) {
        if (show) {
            mManageMenu.setScaleX(0.5f);
            mManageMenu.setScaleX(0.5f);
            mManageMenu.setScaleY(0.5f);
            mManageMenu.setScaleY(0.5f);
            mManageMenu.setTranslationX(targetX - mManageMenu.getWidth() / 4);
            mManageMenu.setTranslationX(targetX - xOffsetForAnimation);
            mManageMenu.setTranslationY(targetY + mManageMenu.getHeight() / 4);
            mManageMenu.setTranslationY(targetY + mManageMenu.getHeight() / 4f);
            mManageMenu.setAlpha(0f);
            mManageMenu.setAlpha(0f);


            PhysicsAnimator.getInstance(mManageMenu)
            PhysicsAnimator.getInstance(mManageMenu)
@@ -2121,8 +2145,8 @@ public class BubbleStackView extends FrameLayout
                    .spring(DynamicAnimation.ALPHA, 0f)
                    .spring(DynamicAnimation.ALPHA, 0f)
                    .spring(DynamicAnimation.SCALE_X, 0.5f)
                    .spring(DynamicAnimation.SCALE_X, 0.5f)
                    .spring(DynamicAnimation.SCALE_Y, 0.5f)
                    .spring(DynamicAnimation.SCALE_Y, 0.5f)
                    .spring(DynamicAnimation.TRANSLATION_X, targetX - mManageMenu.getWidth() / 4)
                    .spring(DynamicAnimation.TRANSLATION_X, targetX - xOffsetForAnimation)
                    .spring(DynamicAnimation.TRANSLATION_Y, targetY + mManageMenu.getHeight() / 4)
                    .spring(DynamicAnimation.TRANSLATION_Y, targetY + mManageMenu.getHeight() / 4f)
                    .withEndActions(() -> mManageMenu.setVisibility(View.INVISIBLE))
                    .withEndActions(() -> mManageMenu.setVisibility(View.INVISIBLE))
                    .start();
                    .start();
        }
        }