xref: /aosp_15_r20/frameworks/base/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/Annotations.kt (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
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.settingslib.metadata
18 
19 import kotlin.reflect.KClass
20 
21 /**
22  * Annotation to provide preference screen.
23  *
24  * The annotated class must satisfy either condition:
25  * - the primary constructor has no parameter
26  * - the primary constructor has a single [android.content.Context] parameter
27  * - it is a Kotlin object class
28  *
29  * @param overlay if specified, current annotated screen will overlay the given screen
30  */
31 @Retention(AnnotationRetention.SOURCE)
32 @Target(AnnotationTarget.CLASS)
33 @MustBeDocumented
34 annotation class ProvidePreferenceScreen(
35     val overlay: KClass<out PreferenceScreenMetadata> = PreferenceScreenMetadata::class,
36 )
37 
38 /**
39  * Provides options for [ProvidePreferenceScreen] annotation processor.
40  *
41  * @param codegenCollector generated collector class (format: "pkg/class/method"), an empty string
42  *   means do not generate code
43  */
44 @Retention(AnnotationRetention.SOURCE)
45 @Target(AnnotationTarget.CLASS)
46 @MustBeDocumented
47 annotation class ProvidePreferenceScreenOptions(
48     val codegenCollector: String = "com.android.settingslib.metadata/PreferenceScreenCollector/get",
49 )
50