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

Commit 7517ae46 authored by Catherine Liang's avatar Catherine Liang
Browse files

Create app icon entry point

Adjusted grid entry point title and created basic icon entry point,
currently without thumbnail or subtitle.

Flag: com.android.systemui.shared.new_customization_picker_ui
Bug: 402161932
Test: manually verified
Test: AppIconViewModelTest passes
Change-Id: Ibc94c18695a0c491f0d6408f9faa6811017b2a7e
parent 34acc650
Loading
Loading
Loading
Loading
+29 −12
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~ Copyright (C) 2025 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.
@@ -17,11 +17,10 @@
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingHorizontal="@dimen/customization_option_entry_horizontal_padding"
    android:paddingVertical="@dimen/customization_option_entry_vertical_padding_large"
    android:paddingVertical="@dimen/customization_option_entry_vertical_padding"
    android:clickable="true">

    <TextView
@@ -29,20 +28,38 @@
        style="@style/CustomizationOptionEntryTitleTextStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/themed_icon_title"
        android:text="@string/app_icons_title"
        android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/option_entry_switch"
        app:layout_constraintEnd_toStartOf="@+id/option_entry_icon_container"
        app:layout_constraintBottom_toTopOf="@+id/option_entry_description"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />
        app:layout_constraintVertical_chainStyle="packed" />

    <com.google.android.material.materialswitch.MaterialSwitch
        android:id="@+id/option_entry_switch"
        android:layout_width="wrap_content"
    <TextView
        android:id="@+id/option_entry_description"
        style="@style/CustomizationOptionEntrySubtitleTextStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:focusable="false"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/option_entry_icon_container"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/option_entry_title" />

    <FrameLayout
        android:id="@+id/option_entry_icon_container"
        android:layout_width="@dimen/customization_option_entry_icon_size"
        android:layout_height="@dimen/customization_option_entry_icon_size"
        android:padding="@dimen/customization_option_entry_icon_padding"
        android:background="@drawable/customization_option_entry_icon_background"
        app:layout_constraintEnd_toEndOf="parent"
        android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <ImageView
            android:id="@+id/option_entry_icon"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
        style="@style/CustomizationOptionEntryTitleTextStyle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="@string/shape_and_grid_title"
        android:text="@string/grid_layout"
        android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/option_entry_icon_container"
+21 −0
Original line number Diff line number Diff line
@@ -206,6 +206,9 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
            homeScreenCustomizationOptionEntries
                .first { it.first == ThemePickerHomeCustomizationOption.APP_ICONS }
                .second
        val optionAppIconsDescription: TextView =
            optionAppIcons.requireViewById(R.id.option_entry_description)
        val optionAppIconsIcon: ImageView = optionAppIcons.requireViewById(R.id.option_entry_icon)

        val optionShapeGrid: View =
            homeScreenCustomizationOptionEntries
@@ -291,6 +294,24 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
                    }
                }

                launch {
                    val appIconPickerViewModel = optionsViewModel.appIconPickerViewModel
                    combine(
                            appIconPickerViewModel.selectedShape,
                            appIconPickerViewModel.isThemedIconEnabled,
                            ::Pair,
                        )
                        .collect { (selectedShape, isThemedIconEnabled) ->
                            // TODO(b/402161932): create and display app icon preview
                            optionAppIcons
                                .requireViewById<View>(R.id.option_entry_icon_container)
                                .visibility = View.INVISIBLE
                            // TODO(b/402161932): show selected shape text when b/406486710 is fixed
                            // TODO(b/402161932): show selected theme text after content is decided
                            optionAppIconsDescription.visibility = View.GONE
                        }
                }

                launch {
                    optionsViewModel.onCustomizeShapeGridClicked.collect {
                        optionShapeGrid.setOnClickListener { _ -> it?.invoke() }
+7 −7
Original line number Diff line number Diff line
@@ -57,9 +57,9 @@ constructor(
    enum class ThemePickerHomeCustomizationOption : CustomizationOptionUtil.CustomizationOption {
        PACK_THEME,
        COLORS,
        COLOR_CONTRAST,
        APP_ICONS,
        GRID,
        COLOR_CONTRAST,
    }

    override fun getOptionEntries(
@@ -138,25 +138,25 @@ constructor(
                            )
                    )
                    add(
                        ThemePickerHomeCustomizationOption.APP_ICONS to
                        ThemePickerHomeCustomizationOption.COLOR_CONTRAST to
                            layoutInflater.inflate(
                                R.layout.customization_option_entry_themed_icons,
                                R.layout.customization_option_entry_color_contrast,
                                optionContainer,
                                false,
                            )
                    )
                    add(
                        ThemePickerHomeCustomizationOption.GRID to
                        ThemePickerHomeCustomizationOption.APP_ICONS to
                            layoutInflater.inflate(
                                R.layout.customization_option_entry_app_shape_grid,
                                R.layout.customization_option_entry_app_icons,
                                optionContainer,
                                false,
                            )
                    )
                    add(
                        ThemePickerHomeCustomizationOption.COLOR_CONTRAST to
                        ThemePickerHomeCustomizationOption.GRID to
                            layoutInflater.inflate(
                                R.layout.customization_option_entry_color_contrast,
                                R.layout.customization_option_entry_app_shape_grid,
                                optionContainer,
                                false,
                            )
+7 −8
Original line number Diff line number Diff line
@@ -45,17 +45,16 @@ constructor(interactor: AppIconInteractor, @Assisted private val viewModelScope:
    //// Shape

    // The currently-set system shape option
    val selectedShapeKey =
    val selectedShape =
        interactor.selectedShapeOption
            .filterNotNull()
            .map { it.key }
            .map { toShapeOptionItemViewModel(it) }
            .shareIn(scope = viewModelScope, started = SharingStarted.Lazily, replay = 1)
    private val overridingShapeKey = MutableStateFlow<String?>(null)
    // If the overriding key is null, use the currently-set system shape option
    val previewingShapeKey =
        combine(overridingShapeKey, selectedShapeKey) { overridingShapeOptionKey, selectedShapeKey
            ->
            overridingShapeOptionKey ?: selectedShapeKey
        combine(overridingShapeKey, selectedShape) { overridingShapeOptionKey, selectedShape ->
            overridingShapeOptionKey ?: selectedShape.key.value
        }

    val shapeOptions: Flow<List<OptionItemViewModel2<ShapeIconViewModel>>> =
@@ -96,16 +95,16 @@ constructor(interactor: AppIconInteractor, @Assisted private val viewModelScope:
    val onApply: Flow<(suspend () -> Unit)?> =
        combine(
            overridingShapeKey,
            selectedShapeKey,
            selectedShape,
            overridingIsThemedIconEnabled,
            isThemedIconEnabled,
        ) {
            overridingShapeKey,
            selectedShapeKey,
            selectedShape,
            overridingIsThemedIconEnabled,
            currentIsThemedIconEnabled ->
            val shapeNeedsUpdate =
                overridingShapeKey != null && overridingShapeKey != selectedShapeKey
                overridingShapeKey != null && overridingShapeKey != selectedShape.key.value
            val themedIconNeedsUpdate =
                overridingIsThemedIconEnabled != null &&
                    overridingIsThemedIconEnabled != currentIsThemedIconEnabled
Loading