summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2023-12-13 23:24:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-12-13 23:24:59 +0000
commitc9a3d8cbf247e76f1e4f2b4ce6d5fd1a46d0cccb (patch)
treeaebdc230b2ed55dceb9f841d3af075a97e97d740
parent3039b071c023bf450d47b4498f5032ca777eed43 (diff)
parent33b9f42fc12644d0813145aa401a7142d4b497f8 (diff)
downloadWallpaperPicker2-c9a3d8cbf247e76f1e4f2b4ce6d5fd1a46d0cccb.tar.gz
Merge "Update set wallpaper dialog style" into main
-rw-r--r--res/drawable/set_wallpaper_dialog_button.xml (renamed from res/drawable/set_wallpaper_dialog_positive_button.xml)14
-rw-r--r--res/drawable/set_wallpaper_dialog_outlined_button.xml46
-rw-r--r--res/drawable/set_wallpaper_dialog_positive_button_base.xml26
-rw-r--r--res/drawable/set_wallpaper_dialog_text_button.xml43
-rw-r--r--res/layout/set_wallpaper_dialog.xml42
-rwxr-xr-xres/values-notnight-v27/styles.xml7
-rwxr-xr-xres/values/styles.xml31
-rw-r--r--src/com/android/wallpaper/picker/preview/ui/binder/SetWallpaperDialogBinder.kt15
-rw-r--r--src/com/android/wallpaper/picker/preview/ui/fragment/SetWallpaperDialogFragment.kt15
9 files changed, 172 insertions, 67 deletions
diff --git a/res/drawable/set_wallpaper_dialog_positive_button.xml b/res/drawable/set_wallpaper_dialog_button.xml
index 540a8a49..1011e805 100644
--- a/res/drawable/set_wallpaper_dialog_positive_button.xml
+++ b/res/drawable/set_wallpaper_dialog_button.xml
@@ -28,6 +28,16 @@
<solid android:color="?android:colorControlHighlight" />
</shape>
</item>
-
- <item android:drawable="@drawable/set_wallpaper_dialog_positive_button_base" />
+ <item>
+ <shape
+ android:shape="rectangle">
+ <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
+ <padding
+ android:left="@dimen/set_wallpaper_button_horizontal_padding"
+ android:top="@dimen/set_wallpaper_button_vertical_padding"
+ android:right="@dimen/set_wallpaper_button_horizontal_padding"
+ android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
+ <solid android:color="@color/system_secondary" />
+ </shape>
+ </item>
</ripple> \ No newline at end of file
diff --git a/res/drawable/set_wallpaper_dialog_outlined_button.xml b/res/drawable/set_wallpaper_dialog_outlined_button.xml
new file mode 100644
index 00000000..af4ed7ec
--- /dev/null
+++ b/res/drawable/set_wallpaper_dialog_outlined_button.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 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.
+ -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:colorControlHighlight">
+
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
+ <padding
+ android:left="@dimen/set_wallpaper_button_horizontal_padding"
+ android:top="@dimen/set_wallpaper_button_vertical_padding"
+ android:right="@dimen/set_wallpaper_button_horizontal_padding"
+ android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
+ <solid android:color="?android:colorControlHighlight" />
+ </shape>
+ </item>
+ <item>
+ <shape
+ android:shape="rectangle">
+ <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
+ <solid android:color="@android:color/transparent"/>
+ <stroke
+ android:color="@color/system_primary"
+ android:width="1dp" />
+ <padding
+ android:left="@dimen/set_wallpaper_button_horizontal_padding"
+ android:top="@dimen/set_wallpaper_button_vertical_padding"
+ android:right="@dimen/set_wallpaper_button_horizontal_padding"
+ android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
+ </shape>
+ </item>
+</ripple> \ No newline at end of file
diff --git a/res/drawable/set_wallpaper_dialog_positive_button_base.xml b/res/drawable/set_wallpaper_dialog_positive_button_base.xml
deleted file mode 100644
index 5942cbb7..00000000
--- a/res/drawable/set_wallpaper_dialog_positive_button_base.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 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.
- -->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
- <padding
- android:left="@dimen/set_wallpaper_button_horizontal_padding"
- android:top="@dimen/set_wallpaper_button_vertical_padding"
- android:right="@dimen/set_wallpaper_button_horizontal_padding"
- android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
- <solid android:color="@color/system_secondary" />
-</shape> \ No newline at end of file
diff --git a/res/drawable/set_wallpaper_dialog_text_button.xml b/res/drawable/set_wallpaper_dialog_text_button.xml
new file mode 100644
index 00000000..3535ea13
--- /dev/null
+++ b/res/drawable/set_wallpaper_dialog_text_button.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 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.
+ -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:colorControlHighlight">
+
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
+ <padding
+ android:left="@dimen/set_wallpaper_button_horizontal_padding"
+ android:top="@dimen/set_wallpaper_button_vertical_padding"
+ android:right="@dimen/set_wallpaper_button_horizontal_padding"
+ android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
+ <solid android:color="?android:colorControlHighlight" />
+ </shape>
+ </item>
+ <item>
+ <shape
+ android:shape="rectangle">
+ <corners android:radius="@dimen/set_wallpaper_button_corner_radius" />
+ <padding
+ android:left="@dimen/set_wallpaper_button_horizontal_padding"
+ android:top="@dimen/set_wallpaper_button_vertical_padding"
+ android:right="@dimen/set_wallpaper_button_horizontal_padding"
+ android:bottom="@dimen/set_wallpaper_button_vertical_padding" />
+ <solid android:color="@android:color/transparent" />
+ </shape>
+ </item>
+</ripple> \ No newline at end of file
diff --git a/res/layout/set_wallpaper_dialog.xml b/res/layout/set_wallpaper_dialog.xml
index 7e5e75cb..c90a4219 100644
--- a/res/layout/set_wallpaper_dialog.xml
+++ b/res/layout/set_wallpaper_dialog.xml
@@ -13,8 +13,7 @@
~ 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.
- -->
-
+-->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -23,45 +22,32 @@
<TextView
android:id="@+id/title"
- style="@style/CategorySectionTitleTextAppearance"
+ style="@style/TextAppearance.SetWallpaperDialog.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:paddingLeft="?attr/dialogPreferredPadding"
+ android:paddingRight="?attr/dialogPreferredPadding"
+ android:paddingTop="@dimen/abc_dialog_padding_top_material"
android:text="Set wallpaper"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
+ <android.widget.Space
+ android:id="@+id/titleDividerNoCustom"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/abc_dialog_title_divider_material"
+ app:layout_constraintTop_toBottomOf="@id/title"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
<LinearLayout
android:id="@+id/previews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
- app:layout_constraintTop_toBottomOf="@+id/title"
+ app:layout_constraintTop_toBottomOf="@+id/titleDividerNoCustom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- app:layout_constraintTop_toBottomOf="@+id/previews"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent">
-
- <Button
- android:id="@+id/button_cancel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/set_wallpaper_dialog_positive_button"
- android:textColor="@color/system_on_primary"
- android:text="Cancel" />
-
- <Button
- android:id="@+id/button_set"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/set_wallpaper_dialog_positive_button"
- android:textColor="@color/system_on_primary"
- android:text="Set" />
- </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/res/values-notnight-v27/styles.xml b/res/values-notnight-v27/styles.xml
index 95c5ee50..beeadac2 100755
--- a/res/values-notnight-v27/styles.xml
+++ b/res/values-notnight-v27/styles.xml
@@ -48,4 +48,11 @@
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
<item name="android:dialogCornerRadius">24dp</item>
</style>
+
+ <!-- SetWallpaperPreviewDialog -->
+ <style name="SetWallpaperPreviewDialogTheme" parent="@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar.MinWidth">
+ <item name="android:buttonBarPositiveButtonStyle">@style/SetWallpaperDialog.Button</item>
+ <item name="android:buttonBarNegativeButtonStyle">@style/SetWallpaperDialog.Button.OutlinedButton</item>
+ <item name="android:buttonBarNeutralButtonStyle">@style/SetWallpaperDialog.Button.TextButton</item>
+ </style>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cabd900b..8112e3a7 100755
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -257,4 +257,35 @@
<item name="android:textColor">@color/system_on_surface</item>
<item name="android:background">@drawable/secondary_dialog_button_background</item>
</style>
+
+ <!-- SetWallpaperPreviewDialog -->
+ <style name="SetWallpaperPreviewDialogTheme" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar.MinWidth">
+ <item name="android:buttonBarPositiveButtonStyle">@style/SetWallpaperDialog.Button</item>
+ <item name="android:buttonBarNegativeButtonStyle">@style/SetWallpaperDialog.Button.OutlinedButton</item>
+ <item name="android:buttonBarNeutralButtonStyle">@style/SetWallpaperDialog.Button.TextButton</item>
+ </style>
+
+ <style name="SetWallpaperDialog"/>
+ <style name="SetWallpaperDialog.Button">
+ <item name="android:textColor">@color/system_on_primary</item>
+ <item name="android:background">@drawable/set_wallpaper_dialog_button</item>
+ </style>
+
+ <style name="SetWallpaperDialog.Button.OutlinedButton">
+ <item name="android:textColor">@color/system_on_surface</item>
+ <item name="android:background">@drawable/set_wallpaper_dialog_outlined_button</item>
+ </style>
+
+ <style name="SetWallpaperDialog.Button.TextButton">
+ <item name="android:textColor">@color/system_secondary</item>
+ <item name="android:background">@drawable/set_wallpaper_dialog_text_button</item>
+ </style>
+
+ <style name="TextAppearance.SetWallpaperDialog.Title" parent="@android:style/TextAppearance.DeviceDefault.Large">
+ <item name="android:textColor">@color/system_on_surface</item>
+ <item name="android:textSize">24sp</item>
+ <item name="android:lineHeight">32sp</item>
+ <item name="android:gravity">center</item>
+ <item name="android:textAlignment">center</item>
+ </style>
</resources>
diff --git a/src/com/android/wallpaper/picker/preview/ui/binder/SetWallpaperDialogBinder.kt b/src/com/android/wallpaper/picker/preview/ui/binder/SetWallpaperDialogBinder.kt
index d1a6d9e0..0bac0344 100644
--- a/src/com/android/wallpaper/picker/preview/ui/binder/SetWallpaperDialogBinder.kt
+++ b/src/com/android/wallpaper/picker/preview/ui/binder/SetWallpaperDialogBinder.kt
@@ -16,21 +16,22 @@
package com.android.wallpaper.picker.preview.ui.binder
-import android.view.View
-import android.widget.Button
-import com.android.wallpaper.R
+import android.app.AlertDialog
+import android.app.Dialog
/** Binds the dialog on small preview confirming and setting wallpaper with destination. */
object SetWallpaperDialogBinder {
fun bind(
- dialogView: View,
+ dialog: AlertDialog,
+ primaryText: String,
+ secondaryText: String,
navigate: () -> Unit,
) {
// TODO(b/303457019): For the set button, listen to a data flow of onClick listener
- dialogView.requireViewById<Button>(R.id.button_set).setOnClickListener { navigate.invoke() }
- dialogView.requireViewById<Button>(R.id.button_cancel).setOnClickListener {
- navigate.invoke()
+ dialog.apply {
+ setButton(Dialog.BUTTON_POSITIVE, primaryText) { _, _ -> navigate.invoke() }
+ setButton(Dialog.BUTTON_NEGATIVE, secondaryText) { _, _ -> navigate.invoke() }
}
}
}
diff --git a/src/com/android/wallpaper/picker/preview/ui/fragment/SetWallpaperDialogFragment.kt b/src/com/android/wallpaper/picker/preview/ui/fragment/SetWallpaperDialogFragment.kt
index 51b66840..10e9fa49 100644
--- a/src/com/android/wallpaper/picker/preview/ui/fragment/SetWallpaperDialogFragment.kt
+++ b/src/com/android/wallpaper/picker/preview/ui/fragment/SetWallpaperDialogFragment.kt
@@ -19,7 +19,7 @@ package com.android.wallpaper.picker.preview.ui.fragment
import android.app.AlertDialog
import android.app.Dialog
import android.os.Bundle
-import android.view.View
+import android.view.LayoutInflater
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
@@ -41,13 +41,20 @@ class SetWallpaperDialogFragment : Hilt_SetWallpaperDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
super.onCreateDialog(savedInstanceState)
- val layout = View.inflate(requireContext(), R.layout.set_wallpaper_dialog, null)
+ val layout =
+ LayoutInflater.from(requireContext()).inflate(R.layout.set_wallpaper_dialog, null)
+ val dialog =
+ AlertDialog.Builder(requireContext(), R.style.SetWallpaperPreviewDialogTheme)
+ .setView(layout)
+ .create()
SetWallpaperDialogBinder.bind(
- layout,
+ dialog,
+ "Set",
+ "Cancel",
) {
findNavController().popBackStack()
}
- return AlertDialog.Builder(requireContext()).setView(layout).create()
+ return dialog
}
}