Merge "Add meaningful accessibility labels for color picker (1/2)" into udc-dev
diff --git a/res/layout/clock_color_option.xml b/res/layout/clock_color_option.xml
index 4203a39..f27c13d 100644
--- a/res/layout/clock_color_option.xml
+++ b/res/layout/clock_color_option.xml
@@ -21,72 +21,8 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:clipChildren="false">
- <FrameLayout
- android:id="@+id/icon_container"
- android:layout_width="@dimen/option_item_size"
- android:layout_height="@dimen/option_item_size"
- android:clipChildren="false">
- <ImageView
- android:id="@id/selection_border"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/option_item_border"
- android:alpha="0"
- android:importantForAccessibility="no" />
-
- <ImageView
- android:id="@id/background"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/option_item_background"
- android:importantForAccessibility="no" />
-
- <FrameLayout
- android:id="@id/foreground"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <ImageView
- android:id="@+id/color_preview_0"
- android:layout_width="@dimen/component_color_chip_small_radius_default2"
- android:layout_height="@dimen/component_color_chip_small_radius_default2"
- android:layout_gravity="center"
- android:layout_marginRight="@dimen/color_seed_chip_margin2"
- android:layout_marginBottom="@dimen/color_seed_chip_margin2"
- android:src="@drawable/color_chip_seed_filled0"
- android:importantForAccessibility="no"/>
-
- <ImageView
- android:id="@+id/color_preview_1"
- android:layout_width="@dimen/component_color_chip_small_radius_default2"
- android:layout_height="@dimen/component_color_chip_small_radius_default2"
- android:layout_gravity="center"
- android:layout_marginLeft="@dimen/color_seed_chip_margin2"
- android:layout_marginBottom="@dimen/color_seed_chip_margin2"
- android:src="@drawable/color_chip_seed_filled2"
- android:importantForAccessibility="no"/>
-
- <ImageView
- android:id="@+id/color_preview_2"
- android:layout_width="@dimen/component_color_chip_small_radius_default2"
- android:layout_height="@dimen/component_color_chip_small_radius_default2"
- android:layout_gravity="center"
- android:layout_marginRight="@dimen/color_seed_chip_margin2"
- android:layout_marginTop="@dimen/color_seed_chip_margin2"
- android:src="@drawable/color_chip_seed_filled1"
- android:importantForAccessibility="no"/>
-
- <ImageView
- android:id="@+id/color_preview_3"
- android:layout_width="@dimen/component_color_chip_small_radius_default2"
- android:layout_height="@dimen/component_color_chip_small_radius_default2"
- android:layout_gravity="center"
- android:layout_marginLeft="@dimen/color_seed_chip_margin2"
- android:layout_marginTop="@dimen/color_seed_chip_margin2"
- android:src="@drawable/color_chip_seed_filled3"
- android:importantForAccessibility="no" />
- </FrameLayout>
- </FrameLayout>
+ <include layout="@layout/color_option_2"/>
<TextView
android:id="@+id/text"
diff --git a/res/layout/clock_size_radio_button_group.xml b/res/layout/clock_size_radio_button_group.xml
index 4264007..30e39ad 100644
--- a/res/layout/clock_size_radio_button_group.xml
+++ b/res/layout/clock_size_radio_button_group.xml
@@ -57,6 +57,7 @@
android:id="@+id/button_container_small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
android:orientation="horizontal">
<RadioButton
diff --git a/res/layout/color_option_2.xml b/res/layout/color_option_2.xml
index 8bacd99..dff03d0 100644
--- a/res/layout/color_option_2.xml
+++ b/res/layout/color_option_2.xml
@@ -16,7 +16,6 @@
<!-- Content description is set programmatically on the parent FrameLayout -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/option_item_size"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -48,16 +47,5 @@
android:layout_height="match_parent"
android:layout_margin="@dimen/color_seed_chip_margin2"/>
</FrameLayout>
-
- <TextView
- android:id="@+id/text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/option_bottom_margin"
- android:textColor="@color/text_color_primary"
- android:visibility="gone"
- android:gravity="center"
- android:text="Placeholder for stable size calculation, please do not remove."
- tools:ignore="HardcodedText" />
</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4392ebf..1ef739b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -176,4 +176,6 @@
copied from sysui resources
-->
<dimen name="keyguard_large_clock_top_margin">-60dp</dimen>
+
+ <dimen name="tab_touch_delegate_height_padding">8dp</dimen>
</resources>
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index d4c4bfc..6c83f23 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -363,6 +363,7 @@
when (colorScheme.style) {
Style.FRUIT_SALAD -> intArrayOf(seed, colorScheme.accent1.s200)
Style.TONAL_SPOT -> intArrayOf(colorScheme.accentColor, colorScheme.accentColor)
+ Style.RAINBOW -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200)
else -> intArrayOf(colorScheme.accent1.s100, colorScheme.accent1.s100)
}
return intArrayOf(
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index 6a5f2f6..520b301 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -1,5 +1,6 @@
package com.android.customization.module;
+import android.app.WallpaperManager;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -100,6 +101,7 @@
DisplayUtils displayUtils,
CustomizationPickerViewModel customizationPickerViewModel,
WallpaperInteractor wallpaperInteractor,
+ WallpaperManager wallpaperManager,
boolean isTwoPaneAndSmallWidth) {
List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
@@ -118,6 +120,7 @@
wallpaperPreviewNavigator,
sectionNavigationController,
wallpaperInteractor,
+ wallpaperManager,
isTwoPaneAndSmallWidth)
: new ScreenPreviewSectionController(
activity,
@@ -128,6 +131,7 @@
displayUtils,
wallpaperPreviewNavigator,
wallpaperInteractor,
+ wallpaperManager,
isTwoPaneAndSmallWidth));
sectionControllers.add(
diff --git a/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt b/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
index 746fdb3..d0e6f18 100644
--- a/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
+++ b/src/com/android/customization/picker/clock/ui/adapter/ClockSettingsTabAdapter.kt
@@ -16,13 +16,17 @@
*/
package com.android.customization.picker.clock.ui.adapter
+import android.graphics.Rect
import android.view.LayoutInflater
+import android.view.TouchDelegate
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.clock.ui.viewmodel.ClockSettingsTabViewModel
import com.android.wallpaper.R
+import com.android.wallpaper.util.ViewUtils.setupTouchDelegate
+
/** Adapter for the tab recycler view on the clock settings screen. */
class ClockSettingsTabAdapter : RecyclerView.Adapter<ClockSettingsTabAdapter.ViewHolder>() {
@@ -54,6 +58,10 @@
val item = items[position]
holder.itemView.isSelected = item.isSelected
holder.textView.text = item.name
+ holder.textView.setupTouchDelegate(
+ parentView = holder.itemView,
+ heightRes = R.dimen.tab_touch_delegate_height_padding
+ )
holder.textView.setOnClickListener(
if (item.onClicked != null) {
View.OnClickListener { item.onClicked.invoke() }
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
index 921151b..4a8ebeb 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -133,7 +133,7 @@
val item =
LayoutInflater.from(view.context)
.inflate(
- R.layout.color_option_2,
+ R.layout.clock_color_option,
colorOptionContainerListView,
false,
) as LinearLayout
diff --git a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
index 88d6d8e..7edaecf 100644
--- a/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
+++ b/src/com/android/customization/picker/clock/ui/fragment/ClockSettingsFragment.kt
@@ -79,7 +79,7 @@
R.string.lock_screen_preview_provider_authority,
),
),
- wallpaperInfoProvider = {
+ wallpaperInfoProvider = { forceReload ->
suspendCancellableCoroutine { continuation ->
injector
.getCurrentWallpaperInfoFactory(context)
@@ -90,7 +90,7 @@
null,
)
},
- /* forceRefresh= */ true,
+ forceReload,
)
}
},
@@ -134,6 +134,10 @@
}
override fun getDefaultTitle(): CharSequence {
- return requireContext().getString(R.string.clock_settings_title)
+ return requireContext().getString(R.string.clock_color_and_size_title)
+ }
+
+ override fun getToolbarColorId(): Int {
+ return android.R.color.transparent
}
}
diff --git a/src/com/android/customization/picker/color/ColorPickerFragment.kt b/src/com/android/customization/picker/color/ColorPickerFragment.kt
deleted file mode 100644
index c8ecb7f..0000000
--- a/src/com/android/customization/picker/color/ColorPickerFragment.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-package com.android.customization.picker.color
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import com.android.wallpaper.R
-import com.android.wallpaper.picker.AppbarFragment
-
-// TODO (b/262924623): Color Picker Fragment
-class ColorPickerFragment : AppbarFragment() {
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View {
- val view =
- inflater.inflate(
- R.layout.fragment_color_picker,
- container,
- false,
- )
- setUpToolbar(view)
- return view
- }
-}
diff --git a/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt b/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
index bb9f082..ac5ad81 100644
--- a/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
+++ b/src/com/android/customization/picker/color/ui/adapter/ColorTypeTabAdapter.kt
@@ -17,13 +17,16 @@
package com.android.customization.picker.color.ui.adapter
+import android.graphics.Rect
import android.view.LayoutInflater
+import android.view.TouchDelegate
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.color.ui.viewmodel.ColorTypeTabViewModel
import com.android.wallpaper.R
+import com.android.wallpaper.util.ViewUtils.setupTouchDelegate
/** Adapts between color type items and views. */
class ColorTypeTabAdapter : RecyclerView.Adapter<ColorTypeTabAdapter.ViewHolder>() {
@@ -55,6 +58,10 @@
val item = items[position]
holder.itemView.isSelected = item.isSelected
holder.textView.text = item.name
+ holder.textView.setupTouchDelegate(
+ parentView = holder.itemView,
+ heightRes = R.dimen.tab_touch_delegate_height_padding
+ )
holder.textView.setOnClickListener(
if (item.onClick != null) {
View.OnClickListener { item.onClick.invoke() }
diff --git a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
index 23ad037..ef38f8b 100644
--- a/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
+++ b/src/com/android/customization/picker/color/ui/fragment/ColorPickerFragment.kt
@@ -98,13 +98,13 @@
R.string.lock_screen_preview_provider_authority,
),
),
- wallpaperInfoProvider = {
+ wallpaperInfoProvider = { forceReload ->
suspendCancellableCoroutine { continuation ->
wallpaperInfoFactory.createCurrentWallpaperInfos(
{ homeWallpaper, lockWallpaper, _ ->
continuation.resume(lockWallpaper ?: homeWallpaper, null)
},
- /* forceRefresh= */ true,
+ forceReload,
)
}
},
@@ -133,13 +133,13 @@
R.string.grid_control_metadata_name,
),
),
- wallpaperInfoProvider = {
+ wallpaperInfoProvider = { forceReload ->
suspendCancellableCoroutine { continuation ->
wallpaperInfoFactory.createCurrentWallpaperInfos(
{ homeWallpaper, lockWallpaper, _ ->
continuation.resume(homeWallpaper ?: lockWallpaper, null)
},
- /* forceRefresh= */ true,
+ forceReload,
)
}
},
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
index 4bd5f1c..5ad01a8 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -17,6 +17,7 @@
package com.android.customization.picker.preview.ui.section
+import android.app.WallpaperManager
import android.content.Context
import android.graphics.Rect
import android.os.Bundle
@@ -65,6 +66,7 @@
wallpaperPreviewNavigator: WallpaperPreviewNavigator,
private val navigationController: CustomizationSectionNavigationController,
wallpaperInteractor: WallpaperInteractor,
+ wallpaperManager: WallpaperManager,
private val isTwoPaneAndSmallWidth: Boolean,
) :
ScreenPreviewSectionController(
@@ -76,6 +78,7 @@
displayUtils,
wallpaperPreviewNavigator,
wallpaperInteractor,
+ wallpaperManager,
isTwoPaneAndSmallWidth,
) {
diff --git a/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt b/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
index 5203ed3..b34ea1b 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/adapter/SlotTabAdapter.kt
@@ -17,13 +17,16 @@
package com.android.customization.picker.quickaffordance.ui.adapter
+import android.graphics.Rect
import android.view.LayoutInflater
+import android.view.TouchDelegate
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordanceSlotViewModel
import com.android.wallpaper.R
+import com.android.wallpaper.util.ViewUtils.setupTouchDelegate
/** Adapts between lock screen quick affordance slot items and views. */
class SlotTabAdapter : RecyclerView.Adapter<SlotTabAdapter.ViewHolder>() {
@@ -55,6 +58,10 @@
val item = items[position]
holder.itemView.isSelected = item.isSelected
holder.textView.text = item.name
+ holder.textView.setupTouchDelegate(
+ parentView = holder.itemView,
+ heightRes = R.dimen.tab_touch_delegate_height_padding
+ )
holder.textView.setOnClickListener(
if (item.onClicked != null) {
View.OnClickListener { item.onClicked.invoke() }
diff --git a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
index 0a52e8f..8a8bb20 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
@@ -91,13 +91,13 @@
)
}
},
- wallpaperInfoProvider = {
+ wallpaperInfoProvider = { forceReload ->
suspendCancellableCoroutine { continuation ->
wallpaperInfoFactory.createCurrentWallpaperInfos(
{ homeWallpaper, lockWallpaper, _ ->
continuation.resume(lockWallpaper ?: homeWallpaper, null)
},
- /* forceRefresh= */ true,
+ forceReload,
)
}
},