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

Commit 7f654f40 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Hide App Icons entry when shape and themed icons not available

Show only Themed Icons or only Shapes if only one is available.
Also added more logging when reading options for debugging in the future

Bug: 411007745
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: added unit test for summary
Test: visually verified entry doesn't show up
Change-Id: I5fcc606c60a6918f7254c0c594bfbff22a6acdd5
parent 77f3fbee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@


    <LinearLayout
        android:id="@+id/themed_icon_toggle_entry"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
+3 −3
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ constructor(
            }
        }

    override suspend fun getShapeOptions(): List<ShapeOptionModel>? =
    override suspend fun getShapeOptions(): List<ShapeOptionModel> =
        withContext(bgDispatcher) {
            if (previewUtils.supportsPreview()) {
                context.contentResolver
@@ -142,9 +142,9 @@ constructor(
                                }
                                list
                            }
                    }
                    } ?: emptyList()
            } else {
                null
                emptyList()
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ interface ShapeGridManager {
     */
    suspend fun getGridOptions(): List<GridOptionModel>

    suspend fun getShapeOptions(): List<ShapeOptionModel>?
    suspend fun getShapeOptions(): List<ShapeOptionModel>

    fun applyGridOption(gridKey: String)

+12 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
package com.android.customization.picker.grid.data.repository

import android.content.Context
import android.content.res.Resources
import com.android.customization.model.ResourceConstants
import com.android.customization.model.grid.ShapeGridManager
import com.android.customization.model.grid.ShapeOptionModel
import com.android.wallpaper.R
@@ -53,6 +55,16 @@ constructor(

    private val _shapeOptions = MutableStateFlow<List<ShapeOptionModel>?>(null)

    val defaultShapePath =
        context.resources.getString(
            Resources.getSystem()
                .getIdentifier(
                    ResourceConstants.CONFIG_ICON_MASK,
                    "string",
                    ResourceConstants.ANDROID_PACKAGE,
                )
        )

    init {
        bgScope.launch { _shapeOptions.value = shapeGridManager.getShapeOptions() }
    }
+7 −1
Original line number Diff line number Diff line
@@ -17,11 +17,13 @@

package com.android.customization.picker.grid.domain.interactor

import com.android.customization.model.grid.ShapeOptionModel
import com.android.customization.picker.grid.data.repository.ShapeRepository
import com.android.customization.picker.themedicon.data.repository.ThemedIconRepository
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

@Singleton
class AppIconInteractor
@@ -33,7 +35,11 @@ constructor(

    val shapeOptions = shapeRepository.shapeOptions

    val selectedShapeOption = shapeRepository.selectedShapeOption
    private val defaultShape =
        ShapeOptionModel("default", "", shapeRepository.defaultShapePath, true)

    val selectedShapeOption =
        shapeRepository.selectedShapeOption.map { shapeOption -> shapeOption ?: defaultShape }

    val isThemedIconAvailable: Flow<Boolean> = themedIconRepository.isAvailable

Loading