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

Commit cd7f8cde authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Add missing Beta tag to themed icons toggle

Bug: 418056815
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: visual, see bug
Change-Id: I67d8a3c85a9d987bf88284beb9fe8b0322e72d18
parent 492c1e06
Loading
Loading
Loading
Loading
+40 −13
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/floating_sheet_content_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
@@ -57,27 +58,53 @@
            android:clipChildren="false" />
    </FrameLayout>


    <LinearLayout
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/themed_icon_toggle_entry"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:gravity="center_vertical"
        android:layout_marginHorizontal="@dimen/floating_sheet_content_horizontal_padding"
        android:orientation="horizontal">
        android:paddingVertical="@dimen/floating_sheet_content_vertical_padding"
        android:clipToPadding="false"
        android:clipChildren="false">

        <TextView
            style="@style/CustomizationOptionEntryTitleTextStyle"
            android:id="@+id/themed_icon_toggle_title"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/themed_icon_title"
            android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
            android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
            android:importantForAccessibility="no"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/themed_icon_toggle"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintBottom_toTopOf="@+id/themed_icon_beta_title" />

        <TextView
            style="@style/BetaTagTextStyle"
            android:id="@+id/themed_icon_beta_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
            android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
            android:importantForAccessibility="no"
            android:textColor="@color/text_color_on_accent"
            android:text="@string/beta_title"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/themed_icon_toggle_title"
            app:layout_constraintBottom_toBottomOf="parent" />

        <com.google.android.material.materialswitch.MaterialSwitch
            style="@style/SettingslibSwitchStyle.Expressive"
            android:id="@+id/themed_icon_toggle"
            android:layout_width="match_parent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:focusable="true"
            android:layout_marginEnd="@dimen/floating_sheet_content_horizontal_padding"
            android:contentDescription="@string/themed_icon_title"
            android:clickable="true"
            android:minHeight="0dp"
            android:text="@string/themed_icon_title"
            android:textAppearance="@style/SectionTitleTextStyle"
            app:layout_constraintTop_toTopOf="@+id/themed_icon_toggle_title"
            app:layout_constraintBottom_toBottomOf="@+id/themed_icon_beta_title"
            app:layout_constraintEnd_toEndOf="parent"
            android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
    </LinearLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -376,6 +376,9 @@
    <!-- Title of a section of the customization where the user can select color override for icon. [CHAR LIMIT=30] -->
    <string name="themed_icon_title" msgid="4305612684940220645">Themed icons</string>

    <!-- Title of a section of the customization where the user can select color override for icon. [CHAR LIMIT=40] -->
    <string name="themed_icon_beta_title">Themed icons (beta)</string>

    <!-- Title of a section of the pack theme where the user enter the theme app. [CHAR LIMIT=30] -->
    <string name="pack_theme_title">Themes</string>

+56 −3
Original line number Diff line number Diff line
@@ -17,9 +17,11 @@
package com.android.wallpaper.customization.ui.binder

import android.content.Context
import android.content.res.ColorStateList
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
@@ -82,6 +84,8 @@ object AppIconFloatingSheetBinder {

        val themedIconsSwitch = view.requireViewById<MaterialSwitch>(R.id.themed_icon_toggle)
        val themedIconEntry = view.requireViewById<ViewGroup>(R.id.themed_icon_toggle_entry)
        val themedIconTitle = view.requireViewById<TextView>(R.id.themed_icon_toggle_title)
        val themedIconBetaLabel = view.requireViewById<TextView>(R.id.themed_icon_beta_title)

        lifecycleOwner.lifecycleScope.launch {
            lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
@@ -111,11 +115,21 @@ object AppIconFloatingSheetBinder {
                }

                launch {
                    var binding: SwitchColorBinder.Binding? = null
                    var switchBinding: SwitchColorBinder.Binding? = null
                    var titleBinding: ColorUpdateBinder.Binding? = null
                    viewModel.previewingIsThemeIconEnabled.collect {
                        themedIconsSwitch.isChecked = it
                        binding?.destroy()
                        binding =
                        titleBinding?.destroy()
                        titleBinding =
                            bindTitleColor(
                                themedIconTitle,
                                themedIconBetaLabel,
                                colorUpdateViewModel,
                                isFloatingSheetActive,
                                lifecycleOwner,
                            )
                        switchBinding?.destroy()
                        switchBinding =
                            SwitchColorBinder.bind(
                                switch = themedIconsSwitch,
                                isChecked = it,
@@ -137,6 +151,45 @@ object AppIconFloatingSheetBinder {
        }
    }

    private fun bindTitleColor(
        title: TextView,
        betaLabel: TextView,
        colorUpdateViewModel: ColorUpdateViewModel,
        shouldAnimateColor: () -> Boolean,
        lifecycleOwner: LifecycleOwner,
    ): ColorUpdateBinder.Binding {
        val titleBinding =
            ColorUpdateBinder.bind(
                setColor = { color -> title.setTextColor(color) },
                color = colorUpdateViewModel.colorOnSurface,
                shouldAnimate = shouldAnimateColor,
                lifecycleOwner = lifecycleOwner,
            )
        val labelBinding =
            ColorUpdateBinder.bind(
                setColor = { color -> betaLabel.setTextColor(color) },
                color = colorUpdateViewModel.colorOnPrimaryContainer,
                shouldAnimate = shouldAnimateColor,
                lifecycleOwner = lifecycleOwner,
            )
        val labelBackgroundBinding =
            ColorUpdateBinder.bind(
                setColor = { color ->
                    betaLabel.background.setTintList(ColorStateList.valueOf(color))
                },
                color = colorUpdateViewModel.colorPrimaryContainer,
                shouldAnimate = shouldAnimateColor,
                lifecycleOwner = lifecycleOwner,
            )
        return object : ColorUpdateBinder.Binding {
            override fun destroy() {
                titleBinding.destroy()
                labelBinding.destroy()
                labelBackgroundBinding.destroy()
            }
        }
    }

    private fun createShapeOptionItemAdapter(
        colorUpdateViewModel: ColorUpdateViewModel,
        shouldAnimateColor: () -> Boolean,