From f9e05736ef5d995a481998f3752dd237e9b8f83e Mon Sep 17 00:00:00 2001 From: Andrew Sapperstein Date: Wed, 15 Nov 2017 18:06:51 -0800 Subject: [PATCH] Add ability to customize button corner radius. Creates a new buttonCornerRadius public attribute to control the rounded corner radius for buttons at the theme level. Updates default button backgrounds to use new value and updates themes to set the corner radius to existing value of 2dp. Also adds a configuration hook for a device to change the value for DeviceDefault-based themes. Bug: 64122537 Bug: 69314526 Bug: 69367197 Test: ag/3238215 Change-Id: I00be0c53b99292e1728ecdf40d4c876e283e65da --- api/current.txt | 1 + .../res/res/drawable/btn_colored_material.xml | 2 +- .../res/drawable/btn_default_mtrl_shape.xml | 2 +- core/res/res/values/attrs.xml | 3 ++ core/res/res/values/config.xml | 2 + core/res/res/values/public.xml | 1 + .../res/res/values/themes_device_defaults.xml | 43 +++++++++++++++++++ core/res/res/values/themes_material.xml | 2 + 8 files changed, 54 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 00a945294f092..7c2249143296b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -343,6 +343,7 @@ package android { field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489 field public static final int buttonBarStyle = 16843566; // 0x101032e + field public static final int buttonCornerRadius = 16844149; // 0x1010575 field public static final int buttonGravity = 16844030; // 0x10104fe field public static final int buttonStyle = 16842824; // 0x1010048 field public static final int buttonStyleInset = 16842826; // 0x101004a diff --git a/core/res/res/drawable/btn_colored_material.xml b/core/res/res/drawable/btn_colored_material.xml index c3c5760f2cc51..7ba21e840a597 100644 --- a/core/res/res/drawable/btn_colored_material.xml +++ b/core/res/res/drawable/btn_colored_material.xml @@ -23,7 +23,7 @@ - + - + + + + diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 65a7ec643078d..171f74f9ead8e 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3174,6 +3174,8 @@ 2dp + + @dimen/control_corner_material true diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index e370786ee1c1c..3dbb89c2a36df 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2853,6 +2853,7 @@ + diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml index 3fa0d3b542fc7..d63d00c86239b 100644 --- a/core/res/res/values/themes_device_defaults.xml +++ b/core/res/res/values/themes_device_defaults.xml @@ -69,6 +69,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button @style/Widget.DeviceDefault.Button.Small @@ -224,6 +225,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -243,6 +245,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -264,6 +267,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -284,6 +288,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -303,6 +308,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -331,6 +337,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -349,6 +356,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -368,6 +376,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -403,6 +412,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -423,6 +433,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -441,6 +452,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -461,6 +473,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -480,6 +493,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -499,6 +513,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -518,6 +533,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -537,6 +553,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -556,6 +573,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -573,6 +591,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -590,6 +609,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -614,6 +634,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Light.Button @style/Widget.DeviceDefault.Light.Button.Small @@ -762,6 +783,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -780,6 +802,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -799,6 +822,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -820,6 +844,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -840,6 +865,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -855,6 +881,7 @@ easier. @style/Theme.DeviceDefault.Light.Dialog.Alert + @dimen/config_buttonCornerRadius @style/DeviceDefault.Light.ButtonBar.AlertDialog @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @style/Widget.DeviceDefault.Light.Button.Borderless.Small @@ -885,6 +912,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -903,6 +931,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -922,6 +951,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -967,6 +997,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -987,6 +1018,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1005,6 +1037,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1025,6 +1058,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1044,6 +1078,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1061,6 +1096,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1078,6 +1114,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1107,6 +1144,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1125,6 +1163,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1153,6 +1192,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1171,6 +1211,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1189,6 +1230,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog @@ -1207,6 +1249,7 @@ easier. @style/TextAppearance.DeviceDefault.Widget.Button + @dimen/config_buttonCornerRadius @style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml index c31712136eed2..9e6b1abac6ff8 100644 --- a/core/res/res/values/themes_material.xml +++ b/core/res/res/values/themes_material.xml @@ -103,6 +103,7 @@ please see themes_device_defaults.xml. @style/Widget.Material.Button.Small @style/Widget.Material.Button.Inset @style/Widget.Material.Button.Toggle + @dimen/control_corner_material @style/Widget.Material.CompoundButton.Switch @style/Widget.Material.MediaRouteButton @@ -472,6 +473,7 @@ please see themes_device_defaults.xml. @style/Widget.Material.Light.Button.Small @style/Widget.Material.Light.Button.Inset @style/Widget.Material.Light.Button.Toggle + @dimen/control_corner_material @style/Widget.Material.Light.CompoundButton.Switch @style/Widget.Material.Light.MediaRouteButton