Merge "Color Option Selection Animation Clean up" into udc-dev
diff --git a/res/layout/color_option_with_background.xml b/res/layout/color_option_with_background.xml
deleted file mode 100644
index 36990b5..0000000
--- a/res/layout/color_option_with_background.xml
+++ /dev/null
@@ -1,93 +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.
--->
-<!-- Content description is set programmatically on the parent FrameLayout -->
-<!-- TODO (b/272109171): Remove after clock settings is refactored to use OptionItemAdapter -->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
- <FrameLayout
- android:id="@+id/icon_container"
- android:layout_width="@dimen/option_item_size"
- android:layout_height="@dimen/option_item_size"
- android:importantForAccessibility="yes">
-
- <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" />
-
- <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>
-
- <TextView
- android:id="@+id/option_title"
- android:layout_width="@dimen/option_tile_width"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/option_bottom_margin"
- android:textColor="@color/text_color_primary"
- android:visibility="gone"
- android:gravity="center" />
-</LinearLayout>
diff --git a/src/com/android/customization/picker/color/ui/adapter/ColorOptionAdapter.kt b/src/com/android/customization/picker/color/ui/adapter/ColorOptionAdapter.kt
deleted file mode 100644
index 7aa390d..0000000
--- a/src/com/android/customization/picker/color/ui/adapter/ColorOptionAdapter.kt
+++ /dev/null
@@ -1,103 +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.ui.adapter
-
-import android.graphics.BlendMode
-import android.graphics.BlendModeColorFilter
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
-import androidx.core.view.isVisible
-import androidx.recyclerview.widget.RecyclerView
-import com.android.customization.picker.color.ui.viewmodel.ColorOptionViewModel
-import com.android.wallpaper.R
-
-/**
- * Adapts between color option items and views.
- *
- * TODO (b/272109171): Remove after clock settings is refactored to use OptionItemAdapter
- */
-class ColorOptionAdapter : RecyclerView.Adapter<ColorOptionAdapter.ViewHolder>() {
-
- private val items = mutableListOf<ColorOptionViewModel>()
- private var isTitleVisible = false
-
- fun setItems(items: List<ColorOptionViewModel>) {
- this.items.clear()
- this.items.addAll(items)
- isTitleVisible = items.any { item -> item.title != null }
- notifyDataSetChanged()
- }
-
- class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
- val borderView: View = itemView.requireViewById(R.id.selection_border)
- val backgroundView: View = itemView.requireViewById(R.id.background)
- val color0View: ImageView = itemView.requireViewById(R.id.color_preview_0)
- val color1View: ImageView = itemView.requireViewById(R.id.color_preview_1)
- val color2View: ImageView = itemView.requireViewById(R.id.color_preview_2)
- val color3View: ImageView = itemView.requireViewById(R.id.color_preview_3)
- val optionTitleView: TextView = itemView.requireViewById(R.id.option_title)
- }
-
- override fun getItemCount(): Int {
- return items.size
- }
-
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
- return ViewHolder(
- LayoutInflater.from(parent.context)
- .inflate(
- R.layout.color_option_with_background,
- parent,
- false,
- )
- )
- }
-
- override fun onBindViewHolder(holder: ViewHolder, position: Int) {
- val item = items[position]
-
- holder.itemView.setOnClickListener(
- if (item.onClick != null) {
- View.OnClickListener { item.onClick.invoke() }
- } else {
- null
- }
- )
- if (item.isSelected) {
- holder.borderView.alpha = 1f
- holder.borderView.scaleX = 1f
- holder.borderView.scaleY = 1f
- holder.backgroundView.scaleX = 0.86f
- holder.backgroundView.scaleY = 0.86f
- } else {
- holder.borderView.alpha = 0f
- holder.backgroundView.scaleX = 1f
- holder.backgroundView.scaleY = 1f
- }
- holder.color0View.drawable.colorFilter = BlendModeColorFilter(item.color0, BlendMode.SRC)
- holder.color1View.drawable.colorFilter = BlendModeColorFilter(item.color1, BlendMode.SRC)
- holder.color2View.drawable.colorFilter = BlendModeColorFilter(item.color2, BlendMode.SRC)
- holder.color3View.drawable.colorFilter = BlendModeColorFilter(item.color3, BlendMode.SRC)
- holder.itemView.contentDescription = item.contentDescription
- holder.optionTitleView.isVisible = isTitleVisible
- holder.optionTitleView.text = item.title
- }
-}