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

Commit 364b1e36 authored by George Lin's avatar George Lin
Browse files

Shortcut option entry

Make the entry observe summary updates and change accordingly

Test: Manually tested. See bug.
Bug: 350718583
Flag: com.android.wallpaper.new_picker_ui_flag
Change-Id: Idb3b52b9aa8a7fc0ec6434cdfed3328f7788149d
parent a09dbca9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,6 +16,6 @@

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/picker_section_icon_background" />
    <solid android:color="@color/system_surface_container" />
    <corners android:radius="18dp" />
</shape>
 No newline at end of file
+21 −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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <size
        android:width="4dp"
        android:height="0dp" />
</shape>
+6 −6
Original line number Diff line number Diff line
@@ -56,8 +56,8 @@
        android:layout_height="@dimen/customization_option_entry_icon_size"
        android:orientation="horizontal"
        android:background="@drawable/customization_option_entry_icon_background"
        android:divider="@drawable/horizontal_divider_14dp"
        android:layout_gravity="center"
        android:gravity="center"
        android:divider="@drawable/horizontal_divider_4dp"
        android:showDividers="middle"
        android:importantForAccessibility="noHideDescendants"
        app:layout_constraintEnd_toEndOf="parent"
@@ -66,15 +66,15 @@

        <ImageView
            android:id="@+id/option_entry_keyguard_quick_affordance_icon_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_width="@dimen/customization_option_entry_shortcut_icon_size"
            android:layout_height="@dimen/customization_option_entry_shortcut_icon_size"
            android:visibility="gone"
            android:tint="@color/system_on_surface" />

        <ImageView
            android:id="@+id/option_entry_keyguard_quick_affordance_icon_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_width="@dimen/customization_option_entry_shortcut_icon_size"
            android:layout_height="@dimen/customization_option_entry_shortcut_icon_size"
            android:visibility="gone"
            android:tint="@color/system_on_surface" />
    </LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -186,4 +186,5 @@
    <dimen name="floating_sheet_clock_size_icon_margin_bottom">8dp</dimen>
    <dimen name="floating_sheet_clock_style_option_size">82dp</dimen>
    <dimen name="floating_sheet_clock_style_thumbnail_margin">12dp</dimen>
    <dimen name="customization_option_entry_shortcut_icon_size">20dp</dimen>
</resources>
+51 −1
Original line number Diff line number Diff line
@@ -17,13 +17,19 @@
package com.android.wallpaper.customization.ui.binder

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.android.themepicker.R
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerHomeCustomizationOption
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
import com.android.wallpaper.picker.common.icon.ui.viewbinder.IconViewBinder
import com.android.wallpaper.picker.common.text.ui.viewbinder.TextViewBinder
import com.android.wallpaper.picker.customization.ui.binder.CustomizationOptionsBinder
import com.android.wallpaper.picker.customization.ui.binder.DefaultCustomizationOptionsBinder
import com.android.wallpaper.picker.customization.ui.util.CustomizationOptionUtil.CustomizationOption
@@ -59,16 +65,30 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
            lockScreenCustomizationOptionEntries
                .find { it.first == ThemePickerLockCustomizationOption.CLOCK }
                ?.second

        val optionShortcut =
            lockScreenCustomizationOptionEntries
                .find { it.first == ThemePickerLockCustomizationOption.SHORTCUTS }
                ?.second
        val optionShortcutDescription =
            optionShortcut?.findViewById<TextView>(
                R.id.option_entry_keyguard_quick_affordance_description
            )
        val optionShortcutIcon1 =
            optionShortcut?.findViewById<ImageView>(
                R.id.option_entry_keyguard_quick_affordance_icon_1
            )
        val optionShortcutIcon2 =
            optionShortcut?.findViewById<ImageView>(
                R.id.option_entry_keyguard_quick_affordance_icon_2
            )

        val optionColors =
            homeScreenCustomizationOptionEntries
                .find { it.first == ThemePickerHomeCustomizationOption.COLORS }
                ?.second
        viewModel as ThemePickerCustomizationOptionsViewModel

        viewModel as ThemePickerCustomizationOptionsViewModel
        lifecycleOwner.lifecycleScope.launch {
            lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch {
@@ -83,6 +103,36 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
                    }
                }

                launch {
                    viewModel.keyguardQuickAffordanceSummery.collect { summary ->
                        optionShortcutDescription?.let {
                            TextViewBinder.bind(
                                view = it,
                                viewModel = summary.description,
                            )
                        }
                        summary.icon1?.let { icon ->
                            optionShortcutIcon1?.let {
                                IconViewBinder.bind(
                                    view = it,
                                    viewModel = icon,
                                )
                            }
                        }
                        optionShortcutIcon1?.isVisible = summary.icon1 != null

                        summary.icon2?.let { icon ->
                            optionShortcutIcon2?.let {
                                IconViewBinder.bind(
                                    view = it,
                                    viewModel = icon,
                                )
                            }
                        }
                        optionShortcutIcon2?.isVisible = summary.icon2 != null
                    }
                }

                launch {
                    viewModel.onCustomizeColorsClicked.collect {
                        optionColors?.setOnClickListener { _ -> it?.invoke() }
Loading