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 17 package com.google.android.wallpaper.weathereffects.provider 18 19 import android.content.ContentResolver.SCHEME_CONTENT 20 import android.net.Uri 21 22 object WallpaperInfoContract { 23 24 /** Returns a [Uri.Builder] for updating a wallpaper. This will produce a uri starts with 25 * content://com.google.android.wallpaper.weathereffects.effectprovider/update_wallpaper. 26 * Append parameters such as foreground and background images, etc. 27 * 28 * All the parameters are optional. 29 * <ul> 30 * <li>For the initial generation, foreground and background images must be provided. 31 * <li>When foreground and background images are already provided, but no weather type is 32 * provided, it clears the existing weather effect (foreground & background images composed). 33 * </ul> 34 * 35 * Example uri: content://com.google.android.wallpaper.weathereffects.effectprovider/ 36 * update_wallpaper?foreground_texture=<path_to_foreground_texture>&background_texture= 37 * <path_to_background_texture> 38 */ getUpdateWallpaperUrinull39 fun getUpdateWallpaperUri(): Uri.Builder { 40 return Uri.Builder().scheme(SCHEME_CONTENT) 41 .authority(AUTHORITY) 42 .appendPath(WeatherEffectsContentProvider.UPDATE_WALLPAPER) 43 } 44 45 enum class WeatherEffect(val value: String) { 46 RAIN("rain"), 47 FOG("fog"), 48 SNOW("snow"), 49 SUN("SUN"); 50 51 companion object { 52 53 /** 54 * Converts the String value to an enum. 55 * 56 * @param value a String representing the [value] of an enum. Note that this is the 57 * value that we created [value] and it does not refer to the [valueOf] value, which 58 * corresponds to the [name]. i.e. 59 * - RAIN("rain"): 60 * -> [valueOf] needs [name] ("RAIN"). 61 * -> [fromStringValue] needs [value] ("rain"). 62 * 63 * @return the associated [WeatherEffect]. 64 */ fromStringValuenull65 fun fromStringValue(value: String?): WeatherEffect? { 66 return when (value) { 67 RAIN.value -> RAIN 68 FOG.value -> FOG 69 SNOW.value -> SNOW 70 SUN.value -> SUN 71 else -> null 72 } 73 } 74 } 75 } 76 77 const val AUTHORITY = "com.google.android.wallpaper.weathereffects.effectprovider" 78 const val FOREGROUND_TEXTURE_PARAM = "foreground_texture" 79 const val BACKGROUND_TEXTURE_PARAM = "background_texture" 80 const val WEATHER_EFFECT_PARAM = "weather_effect" 81 82 object WallpaperGenerationData { 83 84 const val FOREGROUND_TEXTURE = "foreground_texture" 85 const val BACKGROUND_TEXTURE = "background_texture" 86 const val WEATHER_EFFECT = "weather_effect" 87 88 val DEFAULT_PROJECTION = arrayOf( 89 FOREGROUND_TEXTURE, BACKGROUND_TEXTURE, WEATHER_EFFECT 90 ) 91 } 92 } 93