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.android.intentresolver.icons
18 
19 import android.graphics.drawable.Drawable
20 import android.os.UserHandle
21 import com.android.intentresolver.chooser.DisplayResolveInfo
22 import com.android.intentresolver.chooser.SelectableTargetInfo
23 import java.util.function.Consumer
24 
25 /** A target data loader contract. Added to support testing. */
26 abstract class TargetDataLoader {
27     /** Load an app target icon */
getOrLoadAppTargetIconnull28     abstract fun getOrLoadAppTargetIcon(
29         info: DisplayResolveInfo,
30         userHandle: UserHandle,
31         callback: Consumer<Drawable>,
32     ): Drawable?
33 
34     /** Load a shortcut icon */
35     abstract fun getOrLoadDirectShareIcon(
36         info: SelectableTargetInfo,
37         userHandle: UserHandle,
38         callback: Consumer<Drawable>,
39     ): Drawable?
40 
41     /** Load target label */
42     abstract fun loadLabel(info: DisplayResolveInfo, callback: Consumer<LabelInfo>)
43 
44     /** Loads DisplayResolveInfo's display label synchronously, if needed */
45     abstract fun getOrLoadLabel(info: DisplayResolveInfo)
46 }
47