Merge "Update smart reply/action sizes to follow mocks."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d6a69968b3
@@ -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"/>
|
||||
|
||||
@@ -888,8 +888,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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user