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

Commit b75c4eb1 authored by George Lin's avatar George Lin
Browse files

Use grid icon ID passed from the launcher

Use the icon resources from the launcher app

Test: Manually tested. See bug.
Fixes: 393921872
Bug: 348664593
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I6119e54594e6b7be1732bd48695df7ec7a299bff
parent 7df1fc5c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.customization.model.grid

import android.content.ContentValues
import android.content.Context
import android.graphics.drawable.Drawable
import androidx.core.content.res.ResourcesCompat
import com.android.wallpaper.R
import com.android.wallpaper.picker.di.modules.BackgroundDispatcher
import com.android.wallpaper.util.PreviewUtils
@@ -71,6 +73,10 @@ constructor(
                                                    .toBoolean(),
                                            rows = rows,
                                            cols = cols,
                                            iconId =
                                                cursor.getInt(
                                                    cursor.getColumnIndex(KEY_GRID_ICON_ID)
                                                ),
                                        )
                                    )
                                }
@@ -85,6 +91,7 @@ constructor(
                                }
                                list
                            }
                            .sortedByDescending { it.rows * it.cols }
                    }
            } else {
                null
@@ -149,6 +156,14 @@ constructor(
        )
    }

    override fun getGridOptionDrawble(iconId: Int): Drawable? {
        return ResourcesCompat.getDrawable(
            context.packageManager.getResourcesForApplication(APP_RESOURCES_PACKAGE_NAME),
            iconId,
            /* theme = */ null,
        )
    }

    companion object {
        const val SHAPE_OPTIONS: String = "shape_options"
        const val GRID_OPTIONS: String = "list_options"
@@ -162,5 +177,8 @@ constructor(
        const val COL_COLS: String = "cols"
        const val COL_IS_DEFAULT: String = "is_default"
        const val COL_PATH: String = "path"
        const val KEY_GRID_ICON_ID: String = "grid_icon_id"
        private const val APP_RESOURCES_PACKAGE_NAME: String =
            "com.google.android.apps.nexuslauncher"
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@ data class GridOptionModel(
    val isCurrent: Boolean,
    val rows: Int,
    val cols: Int,
    val iconId: Int,
)
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.customization.model.grid

import android.graphics.drawable.Drawable

interface ShapeGridManager {

    suspend fun getGridOptions(): List<GridOptionModel>?
@@ -23,4 +25,6 @@ interface ShapeGridManager {
    suspend fun getShapeOptions(): List<ShapeOptionModel>?

    fun applyShapeGridOption(shapeKey: String, gridKey: String): Int

    fun getGridOptionDrawble(iconId: Int): Drawable?
}
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.customization.picker.grid.data.repository

import android.graphics.drawable.Drawable
import com.android.customization.model.grid.GridOptionModel
import com.android.customization.model.grid.ShapeGridManager
import com.android.customization.model.grid.ShapeOptionModel
@@ -69,4 +70,8 @@ constructor(
            _gridOptions.value = manager.getGridOptions()
            _shapeOptions.value = manager.getShapeOptions()
        }

    fun getGridOptionDrawable(iconId: Int): Drawable? {
        return manager.getGridOptionDrawble(iconId)
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

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

import android.graphics.drawable.Drawable
import com.android.customization.picker.grid.data.repository.ShapeGridRepository
import javax.inject.Inject
import javax.inject.Singleton
@@ -34,4 +35,6 @@ class ShapeGridInteractor @Inject constructor(private val repository: ShapeGridR

    suspend fun applySelectedOption(shapeKey: String, gridKey: String) =
        repository.applySelectedOption(shapeKey, gridKey)

    fun getGridOptionDrawable(iconId: Int): Drawable? = repository.getGridOptionDrawable(iconId)
}
Loading