Make AlertDialog use specific styles per button

As the buttons in an alert dialog are identified with Positive,
Negative, Neutral, use the corresponding style attributes. That way,
they can be styled independently.

Style them independently in SystemUI. This allows for AlertDialog or
SystemUIDialog created with the right theme to be able to use the
default buttons with correct styling.

Test: manual (AddUserDialog)
Bug: 203666386
Change-Id: I4f292193bff5dec90f8dc229a9824d22075d5241
This commit is contained in:
Fabian Kozynski
2021-10-20 12:32:06 -04:00
parent 104ef43ddd
commit 6f78e3c16b
2 changed files with 6 additions and 3 deletions

View File

@@ -124,21 +124,21 @@
android:layout_width="0dip"
android:layout_gravity="start"
android:layout_weight="1"
style="?android:attr/buttonBarButtonStyle"
style="?android:attr/buttonBarPositiveButtonStyle"
android:maxLines="2"
android:layout_height="wrap_content" />
<Button android:id="@+id/button3"
android:layout_width="0dip"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
style="?android:attr/buttonBarButtonStyle"
style="?android:attr/buttonBarNeutralButtonStyle"
android:maxLines="2"
android:layout_height="wrap_content" />
<Button android:id="@+id/button2"
android:layout_width="0dip"
android:layout_gravity="end"
android:layout_weight="1"
style="?android:attr/buttonBarButtonStyle"
style="?android:attr/buttonBarNegativeButtonStyle"
android:maxLines="2"
android:layout_height="wrap_content" />
<LinearLayout android:id="@+id/rightSpacer"

View File

@@ -419,6 +419,9 @@
<style name="Theme.SystemUI.Dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
<item name="android:buttonCornerRadius">28dp</item>
<item name="android:buttonBarPositiveButtonStyle">@style/Widget.QSDialog.Button</item>
<item name="android:buttonBarNegativeButtonStyle">@style/Widget.QSDialog.Button.BorderButton</item>
<item name="android:buttonBarNeutralButtonStyle">@style/Widget.QSDialog.Button.BorderButton</item>
</style>
<style name="Theme.SystemUI.Dialog.Alert" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert" />