• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 package com.android.wallpaper.picker.customization.data.content
19 
20 import android.graphics.Bitmap
21 import com.android.wallpaper.picker.customization.shared.model.WallpaperDestination
22 import com.android.wallpaper.picker.customization.shared.model.WallpaperModel
23 import kotlinx.coroutines.flow.Flow
24 
25 /** Defines interface for classes that can interact with the Wallpaper API. */
26 interface WallpaperClient {
27 
28     /** Lists the most recent wallpapers. The first one is the most recent (current) wallpaper. */
recentWallpapersnull29     fun recentWallpapers(
30         destination: WallpaperDestination,
31         limit: Int,
32     ): Flow<List<WallpaperModel>>
33 
34     /**
35      * Asynchronously sets the wallpaper to the one with the given ID.
36      *
37      * @param destination The screen to set the wallpaper on.
38      * @param wallpaperId The ID of the wallpaper to set.
39      * @param onDone A callback to invoke when setting is done.
40      */
41     suspend fun setWallpaper(
42         destination: WallpaperDestination,
43         wallpaperId: String,
44         onDone: () -> Unit
45     )
46 
47     /** Returns a thumbnail for the wallpaper with the given ID. */
48     suspend fun loadThumbnail(wallpaperId: String): Bitmap?
49 
50     /** Returns whether the recent wallpapers provider is available. */
51     fun areRecentsAvailable(): Boolean
52 }
53