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

Commit de0d5d74 authored by Dongwon Kang's avatar Dongwon Kang
Browse files

MediaRouter: make MediaRouteButton inherit Widget.Material.ActionButton

Also, fix onMeasure() to ensure that (min) width/height includes paddings.

Bug: 22947288
Change-Id: Iba49d89e014d0df747cbdde8383de4158700ac70
parent 7f6fad0d
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -330,40 +330,40 @@ public class MediaRouteButton extends View {
        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        final int heightMode = MeasureSpec.getMode(heightMeasureSpec);

        final int minWidth = Math.max(mMinWidth,
                mRemoteIndicator != null ? mRemoteIndicator.getIntrinsicWidth() : 0);
        final int minHeight = Math.max(mMinHeight,
                mRemoteIndicator != null ? mRemoteIndicator.getIntrinsicHeight() : 0);
        final int width = Math.max(mMinWidth, mRemoteIndicator != null ?
                mRemoteIndicator.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight() : 0);
        final int height = Math.max(mMinHeight, mRemoteIndicator != null ?
                mRemoteIndicator.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom() : 0);

        int width;
        int measuredWidth;
        switch (widthMode) {
            case MeasureSpec.EXACTLY:
                width = widthSize;
                measuredWidth = widthSize;
                break;
            case MeasureSpec.AT_MOST:
                width = Math.min(widthSize, minWidth + getPaddingLeft() + getPaddingRight());
                measuredWidth = Math.min(widthSize, width);
                break;
            default:
            case MeasureSpec.UNSPECIFIED:
                width = minWidth + getPaddingLeft() + getPaddingRight();
                measuredWidth = width;
                break;
        }

        int height;
        int measuredHeight;
        switch (heightMode) {
            case MeasureSpec.EXACTLY:
                height = heightSize;
                measuredHeight = heightSize;
                break;
            case MeasureSpec.AT_MOST:
                height = Math.min(heightSize, minHeight + getPaddingTop() + getPaddingBottom());
                measuredHeight = Math.min(heightSize, height);
                break;
            default:
            case MeasureSpec.UNSPECIFIED:
                height = minHeight + getPaddingTop() + getPaddingBottom();
                measuredHeight = height;
                break;
        }

        setMeasuredDimension(width, height);
        setMeasuredDimension(measuredWidth, measuredHeight);
    }

    @Override
+1 −5
Original line number Diff line number Diff line
@@ -967,12 +967,8 @@ please see styles_device_defaults.xml.
        <item name="borderRight">?attr/preferenceFragmentPaddingSide</item>
    </style>

    <style name="Widget.Material.MediaRouteButton">
        <item name="background">@drawable/control_background_40dp_material</item>
    <style name="Widget.Material.MediaRouteButton" parent ="Widget.Material.ActionButton">
        <item name="externalRouteEnabledDrawable">@drawable/ic_media_route_material</item>
        <item name="minWidth">56dp</item>
        <item name="minHeight">48dp</item>
        <item name="focusable">true</item>
        <item name="contentDescription">@string/media_route_button_content_description</item>
    </style>