Merge changes If6a02209,Ied39acb0 into sc-v2-dev
* changes: Apply dialog style to User switcher dialog. Create style for AlertDialog in SystemUI
This commit is contained in:
committed by
Android (Google) Code Review
commit
5150828ce3
@@ -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>
|
||||
@@ -22,6 +22,6 @@
|
||||
xmlns:sysui="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
sysui:verticalSpacing="4dp"
|
||||
sysui:verticalSpacing="20dp"
|
||||
sysui:horizontalSpacing="4dp"
|
||||
style="@style/UserDetailView" />
|
||||
@@ -24,8 +24,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="top|center_horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:minHeight="112dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:focusable="true"
|
||||
|
||||
@@ -15,75 +15,19 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:sysui="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/qs_user_switch_dialog_title"
|
||||
android:textAppearance="@style/TextAppearance.QSDialog.Title"
|
||||
android:layout_marginBottom="32dp"
|
||||
sysui:layout_constraintTop_toTopOf="parent"
|
||||
sysui:layout_constraintStart_toStartOf="parent"
|
||||
sysui:layout_constraintEnd_toEndOf="parent"
|
||||
sysui:layout_constraintBottom_toTopOf="@id/grid"
|
||||
/>
|
||||
|
||||
>
|
||||
<com.android.systemui.qs.PseudoGridView
|
||||
android:id="@+id/grid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="28dp"
|
||||
sysui:verticalSpacing="4dp"
|
||||
sysui:horizontalSpacing="4dp"
|
||||
sysui:fixedChildWidth="80dp"
|
||||
sysui:layout_constraintTop_toBottomOf="@id/title"
|
||||
sysui:layout_constraintStart_toStartOf="parent"
|
||||
sysui:layout_constraintEnd_toEndOf="parent"
|
||||
sysui:layout_constraintBottom_toTopOf="@id/barrier"
|
||||
/>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
sysui:barrierDirection="top"
|
||||
sysui:constraint_referenced_ids="settings,done"
|
||||
android:id="@+id/grid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
sysui:verticalSpacing="20dp"
|
||||
sysui:horizontalSpacing="4dp"
|
||||
sysui:fixedChildWidth="80dp"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:text="@string/quick_settings_more_user_settings"
|
||||
sysui:layout_constraintTop_toBottomOf="@id/barrier"
|
||||
sysui:layout_constraintBottom_toBottomOf="parent"
|
||||
sysui:layout_constraintStart_toStartOf="parent"
|
||||
sysui:layout_constraintEnd_toStartOf="@id/done"
|
||||
sysui:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
style="@style/Widget.QSDialog.Button.BorderButton"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/done"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:text="@string/quick_settings_done"
|
||||
sysui:layout_constraintTop_toBottomOf="@id/barrier"
|
||||
sysui:layout_constraintBottom_toBottomOf="parent"
|
||||
sysui:layout_constraintStart_toEndOf="@id/settings"
|
||||
sysui:layout_constraintEnd_toEndOf="parent"
|
||||
style="@style/Widget.QSDialog.Button"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
@@ -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>
|
||||
|
||||
@@ -133,10 +133,7 @@ public class PseudoGridView extends ViewGroup {
|
||||
x += width + mHorizontalSpacing;
|
||||
}
|
||||
}
|
||||
y += maxHeight;
|
||||
if (row > 0) {
|
||||
y += mVerticalSpacing;
|
||||
}
|
||||
y += maxHeight + mVerticalSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.systemui.qs.user
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowManager
|
||||
import com.android.systemui.qs.PseudoGridView
|
||||
import com.android.systemui.statusbar.phone.SystemUIDialog
|
||||
import com.android.systemui.R
|
||||
|
||||
/**
|
||||
* Dialog for switching users or creating new ones.
|
||||
*/
|
||||
class UserDialog(
|
||||
context: Context
|
||||
) : SystemUIDialog(context) {
|
||||
|
||||
// create() is no-op after creation
|
||||
private lateinit var _doneButton: View
|
||||
/**
|
||||
* Button with text "Done" in dialog.
|
||||
*/
|
||||
val doneButton: View
|
||||
get() {
|
||||
create()
|
||||
return _doneButton
|
||||
}
|
||||
|
||||
private lateinit var _settingsButton: View
|
||||
/**
|
||||
* Button with text "User Settings" in dialog.
|
||||
*/
|
||||
val settingsButton: View
|
||||
get() {
|
||||
create()
|
||||
return _settingsButton
|
||||
}
|
||||
|
||||
private lateinit var _grid: PseudoGridView
|
||||
/**
|
||||
* Grid to populate with user avatar from adapter
|
||||
*/
|
||||
val grid: ViewGroup
|
||||
get() {
|
||||
create()
|
||||
return _grid
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
window?.apply {
|
||||
setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL)
|
||||
attributes.fitInsetsTypes = attributes.fitInsetsTypes or WindowInsets.Type.statusBars()
|
||||
attributes.receiveInsetsIgnoringZOrder = true
|
||||
setGravity(Gravity.CENTER)
|
||||
}
|
||||
setContentView(R.layout.qs_user_dialog_content)
|
||||
|
||||
_doneButton = requireViewById(R.id.done)
|
||||
_settingsButton = requireViewById(R.id.settings)
|
||||
_grid = requireViewById(R.id.grid)
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,16 @@ import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.provider.Settings
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.animation.DialogLaunchAnimator
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
import com.android.systemui.qs.tiles.UserDetailView
|
||||
import com.android.systemui.statusbar.phone.SystemUIDialog
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Provider
|
||||
|
||||
@@ -40,7 +43,7 @@ class UserSwitchDialogController @VisibleForTesting constructor(
|
||||
private val activityStarter: ActivityStarter,
|
||||
private val falsingManager: FalsingManager,
|
||||
private val dialogLaunchAnimator: DialogLaunchAnimator,
|
||||
private val dialogFactory: (Context) -> UserDialog
|
||||
private val dialogFactory: (Context) -> SystemUIDialog
|
||||
) {
|
||||
|
||||
@Inject
|
||||
@@ -54,7 +57,7 @@ class UserSwitchDialogController @VisibleForTesting constructor(
|
||||
activityStarter,
|
||||
falsingManager,
|
||||
dialogLaunchAnimator,
|
||||
{ UserDialog(it) }
|
||||
{ SystemUIDialog(it) }
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -71,9 +74,10 @@ class UserSwitchDialogController @VisibleForTesting constructor(
|
||||
with(dialogFactory(view.context)) {
|
||||
setShowForAllUsers(true)
|
||||
setCanceledOnTouchOutside(true)
|
||||
create() // Needs to be called before we can retrieve views
|
||||
|
||||
settingsButton.setOnClickListener {
|
||||
setTitle(R.string.qs_user_switch_dialog_title)
|
||||
setPositiveButton(R.string.quick_settings_done, null)
|
||||
setNeutralButton(R.string.quick_settings_more_user_settings) { _, _ ->
|
||||
if (!falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||
dialogLaunchAnimator.disableAllCurrentDialogsExitAnimations()
|
||||
activityStarter.postStartActivityDismissingKeyguard(
|
||||
@@ -81,12 +85,14 @@ class UserSwitchDialogController @VisibleForTesting constructor(
|
||||
0
|
||||
)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
doneButton.setOnClickListener { dismiss() }
|
||||
val gridFrame = LayoutInflater.from(this.context)
|
||||
.inflate(R.layout.qs_user_dialog_content, null)
|
||||
setView(gridFrame)
|
||||
|
||||
val adapter = userDetailViewAdapterProvider.get()
|
||||
adapter.linkToViewGroup(grid)
|
||||
|
||||
adapter.linkToViewGroup(gridFrame.findViewById(R.id.grid))
|
||||
|
||||
val hostDialog = dialogLaunchAnimator.showFromView(this, view)
|
||||
adapter.injectDialogShower(DialogShowerImpl(hostDialog, dialogLaunchAnimator))
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.systemui.qs.user
|
||||
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@TestableLooper.RunWithLooper
|
||||
class UserDialogTest : SysuiTestCase() {
|
||||
|
||||
private lateinit var dialog: UserDialog
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
dialog = UserDialog(mContext)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun doneButtonExists() {
|
||||
assertThat(dialog.doneButton).isInstanceOf(View::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun settingsButtonExists() {
|
||||
assertThat(dialog.settingsButton).isInstanceOf(View::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun gridExistsAndIsViewGroup() {
|
||||
assertThat(dialog.grid).isInstanceOf(ViewGroup::class.java)
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.qs.user
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.provider.Settings
|
||||
import android.testing.AndroidTestingRunner
|
||||
@@ -28,6 +29,7 @@ import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
import com.android.systemui.qs.PseudoGridView
|
||||
import com.android.systemui.qs.tiles.UserDetailView
|
||||
import com.android.systemui.statusbar.phone.SystemUIDialog
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.android.systemui.util.mockito.argumentCaptor
|
||||
import com.android.systemui.util.mockito.capture
|
||||
@@ -43,7 +45,6 @@ import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.anyBoolean
|
||||
import org.mockito.Mockito.anyInt
|
||||
import org.mockito.Mockito.argThat
|
||||
import org.mockito.Mockito.inOrder
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
@@ -53,27 +54,21 @@ import org.mockito.MockitoAnnotations
|
||||
class UserSwitchDialogControllerTest : SysuiTestCase() {
|
||||
|
||||
@Mock
|
||||
private lateinit var dialog: UserDialog
|
||||
private lateinit var dialog: SystemUIDialog
|
||||
@Mock
|
||||
private lateinit var falsingManager: FalsingManager
|
||||
@Mock
|
||||
private lateinit var settingsView: View
|
||||
@Mock
|
||||
private lateinit var doneView: View
|
||||
@Mock
|
||||
private lateinit var activityStarter: ActivityStarter
|
||||
@Mock
|
||||
private lateinit var userDetailViewAdapter: UserDetailView.Adapter
|
||||
@Mock
|
||||
private lateinit var launchView: View
|
||||
@Mock
|
||||
private lateinit var gridView: PseudoGridView
|
||||
@Mock
|
||||
private lateinit var dialogLaunchAnimator: DialogLaunchAnimator
|
||||
@Mock
|
||||
private lateinit var hostDialog: Dialog
|
||||
@Captor
|
||||
private lateinit var clickCaptor: ArgumentCaptor<View.OnClickListener>
|
||||
private lateinit var clickCaptor: ArgumentCaptor<DialogInterface.OnClickListener>
|
||||
|
||||
private lateinit var controller: UserSwitchDialogController
|
||||
|
||||
@@ -81,11 +76,8 @@ class UserSwitchDialogControllerTest : SysuiTestCase() {
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
|
||||
`when`(dialog.settingsButton).thenReturn(settingsView)
|
||||
`when`(dialog.doneButton).thenReturn(doneView)
|
||||
`when`(dialog.grid).thenReturn(gridView)
|
||||
|
||||
`when`(launchView.context).thenReturn(mContext)
|
||||
`when`(dialog.context).thenReturn(mContext)
|
||||
`when`(dialogLaunchAnimator.showFromView(any(), any(), anyBoolean()))
|
||||
.thenReturn(hostDialog)
|
||||
|
||||
@@ -104,30 +96,6 @@ class UserSwitchDialogControllerTest : SysuiTestCase() {
|
||||
verify(dialogLaunchAnimator).showFromView(dialog, launchView)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createCalledBeforeDoneButton() {
|
||||
controller.showDialog(launchView)
|
||||
val inOrder = inOrder(dialog)
|
||||
inOrder.verify(dialog).create()
|
||||
inOrder.verify(dialog).doneButton
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createCalledBeforeSettingsButton() {
|
||||
controller.showDialog(launchView)
|
||||
val inOrder = inOrder(dialog)
|
||||
inOrder.verify(dialog).create()
|
||||
inOrder.verify(dialog).settingsButton
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createCalledBeforeGrid() {
|
||||
controller.showDialog(launchView)
|
||||
val inOrder = inOrder(dialog)
|
||||
inOrder.verify(dialog).create()
|
||||
inOrder.verify(dialog).grid
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dialog_showForAllUsers() {
|
||||
controller.showDialog(launchView)
|
||||
@@ -143,51 +111,44 @@ class UserSwitchDialogControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun adapterAndGridLinked() {
|
||||
controller.showDialog(launchView)
|
||||
verify(userDetailViewAdapter).linkToViewGroup(gridView)
|
||||
verify(userDetailViewAdapter).linkToViewGroup(any<PseudoGridView>())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clickDoneButton_dismiss() {
|
||||
fun doneButtonSetWithNullHandler() {
|
||||
controller.showDialog(launchView)
|
||||
|
||||
verify(doneView).setOnClickListener(capture(clickCaptor))
|
||||
|
||||
clickCaptor.value.onClick(doneView)
|
||||
|
||||
verify(activityStarter, never()).postStartActivityDismissingKeyguard(any(), anyInt())
|
||||
verify(dialog).dismiss()
|
||||
verify(dialog).setPositiveButton(anyInt(), eq(null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clickSettingsButton_noFalsing_opensSettingsAndDismisses() {
|
||||
fun clickSettingsButton_noFalsing_opensSettings() {
|
||||
`when`(falsingManager.isFalseTap(anyInt())).thenReturn(false)
|
||||
|
||||
controller.showDialog(launchView)
|
||||
|
||||
verify(settingsView).setOnClickListener(capture(clickCaptor))
|
||||
verify(dialog).setNeutralButton(anyInt(), capture(clickCaptor))
|
||||
|
||||
clickCaptor.value.onClick(settingsView)
|
||||
clickCaptor.value.onClick(dialog, DialogInterface.BUTTON_NEUTRAL)
|
||||
|
||||
verify(activityStarter)
|
||||
.postStartActivityDismissingKeyguard(
|
||||
argThat(IntentMatcher(Settings.ACTION_USER_SETTINGS)),
|
||||
eq(0)
|
||||
)
|
||||
verify(dialog).dismiss()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clickSettingsButton_Falsing_notOpensSettingsAndDismisses() {
|
||||
fun clickSettingsButton_Falsing_notOpensSettings() {
|
||||
`when`(falsingManager.isFalseTap(anyInt())).thenReturn(true)
|
||||
|
||||
controller.showDialog(launchView)
|
||||
|
||||
verify(settingsView).setOnClickListener(capture(clickCaptor))
|
||||
verify(dialog).setNeutralButton(anyInt(), capture(clickCaptor))
|
||||
|
||||
clickCaptor.value.onClick(settingsView)
|
||||
clickCaptor.value.onClick(dialog, DialogInterface.BUTTON_NEUTRAL)
|
||||
|
||||
verify(activityStarter, never()).postStartActivityDismissingKeyguard(any(), anyInt())
|
||||
verify(dialog).dismiss()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user