1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.customization.model.color 17 18 import android.R 19 import android.app.WallpaperColors 20 import android.content.Context 21 import com.android.systemui.monet.ColorScheme 22 23 /** A class to override colors in a [Context] with wallpaper colors. */ 24 class DefaultWallpaperColorResources(private val wallpaperColors: WallpaperColors) : 25 WallpaperColorResources() { 26 applynull27 override suspend fun apply(context: Context, callback: () -> Unit) { 28 val wallpaperColorScheme = ColorScheme(wallpaperColors, false) 29 with(wallpaperColorScheme) { 30 addOverlayColor(neutral1, R.color.system_neutral1_10) 31 addOverlayColor(neutral2, R.color.system_neutral2_10) 32 addOverlayColor(accent1, R.color.system_accent1_10) 33 addOverlayColor(accent2, R.color.system_accent2_10) 34 addOverlayColor(accent3, R.color.system_accent3_10) 35 } 36 applyToContext(context) 37 callback.invoke() 38 } 39 } 40