Create style for AlertDialog in SystemUI
This creates the style up to the design spec and customizes the following: * Dialog icon on top of title * Font sizes and colors * Buttons * Padding Using R.style.Theme_SystemUI_Dialog for an AlertDialog (or preferably a SystemUIDialog) will make sure that the correct style is applied. Test: manual, using a test dialog Fixes: 203666386 Change-Id: Ied39acb05295dea1e1e353ef504d013900a97266 Merged-In: Ied39acb05295dea1e1e353ef504d013900a97266
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?androidprv:attr/textColorOnAccent" />
|
||||
</selector>
|
||||
@@ -16,8 +16,8 @@
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:insetTop="@dimen/qs_dialog_button_vertical_inset"
|
||||
android:insetBottom="@dimen/qs_dialog_button_vertical_inset">
|
||||
android:insetTop="@dimen/dialog_button_vertical_inset"
|
||||
android:insetBottom="@dimen/dialog_button_vertical_inset">
|
||||
<ripple android:color="?android:attr/colorControlHighlight">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
@@ -29,10 +29,10 @@
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="?android:attr/buttonCornerRadius"/>
|
||||
<solid android:color="?androidprv:attr/colorAccentPrimary"/>
|
||||
<padding android:left="@dimen/qs_dialog_button_horizontal_padding"
|
||||
android:top="@dimen/qs_dialog_button_vertical_padding"
|
||||
android:right="@dimen/qs_dialog_button_horizontal_padding"
|
||||
android:bottom="@dimen/qs_dialog_button_vertical_padding"/>
|
||||
<padding android:left="@dimen/dialog_button_horizontal_padding"
|
||||
android:top="@dimen/dialog_button_vertical_padding"
|
||||
android:right="@dimen/dialog_button_horizontal_padding"
|
||||
android:bottom="@dimen/dialog_button_vertical_padding"/>
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:insetTop="@dimen/qs_dialog_button_vertical_inset"
|
||||
android:insetBottom="@dimen/qs_dialog_button_vertical_inset">
|
||||
android:insetTop="@dimen/dialog_button_vertical_inset"
|
||||
android:insetBottom="@dimen/dialog_button_vertical_inset">
|
||||
<ripple android:color="?android:attr/colorControlHighlight">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
@@ -32,10 +32,10 @@
|
||||
<stroke android:color="?androidprv:attr/colorAccentPrimary"
|
||||
android:width="1dp"
|
||||
/>
|
||||
<padding android:left="@dimen/qs_dialog_button_horizontal_padding"
|
||||
android:top="@dimen/qs_dialog_button_vertical_padding"
|
||||
android:right="@dimen/qs_dialog_button_horizontal_padding"
|
||||
android:bottom="@dimen/qs_dialog_button_vertical_padding"/>
|
||||
<padding android:left="@dimen/dialog_button_horizontal_padding"
|
||||
android:top="@dimen/dialog_button_vertical_padding"
|
||||
android:right="@dimen/dialog_button_horizontal_padding"
|
||||
android:bottom="@dimen/dialog_button_vertical_padding"/>
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@*android:id/buttonPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"
|
||||
android:scrollIndicators="top|bottom"
|
||||
android:fillViewport="true"
|
||||
android:paddingTop="@dimen/dialog_button_bar_top_padding"
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding"
|
||||
android:paddingBottom="@dimen/dialog_bottom_padding"
|
||||
style="?android:attr/buttonBarStyle">
|
||||
<com.android.internal.widget.ButtonBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layoutDirection="locale"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="bottom">
|
||||
|
||||
<Button
|
||||
android:id="@android:id/button3"
|
||||
style="?android:attr/buttonBarNeutralButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Space
|
||||
android:id="@*android:id/spacer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<Button
|
||||
android:id="@android:id/button2"
|
||||
style="?android:attr/buttonBarNegativeButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@android:id/button1"
|
||||
style="?android:attr/buttonBarPositiveButtonStyle"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.android.internal.widget.ButtonBarLayout>
|
||||
</ScrollView>
|
||||
91
packages/SystemUI/res/layout/alert_dialog_systemui.xml
Normal file
91
packages/SystemUI/res/layout/alert_dialog_systemui.xml
Normal file
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.android.internal.widget.AlertDialogLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@*android:id/parentPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/dialog_top_padding"
|
||||
>
|
||||
|
||||
<include layout="@layout/alert_dialog_title_systemui" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@*android:id/contentPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding"
|
||||
>
|
||||
|
||||
<ScrollView
|
||||
android:id="@*android:id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Space
|
||||
android:id="@*android:id/textSpacerNoTitle"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@*android:id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.Dialog.Body.Message" />
|
||||
|
||||
<Space
|
||||
android:id="@*android:id/textSpacerNoButtons"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="6dp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@*android:id/customPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding"
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@*android:id/custom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
|
||||
<include
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/alert_dialog_button_bar_systemui" />
|
||||
|
||||
</com.android.internal.widget.AlertDialogLayout>
|
||||
63
packages/SystemUI/res/layout/alert_dialog_title_systemui.xml
Normal file
63
packages/SystemUI/res/layout/alert_dialog_title_systemui.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:id="@*android:id/topPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding"
|
||||
>
|
||||
|
||||
<!-- If the client uses a customTitle, it will be added here. -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@*android:id/title_template"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal|top">
|
||||
|
||||
<ImageView
|
||||
android:id="@*android:id/icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@null"
|
||||
android:tint="?androidprv:attr/colorAccentPrimaryVariant"
|
||||
/>
|
||||
|
||||
<com.android.internal.widget.DialogTitle
|
||||
android:id="@*android:id/alertTitle"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
style="@style/TextAppearance.Dialog.Title" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:id="@*android:id/titleDividerNoCustom"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp" />
|
||||
</LinearLayout>
|
||||
@@ -31,7 +31,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/qs_user_switch_dialog_title"
|
||||
android:textAppearance="@style/TextAppearance.QSDialog.Title"
|
||||
android:textAppearance="@style/TextAppearance.Dialog.Title"
|
||||
android:layout_marginBottom="32dp"
|
||||
sysui:layout_constraintTop_toTopOf="parent"
|
||||
sysui:layout_constraintStart_toStartOf="parent"
|
||||
@@ -71,7 +71,7 @@
|
||||
sysui:layout_constraintStart_toStartOf="parent"
|
||||
sysui:layout_constraintEnd_toStartOf="@id/done"
|
||||
sysui:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
style="@style/Widget.QSDialog.Button.BorderButton"
|
||||
style="@style/Widget.Dialog.Button.BorderButton"
|
||||
/>
|
||||
|
||||
<Button
|
||||
@@ -83,7 +83,7 @@
|
||||
sysui:layout_constraintBottom_toBottomOf="parent"
|
||||
sysui:layout_constraintStart_toEndOf="@id/settings"
|
||||
sysui:layout_constraintEnd_toEndOf="parent"
|
||||
style="@style/Widget.QSDialog.Button"
|
||||
style="@style/Widget.Dialog.Button"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<style name="Theme.SystemUI.Dialog" parent="@android:style/Theme.DeviceDefault.Dialog">
|
||||
<item name="android:buttonCornerRadius">28dp</item>
|
||||
</style>
|
||||
<style name="Theme.SystemUI.DayNightDialog" parent="@android:style/Theme.DeviceDefault.Dialog"/>
|
||||
|
||||
<style name="Theme.SystemUI.Dialog.Alert" parent="@*android:style/Theme.DeviceDefault.Dialog.Alert" />
|
||||
|
||||
|
||||
@@ -1275,10 +1275,19 @@
|
||||
|
||||
<dimen name="drag_and_drop_icon_size">70dp</dimen>
|
||||
|
||||
<dimen name="qs_dialog_button_horizontal_padding">16dp</dimen>
|
||||
<dimen name="qs_dialog_button_vertical_padding">8dp</dimen>
|
||||
<!-- Dimensions for unified SystemUI dialogs styling. Used by Theme.SystemUI.Dialog and
|
||||
alert_dialog_systemui.xml
|
||||
-->
|
||||
<dimen name="dialog_button_horizontal_padding">16dp</dimen>
|
||||
<dimen name="dialog_button_vertical_padding">8dp</dimen>
|
||||
<!-- The button will be 48dp tall, but the background needs to be 36dp tall -->
|
||||
<dimen name="qs_dialog_button_vertical_inset">6dp</dimen>
|
||||
<dimen name="dialog_button_vertical_inset">6dp</dimen>
|
||||
<dimen name="dialog_top_padding">24dp</dimen>
|
||||
<dimen name="dialog_bottom_padding">18dp</dimen>
|
||||
<dimen name="dialog_side_padding">24dp</dimen>
|
||||
<dimen name="dialog_button_bar_top_padding">32dp</dimen>
|
||||
|
||||
<!-- ************************************************************************* -->
|
||||
|
||||
<dimen name="keyguard_unfold_translation_x">16dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- NOTE: Adding the androidprv: namespace to this file will break the studio build. -->
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||
|
||||
<!-- HybridNotification themes and styles -->
|
||||
|
||||
@@ -351,11 +351,19 @@
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.SystemUI.Dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
|
||||
<style name="Theme.SystemUI.DayNightDialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog"/>
|
||||
|
||||
<style name="Theme.SystemUI.Dialog" parent="@style/Theme.SystemUI.DayNightDialog">
|
||||
<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>
|
||||
<item name="android:buttonBarPositiveButtonStyle">@style/Widget.Dialog.Button</item>
|
||||
<item name="android:buttonBarNegativeButtonStyle">@style/Widget.Dialog.Button.BorderButton</item>
|
||||
<item name="android:buttonBarNeutralButtonStyle">@style/Widget.Dialog.Button.BorderButton</item>
|
||||
<item name="android:colorBackground">?androidprv:attr/colorSurface</item>
|
||||
<item name="android:alertDialogStyle">@style/AlertDialogStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AlertDialogStyle" parent="@androidprv:style/AlertDialog.DeviceDefault">
|
||||
<item name="android:layout">@layout/alert_dialog_systemui</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.SystemUI.Dialog.Alert" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
|
||||
@@ -853,24 +861,37 @@
|
||||
<item name="actionDividerHeight">32dp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QSDialog.Title" parent="Theme.SystemUI.Dialog">
|
||||
<style name="TextAppearance.Dialog.Title" parent="@android:style/TextAppearance.DeviceDefault.Large">
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textSize">24sp</item>
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
<item name="android:lineHeight">32sp</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:textAlignment">center</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.QSDialog.Button" parent = "Theme.SystemUI.Dialog">
|
||||
<style name="TextAppearance.Dialog.Body" parent="@android:style/TextAppearance.DeviceDefault.Medium">
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
<item name="android:lineHeight">20sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Dialog.Body.Message">
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:textAlignment">center</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Dialog.Button" parent = "Theme.SystemUI.Dialog">
|
||||
<item name="android:background">@drawable/qs_dialog_btn_filled</item>
|
||||
<item name="android:textColor">@color/prv_text_color_on_accent</item>
|
||||
<item name="android:textColor">?androidprv:attr/textColorOnAccent</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:lineHeight">20sp</item>
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
|
||||
<item name="android:stateListAnimator">@null</item>
|
||||
<item name="android:layout_marginHorizontal">4dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.QSDialog.Button.BorderButton">
|
||||
<style name="Widget.Dialog.Button.BorderButton">
|
||||
<item name="android:background">@drawable/qs_dialog_btn_outline</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user