• 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 package com.android.intentresolver.icons
18 
19 import android.content.pm.ResolveInfo
20 import android.graphics.drawable.Drawable
21 import android.os.UserHandle
22 import com.android.intentresolver.TargetPresentationGetter
23 import com.android.intentresolver.chooser.DisplayResolveInfo
24 import com.android.intentresolver.chooser.SelectableTargetInfo
25 import java.util.function.Consumer
26 
27 /** A target data loader contract. Added to support testing. */
28 abstract class TargetDataLoader {
29     /** Load an app target icon */
loadAppTargetIconnull30     abstract fun loadAppTargetIcon(
31         info: DisplayResolveInfo,
32         userHandle: UserHandle,
33         callback: Consumer<Drawable>,
34     )
35 
36     /** Load a shortcut icon */
37     abstract fun loadDirectShareIcon(
38         info: SelectableTargetInfo,
39         userHandle: UserHandle,
40         callback: Consumer<Drawable>,
41     )
42 
43     /** Load target label */
44     abstract fun loadLabel(info: DisplayResolveInfo, callback: Consumer<Array<CharSequence?>>)
45 
46     /** Create a presentation getter to be used with a [DisplayResolveInfo] */
47     // TODO: get rid of DisplayResolveInfo's dependency on the presentation getter and remove this
48     //  method.
49     abstract fun createPresentationGetter(info: ResolveInfo): TargetPresentationGetter
50 }
51