• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.launcher3.icons
18 
19 import android.content.Context
20 import android.graphics.drawable.AdaptiveIconDrawable
21 import com.android.launcher3.icons.cache.CachingLogic
22 import com.android.launcher3.util.ComponentKey
23 
24 /** Represents a themed version of a BitmapInfo */
25 interface ThemedBitmap {
26 
27     /** Creates a new Drawable */
newDrawablenull28     fun newDrawable(info: BitmapInfo, context: Context): FastBitmapDrawable
29 
30     fun serialize(): ByteArray
31 }
32 
33 interface IconThemeController {
34 
35     val themeID: String
36 
37     fun createThemedBitmap(
38         icon: AdaptiveIconDrawable,
39         info: BitmapInfo,
40         factory: BaseIconFactory,
41         sourceHint: SourceHint? = null,
42     ): ThemedBitmap?
43 
44     fun decode(
45         data: ByteArray,
46         info: BitmapInfo,
47         factory: BaseIconFactory,
48         sourceHint: SourceHint,
49     ): ThemedBitmap?
50 
51     fun createThemedAdaptiveIcon(
52         context: Context,
53         originalIcon: AdaptiveIconDrawable,
54         info: BitmapInfo?,
55     ): AdaptiveIconDrawable?
56 }
57 
58 data class SourceHint(
59     val key: ComponentKey,
60     val logic: CachingLogic<*>,
61     val freshnessId: String? = null,
62     val isFileDrawable: Boolean = false,
63 )
64