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

Commit 6be228c1 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Fix floating toolbar rendering.

The code to size and position the floating toolbar and it's content
when there was no overflow menu was omitted. This caused bad
rendering of the toolbar and it's content when an existing toolbar
object was updated to go in the "no overflow" state.

Fixed the issue by properly updating the floating toolbar size
and positioning of it's contents in the "no overflow" state.

Bug: 25973599
Change-Id: I9305140f493bc36b87328571cd7645f184d9cf30
parent 7200364e
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -920,14 +920,14 @@ public final class FloatingToolbar {
                    mOverflowPanel.setY(mOverflowButtonSize.getHeight());  // align bottom
                }
            } else {
                if (hasOverflow()) {
                    // overflow not open. Set closed state.
                // Overflow not open. Set closed state.
                final Size containerSize = mMainPanelSize;
                setSize(mContentContainer, containerSize);
                mMainPanel.setAlpha(1);
                mOverflowPanel.setAlpha(0);
                mOverflowButton.setImageDrawable(mOverflow);

                if (hasOverflow()) {
                    // Update x-coordinates depending on RTL state.
                    if (isRTL()) {
                        mContentContainer.setX(mMarginHorizontal);  // align left
@@ -960,8 +960,11 @@ public final class FloatingToolbar {
                        mOverflowPanel.setY(mOverflowButtonSize.getHeight());  // align bottom
                    }
                } else {
                    mContentContainer.setX(mMarginHorizontal);
                    mContentContainer.setY(mMarginVertical);
                    // No overflow.
                    mContentContainer.setX(mMarginHorizontal);  // align left
                    mContentContainer.setY(mMarginVertical);  // align top
                    mMainPanel.setX(0);  // align left
                    mMainPanel.setY(0);  // align top
                }
            }
        }
@@ -1092,6 +1095,7 @@ public final class FloatingToolbar {
            final LinkedList<MenuItem> remainingMenuItems = new LinkedList<MenuItem>(menuItems);

            mMainPanel.removeAllViews();
            mMainPanel.setPaddingRelative(0, 0, 0, 0);

            boolean isFirstItem = true;
            while (!remainingMenuItems.isEmpty()) {
@@ -1302,7 +1306,6 @@ public final class FloatingToolbar {
            overflowButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final Drawable drawable = overflowButton.getDrawable();
                    if (mIsOverflowOpen) {
                        overflowButton.setImageDrawable(mToOverflow);
                        mToOverflow.start();
@@ -1599,6 +1602,8 @@ public final class FloatingToolbar {
    private static ViewGroup createContentContainer(Context context) {
        ViewGroup contentContainer = (ViewGroup) LayoutInflater.from(context)
                .inflate(R.layout.floating_popup_container, null);
        contentContainer.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        contentContainer.setTag(FLOATING_TOOLBAR_TAG);
        return contentContainer;
    }