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 50 companion object { 51 52 /** 53 * Converts the String value to an enum. 54 * 55 * @param value a String representing the [value] of an enum. Note that this is the 56 * value that we created [value] and it does not refer to the [valueOf] value, which 57 * corresponds to the [name]. i.e. 58 * - RAIN("rain"): 59 * -> [valueOf] needs [name] ("RAIN"). 60 * -> [fromStringValue] needs [value] ("rain"). 61 * 62 * @return the associated [WeatherEffect]. 63 */ fromStringValuenull64 fun fromStringValue(value: String?): WeatherEffect? { 65 return when (value) { 66 RAIN.value -> RAIN 67 FOG.value -> FOG 68 SNOW.value -> SNOW 69 else -> null 70 } 71 } 72 } 73 } 74 75 const val AUTHORITY = "com.google.android.wallpaper.weathereffects.effectprovider" 76 const val FOREGROUND_TEXTURE_PARAM = "foreground_texture" 77 const val BACKGROUND_TEXTURE_PARAM = "background_texture" 78 const val WEATHER_EFFECT_PARAM = "weather_effect" 79 80 object WallpaperGenerationData { 81 82 const val FOREGROUND_TEXTURE = "foreground_texture" 83 const val BACKGROUND_TEXTURE = "background_texture" 84 const val WEATHER_EFFECT = "weather_effect" 85 86 val DEFAULT_PROJECTION = arrayOf( 87 FOREGROUND_TEXTURE, BACKGROUND_TEXTURE, WEATHER_EFFECT 88 ) 89 } 90 } 91