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.google.android.torus.utils.wallpaper 17 18 import android.app.WallpaperColors 19 import android.graphics.Color 20 import android.os.Build 21 22 /** Creates some utils for wallpapers. */ 23 object WallpaperUtils { 24 /** 25 * Returns a [WallpaperColors] with the color provided and launcher using black text 26 * if [darkText] is true. 27 * 28 * @param primaryColor Primary color. 29 * @param secondaryColor Secondary color. 30 * @param tertiaryColor Tertiary color. 31 * @param darkText If the launcher should use dark text (It won't work for SDK < 31 (S)). 32 * 33 * @return the wallpaper color with the color hints (if possible). 34 */ 35 @JvmStatic getWallpaperColorsnull36 fun getWallpaperColors( 37 primaryColor: Color, 38 secondaryColor: Color, 39 tertiaryColor: Color, 40 darkText: Boolean = false 41 ): WallpaperColors { 42 return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && darkText) { 43 WallpaperColors( 44 primaryColor, 45 secondaryColor, 46 tertiaryColor, 47 WallpaperColors.HINT_SUPPORTS_DARK_TEXT or WallpaperColors.HINT_SUPPORTS_DARK_THEME 48 ) 49 } else { 50 WallpaperColors( 51 primaryColor, 52 secondaryColor, 53 tertiaryColor, 54 ) 55 } 56 } 57 } 58