Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0966662 authored by Catherine Liang's avatar Catherine Liang
Browse files

System Colors picker selection animation (1/2)

Added selection animation to system colors by adapting color picker to
use option item framework. Adjusted icon type used by option item
framework to accomdate for color icons made up of multiple images.
Animation on optimistic update can occasionally lead to animation being
cut off due to restart, working with designers to resolve in follow-up
CL

Bug: 270188654
Test: existing view-model and interactor tests updated for field type
changes, and still pass without logic changes. Manually verified picker
is unchanged and funactional with revamped UI flag turned off. Manually
verified animations, recording - https://drive.google.com/file/d/1BGFf9gyYMBKS9t8uLD1eQB4unb6Dv_z3/view?usp=sharing&resourcekey=0-IZFfkwrM9nmcgsD6RyW3lA

Change-Id: I1e42106bb289c1d53eb63cd1b2288c4757564a73
parent eea14d36
Loading
Loading
Loading
Loading
+90 −0
Original line number Diff line number Diff line
<?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 -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:clipChildren="false">
    <FrameLayout
        android:id="@+id/icon_container"
        android:layout_width="@dimen/option_tile_width"
        android:layout_height="@dimen/option_tile_width"
        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="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="@dimen/color_seed_chip_margin"
                android:layout_marginBottom="@dimen/color_seed_chip_margin"
                android:src="@drawable/color_chip_seed_filled0"
                android:importantForAccessibility="no"/>

            <ImageView
                android:id="@+id/color_preview_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/color_seed_chip_margin"
                android:layout_marginBottom="@dimen/color_seed_chip_margin"
                android:src="@drawable/color_chip_seed_filled2"
                android:importantForAccessibility="no"/>

            <ImageView
                android:id="@+id/color_preview_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="@dimen/color_seed_chip_margin"
                android:layout_marginTop="@dimen/color_seed_chip_margin"
                android:src="@drawable/color_chip_seed_filled1"
                android:importantForAccessibility="no"/>

            <ImageView
                android:id="@+id/color_preview_3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/color_seed_chip_margin"
                android:layout_marginTop="@dimen/color_seed_chip_margin"
                android:src="@drawable/color_chip_seed_filled3"
                android:importantForAccessibility="no" />
        </FrameLayout>
    </FrameLayout>
</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
     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"
+7 −4
Original line number Diff line number Diff line
@@ -60,7 +60,8 @@
        android:layout_marginHorizontal="24dp"
        android:layout_marginBottom="28dp"
        android:background="@drawable/picker_fragment_background"
        android:paddingTop="22dp">
        android:paddingTop="22dp"
        android:clipChildren="false">

        <FrameLayout
            android:layout_width="match_parent"
@@ -97,14 +98,16 @@

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            android:layout_height="wrap_content"
            android:clipChildren="false">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/color_options"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:paddingHorizontal="16dp" />
                android:paddingHorizontal="16dp"
                android:clipChildren="false" />

            <!--
            This is just an invisible placeholder put in place so that the parent keeps its height
@@ -116,7 +119,7 @@
            It's critical for any TextViews inside the included layout to have text.
            -->
            <include
                layout="@layout/color_option_with_background"
                layout="@layout/color_option_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="invisible" />
+6 −3
Original line number Diff line number Diff line
@@ -110,9 +110,12 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> {
        if (mStyle != other.getStyle()) {
            return false;
        }
        if (mIsDefault) {
            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages())
                    || EMPTY_JSON.equals(other.getSerializedPackages());
        String thisSerializedPackages = getSerializedPackages();
        if (mIsDefault || TextUtils.isEmpty(thisSerializedPackages)
                || EMPTY_JSON.equals(thisSerializedPackages)) {
            String otherSerializedPackages = other.getSerializedPackages();
            return other.isDefault() || TextUtils.isEmpty(otherSerializedPackages)
                    || EMPTY_JSON.equals(otherSerializedPackages);
        }
        // Map#equals ensures keys and values are compared.
        return mPackagesByCategory.equals(other.mPackagesByCategory);
+8 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package com.android.customization.model.grid.ui.binder

import android.view.View
import android.widget.ImageView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
@@ -27,6 +28,8 @@ import androidx.recyclerview.widget.RecyclerView
import com.android.customization.model.grid.ui.viewmodel.GridScreenViewModel
import com.android.customization.picker.common.ui.view.ItemSpacing
import com.android.wallpaper.R
import com.android.wallpaper.picker.common.icon.ui.viewbinder.IconViewBinder
import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import com.android.wallpaper.picker.option.ui.binder.OptionItemBinder
import kotlinx.coroutines.CoroutineDispatcher
@@ -57,7 +60,11 @@ object GridScreenBinder {
                    OptionItemBinder.TintSpec(
                        selectedColor = view.context.getColor(R.color.text_color_primary),
                        unselectedColor = view.context.getColor(R.color.text_color_secondary),
                    )
                    ),
                bindIcon = { foregroundView: View, gridIcon: Icon ->
                    val imageView = foregroundView as? ImageView
                    imageView?.let { IconViewBinder.bind(imageView, gridIcon) }
                }
            )
        optionView.adapter = adapter

Loading