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

Commit 3c5fcca4 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Update smart reply/action sizes to follow mocks.

The smart suggestion mocks show buttons with rounded sides - with this
CL we update the button dimensions to make their sides rounded.
This CL also changes a couple other button dimensions to follow the
mocks.

Screenshots:
One-line buttons before this CL:
https://screenshot.googleplex.com/yzMXZ3Djrmy.png
One-line buttons after this CL:
https://screenshot.googleplex.com/3rBDmTXzkch.png

Two-line buttons after this CL:
https://screenshot.googleplex.com/s1HfEsyTFFU.png
Two-line buttons after this CL:
https://screenshot.googleplex.com/Z2bCLgXCJJu.png

Bug: 121186803
Test: build Android and check how smart suggestions look.

Change-Id: Idac328c4e5e108e4af99e1de16e4db2dcb404bd2
parent 0c6becec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
            android:insetRight="0dp"
            android:insetBottom="8dp">
            <shape android:shape="rectangle">
                <corners android:radius="8dp" />
              <corners android:radius="@dimen/smart_reply_button_corner_radius" />
                <stroke android:width="@dimen/smart_reply_button_stroke_width"
                        android:color="@color/smart_reply_button_stroke" />
                <solid android:color="@color/smart_reply_button_background"/>
+4 −2
Original line number Diff line number Diff line
@@ -876,8 +876,10 @@
    <dimen name="smart_reply_button_stroke_width">1dp</dimen>
    <dimen name="smart_reply_button_font_size">14sp</dimen>
    <dimen name="smart_reply_button_line_spacing_extra">6sp</dimen> <!-- Total line height 20sp. -->
    <dimen name="smart_action_button_icon_size">24dp</dimen>
    <dimen name="smart_action_button_icon_padding">10dp</dimen>
    <!-- Corner radius = half of min_height to create rounded sides. -->
    <dimen name="smart_reply_button_corner_radius">24dp</dimen>
    <dimen name="smart_action_button_icon_size">18dp</dimen>
    <dimen name="smart_action_button_icon_padding">8dp</dimen>

    <!-- A reasonable upper bound for the height of the smart reply button. The measuring code
            needs to start with a guess for the maximum size. Currently two-line smart reply buttons
+27 −3
Original line number Diff line number Diff line
@@ -479,13 +479,20 @@ public class SmartReplyView extends ViewGroup {
        remeasureButtonsIfNecessary(accumulatedMeasures.mButtonPaddingHorizontal,
                                    accumulatedMeasures.mMaxChildHeight);

        int buttonHeight = Math.max(getSuggestedMinimumHeight(), mPaddingTop
                + accumulatedMeasures.mMaxChildHeight + mPaddingBottom);

        // Set the corner radius to half the button height to make the side of the buttons look like
        // a semicircle.
        for (View smartSuggestionButton : smartSuggestions) {
            setCornerRadius((Button) smartSuggestionButton, ((float) buttonHeight) / 2);
        }

        setMeasuredDimension(
                resolveSize(Math.max(getSuggestedMinimumWidth(),
                                     accumulatedMeasures.mMeasuredWidth),
                            widthMeasureSpec),
                resolveSize(Math.max(getSuggestedMinimumHeight(), mPaddingTop
                        + accumulatedMeasures.mMaxChildHeight + mPaddingBottom),
                            heightMeasureSpec));
                resolveSize(buttonHeight, heightMeasureSpec));
    }

    /**
@@ -806,6 +813,23 @@ public class SmartReplyView extends ViewGroup {
        button.setTextColor(textColor);
    }

    private void setCornerRadius(Button button, float radius) {
        Drawable drawable = button.getBackground();
        if (drawable instanceof RippleDrawable) {
            // Mutate in case other notifications are using this drawable.
            drawable = drawable.mutate();
            RippleDrawable ripple = (RippleDrawable) drawable;
            Drawable inset = ripple.getDrawable(0);
            if (inset instanceof InsetDrawable) {
                Drawable background = ((InsetDrawable) inset).getDrawable();
                if (background instanceof GradientDrawable) {
                    GradientDrawable gradientDrawable = (GradientDrawable) background;
                    gradientDrawable.setCornerRadius(radius);
                }
            }
        }
    }

    private ActivityStarter getActivityStarter() {
        if (mActivityStarter == null) {
            mActivityStarter = Dependency.get(ActivityStarter.class);