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

Commit 8ed12a0f authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12722466 from 28ef0109 to 25Q1-release

Change-Id: Ib116ed5c900d3c3dcdee7439270eca681267a697
parents 96230061 28ef0109
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2024 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:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/option_item_size"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:clipChildren="false">

    <FrameLayout
        android:layout_width="@dimen/option_item_size"
        android:layout_height="@dimen/option_item_size"
        android:clipChildren="false">

        <com.android.wallpaper.picker.option.ui.view.OptionItemBackground
            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/foreground"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_gravity="center" />

    </FrameLayout>

    <View
        android:layout_width="0dp"
        android:layout_height="8dp" />

    <TextView
        android:id="@id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/system_on_surface"
        android:singleLine="true"
        android:ellipsize="end"
        android:textSize="12sp"
        android:text="Placeholder for stable size calculation, please do not remove."
        tools:ignore="HardcodedText" />

</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@
    <dimen name="floating_sheet_tab_clock_font_toolbar_top_margin">16dp</dimen>
    <dimen name="floating_sheet_tab_clock_font_toolbar_bottom_margin">8dp</dimen>
    <dimen name="floating_sheet_list_item_horizontal_space">4dp</dimen>
    <dimen name="floating_sheet_grid_list_item_horizontal_space">10dp</dimen>
    <dimen name="floating_sheet_list_item_vertical_space">4dp</dimen>
    <dimen name="floating_sheet_clock_style_option_list_margin_bottom">8dp</dimen>
    <dimen name="floating_sheet_clock_style_option_width">80dp</dimen>
+11 −19
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.wallpaper.picker.customization.ui.view.FloatingToolbar
import com.android.wallpaper.picker.customization.ui.view.adapter.FloatingToolbarTabAdapter
import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewModel
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter2
import com.android.wallpaper.picker.option.ui.binder.OptionItemBinder
import java.lang.ref.WeakReference
import kotlinx.coroutines.CoroutineDispatcher
@@ -97,7 +98,7 @@ object ShapeGridFloatingSheetBinder {

        val gridContent = view.requireViewById<View>(R.id.app_grid_container)
        val gridOptionListAdapter =
            createGridOptionItemAdapter(view.context, lifecycleOwner, backgroundDispatcher)
            createGridOptionItemAdapter(lifecycleOwner, backgroundDispatcher)
        val gridOptionList =
            view.requireViewById<RecyclerView>(R.id.grid_options).also {
                it.initGridOptionList(view.context, gridOptionListAdapter)
@@ -243,8 +244,7 @@ object ShapeGridFloatingSheetBinder {
                        ),
                    itemHorizontalSpacePx =
                        context.resources.getDimensionPixelSize(
                            com.android.themepicker.R.dimen
                                .floating_sheet_list_item_horizontal_space
                            R.dimen.floating_sheet_list_item_horizontal_space
                        ),
                )
            )
@@ -253,30 +253,23 @@ object ShapeGridFloatingSheetBinder {
    }

    private fun createGridOptionItemAdapter(
        context: Context,
        lifecycleOwner: LifecycleOwner,
        backgroundDispatcher: CoroutineDispatcher,
    ): OptionItemAdapter<GridIconViewModel> =
        OptionItemAdapter(
            layoutResourceId = R.layout.grid_option,
    ): OptionItemAdapter2<GridIconViewModel> =
        OptionItemAdapter2(
            layoutResourceId = R.layout.grid_option2,
            lifecycleOwner = lifecycleOwner,
            backgroundDispatcher = backgroundDispatcher,
            foregroundTintSpec =
                OptionItemBinder.TintSpec(
                    selectedColor =
                        context.getColor(com.android.wallpaper.R.color.system_on_surface),
                    unselectedColor =
                        context.getColor(com.android.wallpaper.R.color.system_on_surface),
                ),
            bindIcon = { foregroundView: View, gridIcon: GridIconViewModel ->
                val imageView = foregroundView as? ImageView
            bindPayload = { view: View, gridIcon: GridIconViewModel ->
                val imageView = view.findViewById(R.id.foreground) as? ImageView
                imageView?.let { GridIconViewBinder.bind(imageView, gridIcon) }
                return@OptionItemAdapter2 null
            },
        )

    private fun RecyclerView.initGridOptionList(
        context: Context,
        adapter: OptionItemAdapter<GridIconViewModel>,
        adapter: OptionItemAdapter2<GridIconViewModel>,
    ) {
        apply {
            this.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
@@ -288,8 +281,7 @@ object ShapeGridFloatingSheetBinder {
                        ),
                    itemHorizontalSpacePx =
                        context.resources.getDimensionPixelSize(
                            com.android.themepicker.R.dimen
                                .floating_sheet_list_item_horizontal_space
                            R.dimen.floating_sheet_grid_list_item_horizontal_space
                        ),
                )
            )
+30 −11
Original line number Diff line number Diff line
@@ -22,16 +22,18 @@ import android.widget.Button
import android.widget.FrameLayout
import android.widget.Toolbar
import androidx.core.graphics.ColorUtils
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isInvisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.android.wallpaper.R
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
import com.android.wallpaper.customization.ui.viewmodel.ToolbarHeightsViewModel
import com.android.wallpaper.picker.customization.ui.binder.ColorUpdateBinder
import com.android.wallpaper.picker.customization.ui.binder.DefaultToolbarBinder
import com.android.wallpaper.picker.customization.ui.binder.ToolbarBinder
import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewModel
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationOptionsViewModel
import javax.inject.Inject
import javax.inject.Singleton
@@ -39,6 +41,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch

@Singleton
@@ -54,6 +57,7 @@ constructor(private val defaultToolbarBinder: DefaultToolbarBinder) : ToolbarBin
        toolbar: Toolbar,
        applyButton: Button,
        viewModel: CustomizationOptionsViewModel,
        colorUpdateViewModel: ColorUpdateViewModel,
        lifecycleOwner: LifecycleOwner,
        onNavBack: () -> Unit,
    ) {
@@ -62,6 +66,7 @@ constructor(private val defaultToolbarBinder: DefaultToolbarBinder) : ToolbarBin
            toolbar,
            applyButton,
            viewModel,
            colorUpdateViewModel,
            lifecycleOwner,
            onNavBack,
        )
@@ -111,13 +116,14 @@ constructor(private val defaultToolbarBinder: DefaultToolbarBinder) : ToolbarBin
            }
        )

        val applyButtonTextColorEnabled =
            applyButton.resources.getColor(R.color.system_on_primary, null)
        val applyButtonTextColorDisabled =
            ColorUtils.setAlphaComponent(
                applyButton.resources.getColor(R.color.system_on_surface, null),
                97,
            ) // 97 for 38% transparent
        ColorUpdateBinder.bind(
            setColor = { color ->
                DrawableCompat.setTint(DrawableCompat.wrap(applyButton.background), color)
            },
            color = colorUpdateViewModel.colorPrimary,
            shouldAnimate = { true },
            lifecycleOwner = lifecycleOwner,
        )

        lifecycleOwner.lifecycleScope.launch {
            lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
@@ -133,9 +139,22 @@ constructor(private val defaultToolbarBinder: DefaultToolbarBinder) : ToolbarBin
                    viewModel.isApplyButtonEnabled.collect {
                        applyButton.isEnabled = it
                        applyButton.background.alpha =
                            if (it) 255 else 31 // 255 for 100%, 31 for 12% transparent,
                        applyButton.setTextColor(
                            if (it) applyButtonTextColorEnabled else applyButtonTextColorDisabled
                            if (it) 255 else 31 // 255 for 100%, 31 for 12% transparent
                        ColorUpdateBinder.bind(
                            setColor = { color -> applyButton.setTextColor(color) },
                            color =
                                if (it) {
                                    colorUpdateViewModel.colorOnPrimary
                                } else {
                                    colorUpdateViewModel.colorOnSurface.map { color: Int ->
                                        ColorUtils.setAlphaComponent(
                                            color,
                                            97,
                                        ) // 97 for 38% transparent
                                    }
                                },
                            shouldAnimate = { true },
                            lifecycleOwner = lifecycleOwner,
                        )
                    }
                }
+4 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
import com.android.wallpaper.picker.common.text.ui.viewmodel.Text
import com.android.wallpaper.picker.customization.ui.viewmodel.FloatingToolbarTabViewModel
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel2
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -126,7 +127,7 @@ constructor(
            overridingGridOptionKey ?: selectedGridOption.key.value
        }

    val gridOptions: Flow<List<OptionItemViewModel<GridIconViewModel>>> =
    val gridOptions: Flow<List<OptionItemViewModel2<GridIconViewModel>>> =
        interactor.gridOptions
            .filterNotNull()
            .map { gridOptions -> gridOptions.map { toGridOptionItemViewModel(it) } }
@@ -184,7 +185,7 @@ constructor(

    private fun toGridOptionItemViewModel(
        option: GridOptionModel
    ): OptionItemViewModel<GridIconViewModel> {
    ): OptionItemViewModel2<GridIconViewModel> {
        val iconShapePath =
            context.resources.getString(
                Resources.getSystem()
@@ -203,7 +204,7 @@ constructor(
                    initialValue = false,
                )

        return OptionItemViewModel(
        return OptionItemViewModel2(
            key = MutableStateFlow(option.key),
            payload =
                GridIconViewModel(columns = option.cols, rows = option.rows, path = iconShapePath),
Loading