Compare commits

...

8 Commits

25 changed files with 215 additions and 94 deletions

View File

@@ -18,7 +18,16 @@ Time zone of version release date: **UTC+8**
## hikage-core ## hikage-core
### 1.0.1 | 2025.05.06 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.2 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Migrated Java reflection related behaviors from [YukiReflection](https://github.com/HighCapable/YukiReflection) to [KavaRef](https://github.com/HighCapable/KavaRef)
- Adapted to Android 16 (API 36), fixed the `XmlBlock` crash issue on Android 16
- Optimized layout performance, removed unnecessary inline operations, added caching for reflection operations
- Added `final` parameter to `HikageView` and `HikageViewDeclaration` to support new features in `hikage-compiler`
- Added `SurfaceView` and `WebView` built-in components to `Widgets`
- Adjusted some components in `Widgets` to be `final`
### 1.0.1 | 2025.05.06 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- Fixed the issue where the KSP source code was not successfully released - Fixed the issue where the KSP source code was not successfully released
- Added states management feature - Added states management feature
@@ -29,19 +38,32 @@ Time zone of version release date: **UTC+8**
## hikage-compiler ## hikage-compiler
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Added support for the `final` parameter of `HikageView` and `HikageViewDeclaration`, please refer to the relevant usage in the documentation
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- The first version is submitted to Maven - The first version is submitted to Maven
## hikage-extension ## hikage-extension
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Migrated Java reflection related behaviors from [YukiReflection](https://github.com/HighCapable/YukiReflection) to [KavaRef](https://github.com/HighCapable/KavaRef)
- Added generic `ViewGroup.LayoutParams` support for `addView` in `ViewGroup`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- The first version is submitted to Maven - The first version is submitted to Maven
## hikage-extension-betterandroid ## hikage-extension-betterandroid
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Adapted to decoupled `ui-component` and `ui-component-adapter` in `BetterAndroid`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- The first version is submitted to Maven - The first version is submitted to Maven
@@ -53,12 +75,21 @@ Time zone of version release date: **UTC+8**
## hikage-widget-androidx ## hikage-widget-androidx
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Added `MotionLayout`, `ImageFilterButton`, `ImageFilterView`, `MockView`, `MotionButton`, `MotionLabel`, `MotionTelltales` components to `ConstraintLayout`
- Adjusted some components to be `final`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- The first version is submitted to Maven - The first version is submitted to Maven
## hikage-widget-material ## hikage-widget-material
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="latest" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="latest" vertical="middle" />
- Adjusted some components to be `final`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="stale" vertical="middle" />
- The first version is submitted to Maven - The first version is submitted to Maven

View File

@@ -139,12 +139,13 @@ Hikage can automatically generate the `Hikageable` function corresponding to the
You can add the `HikageView` annotation on your custom `View` to mark it as a Hikage layout component. You can add the `HikageView` annotation on your custom `View` to mark it as a Hikage layout component.
| Parameter Name | Description | | Parameter Name | Description |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value | | `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value |
| `alias` | The alias of the layout component, that is, the function name to be generated, gets the name of the current Class by default | | `alias` | The alias of the layout component, that is, the function name to be generated, gets the name of the current Class by default |
| `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters | | `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters |
| `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` | | `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` |
| `final` | Whether to declare the layout as "final layout", the default is false, that is, whether this layout is `ViewGroup` or its subclasses will not generate the `performer` method block. After set to `true`, `lparams` and `requirePerformer` will no longer be valid. |
> The following example > The following example
@@ -177,13 +178,14 @@ Hikageable {
Hikage can also automatically generate layout component functions for the `View` component provided by third parties, and you can use the `HikageViewDeclaration` annotation to complete it. Hikage can also automatically generate layout component functions for the `View` component provided by third parties, and you can use the `HikageViewDeclaration` annotation to complete it.
| Parameter Name | Description | | Parameter Name | Description |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `view` | Class object of layout component that needs to be declared | | `view` | Class object of layout component that needs to be declared |
| `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value | | `lparams` | LayoutParams `Class` object, if your custom `View` is a subclass of `ViewGroup`, you can declare or leave it blank to use the default value |
| `alias` | The alias of the layout component, that is, the name of the function to be generated, obtains the name of the `view` Class by default | | `alias` | The alias of the layout component, that is, the name of the function to be generated, obtains the name of the `view` Class by default |
| `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters | | `requireInit` | Whether to fill in the initialization method block of the layout, the default is the omitted parameters |
| `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` | | `requirePerformer` | Whether to fill in the `performer` method block of the layout, the default is an omitted parameter, which only takes effect when your custom `View` is a subclass of `ViewGroup` |
| `final` | Whether to declare the layout as "final layout", the default is false, that is, whether this layout is `ViewGroup` or its subclasses will not generate the `performer` method block. After set to `true`, `lparams` and `requirePerformer` will no longer be valid. |
> The following example > The following example

View File

@@ -65,7 +65,7 @@ You can view the KDoc [click here](kdoc://hikage-extension-betterandroid).
### Adapter Extension ### Adapter Extension
Hikage provides layout extension function for BetterAndroid's [Adapter](https://betterandroid.github.io/BetterAndroid/en/library/ui-component#adapter), Hikage provides layout extension function for BetterAndroid's [Adapter](https://betterandroid.github.io/BetterAndroid/en/library/ui-component-adapter),
you can use the Hikage layout directly on the original extension method of the adapter. you can use the Hikage layout directly on the original extension method of the adapter.
It uses the `ViewHolderDelegate` provided by BetterAndroid to create extension methods. It uses the `ViewHolderDelegate` provided by BetterAndroid to create extension methods.
@@ -76,9 +76,9 @@ Here is a simple example based on `RecyclerView`.
```kotlin ```kotlin
// Assume this is the dataset you need to bind to. // Assume this is the dataset you need to bind to.
val listData = ArrayList<CustomBean>() val listData = ArrayList<MyEntity>()
// Create and bind to a custom RecyclerView.Adapter. // Create and bind to a custom RecyclerView.Adapter.
val adapter = recyclerView.bindAdapter<CustomBean> { val adapter = recyclerView.bindAdapter<MyEntity> {
onBindData { listData } onBindData { listData }
onBindItemView( onBindItemView(
Hikageable = { Hikageable = {
@@ -87,8 +87,8 @@ val adapter = recyclerView.bindAdapter<CustomBean> {
textSize = 16f textSize = 16f
} }
} }
) { hikage, bean, position -> ) { hikage, entity, position ->
hikage.get<TextView>("text_view").text = bean.name hikage.get<TextView>("text_view").text = entity.name
} }
} }
``` ```

View File

@@ -219,7 +219,7 @@ Or, use in a custom `View`.
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
init { init {
addView { addView<FrameLayout.LayoutParams> {
TextView { TextView {
text = "Hello, World!" text = "Hello, World!"
textSize = 16f textSize = 16f

View File

@@ -10,7 +10,16 @@
## hikage-core ## hikage-core
### 1.0.1 | 2025.05.06 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.2 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- 将 Java 反射相关行为由 [YukiReflection](https://github.com/HighCapable/YukiReflection) 迁移至 [KavaRef](https://github.com/HighCapable/KavaRef)
- 适配 Android 16 (API 36),解决了 Android 16 上 `XmlBlock` 的崩溃问题
- 优化布局性能,移除了不必要的内联操作,对反射操作增加缓存
- `HikageView``HikageViewDeclaration` 新增 `final` 参数以配合 `hikage-compiler` 实现新功能
- `Widgets` 新增 `SurfaceView``WebView` 内置组件
- `Widgets` 调整部分组件为 `final`
### 1.0.1 | 2025.05.06 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 修复 KSP 源码没有成功发布的问题 - 修复 KSP 源码没有成功发布的问题
- 新增状态管理功能 - 新增状态管理功能
@@ -21,19 +30,32 @@
## hikage-compiler ## hikage-compiler
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- 新增对 `HikageView``HikageViewDeclaration``final` 参数的支持,详情请参考文档的相关用法
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 首个版本提交至 Maven - 首个版本提交至 Maven
## hikage-extension ## hikage-extension
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- 将 Java 反射相关行为由 [YukiReflection](https://github.com/HighCapable/YukiReflection) 迁移至 [KavaRef](https://github.com/HighCapable/KavaRef)
- `ViewGroup` 新增对 `addView` 的泛型 `ViewGroup.LayoutParams` 支持
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 首个版本提交至 Maven - 首个版本提交至 Maven
## hikage-extension-betterandroid ## hikage-extension-betterandroid
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- 适配了 `BetterAndroid` 解耦合后的 `ui-component``ui-component-adapter`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 首个版本提交至 Maven - 首个版本提交至 Maven
@@ -45,12 +67,21 @@
## hikage-widget-androidx ## hikage-widget-androidx
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- `ConstraintLayout` 新增 `MotionLayout``ImageFilterButton``ImageFilterView``MockView``MotionButton``MotionLabel``MotionTelltales` 组件
- 调整部分组件为 `final`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 首个版本提交至 Maven - 首个版本提交至 Maven
## hikage-widget-material ## hikage-widget-material
### 1.0.0 | 2025.04.20 &ensp;<Badge type="tip" text="最新" vertical="middle" /> ### 1.0.1 | 2025.08.24 &ensp;<Badge type="tip" text="最新" vertical="middle" />
- 调整部分组件为 `final`
### 1.0.0 | 2025.04.20 &ensp;<Badge type="warning" text="过旧" vertical="middle" />
- 首个版本提交至 Maven - 首个版本提交至 Maven

View File

@@ -136,12 +136,13 @@ Hikage 可以在编译时为指定的布局组件自动生成布局组件对应
你可以在你的自定义 `View` 上加入 `HikageView` 注解,以标记它生成为 Hikage 布局组件。 你可以在你的自定义 `View` 上加入 `HikageView` 注解,以标记它生成为 Hikage 布局组件。
| 参数名称 | 描述 | | 参数名称 | 描述 |
| ------------------ | --------------------------------------------------------------------------------------------------------------------- | | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View``ViewGroup` 的子类,则可以声明或留空使用默认值 | | `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View``ViewGroup` 的子类,则可以声明或留空使用默认值 |
| `alias` | 布局组件的别名,即要生成的函数名称,默认获取当前 Class 的名称 | | `alias` | 布局组件的别名,即要生成的函数名称,默认获取当前 Class 的名称 |
| `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 | | `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 |
| `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View``ViewGroup` 的子类时生效 | | `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View``ViewGroup` 的子类时生效 |
| `final` | 是否将布局声明为 “最终布局”,默认否,即此布局是否是 `ViewGroup` 还是从其继承都将不会生成 `performer` 方法块,设置为 `true` 之后,`lparams``requirePerformer` 将不再有效。 |
> 示例如下 > 示例如下
@@ -174,13 +175,14 @@ Hikageable {
Hikage 同样可以为第三方提供的 `View` 组件自动生成布局组件函数,你可以使用 `HikageViewDeclaration` 注解来完成。 Hikage 同样可以为第三方提供的 `View` 组件自动生成布局组件函数,你可以使用 `HikageViewDeclaration` 注解来完成。
| 参数名称 | 描述 | | 参数名称 | 描述 |
| ------------------ | --------------------------------------------------------------------------------------------------------------------- | | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `view` | 需要声明的布局组件的 Class 对象 | | `view` | 需要声明的布局组件的 Class 对象 |
| `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View``ViewGroup` 的子类,则可以声明或留空使用默认值 | | `lparams` | 布局参数 `ViewGroup.LayoutParams` Class 对象,如果你的自定义 `View``ViewGroup` 的子类,则可以声明或留空使用默认值 |
| `alias` | 布局组件的别名,即要生成的函数名称,默认获取 `view` Class 的名称 | | `alias` | 布局组件的别名,即要生成的函数名称,默认获取 `view` Class 的名称 |
| `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 | | `requireInit` | 是否要求填写布局的初始化方法块,默认为可省略的参数 |
| `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View``ViewGroup` 的子类时生效 | | `requirePerformer` | 是否要求填写布局的 `performer` 方法块,默认为可省略的参数,仅在你的自定义 `View``ViewGroup` 的子类时生效 |
| `final` | 是否将布局声明为 “最终布局”,默认否,即此布局是否是 `ViewGroup` 还是从其继承都将不会生成 `performer` 方法块,设置为 `true` 之后,`lparams``requirePerformer` 将不再有效。 |
> 示例如下 > 示例如下

View File

@@ -65,7 +65,7 @@ implementation("com.highcapable.hikage:hikage-extension-betterandroid:<version>"
### 适配器 (Adapter) 扩展 ### 适配器 (Adapter) 扩展
Hikage 为 BetterAndroid 提供的 [适配器](https://betterandroid.github.io/BetterAndroid/zh-cn/library/ui-component#%E9%80%82%E9%85%8D%E5%99%A8-adapter) Hikage 为 BetterAndroid 提供的 [适配器](https://betterandroid.github.io/BetterAndroid/zh-cn/library/ui-component-adapter)
提供了布局扩展功能,你可以直接在适配器的原始扩展方法上使用 Hikage 布局。 提供了布局扩展功能,你可以直接在适配器的原始扩展方法上使用 Hikage 布局。
它使用了 BetterAndroid 提供的 `ViewHolderDelegate` 来创建扩展方法。 它使用了 BetterAndroid 提供的 `ViewHolderDelegate` 来创建扩展方法。
@@ -76,9 +76,9 @@ Hikage 为 BetterAndroid 提供的 [适配器](https://betterandroid.github.io/B
```kotlin ```kotlin
// 假设这就是你需要绑定的数据集 // 假设这就是你需要绑定的数据集
val listData = ArrayList<CustomBean>() val listData = ArrayList<MyEntity>()
// 创建并绑定到自定义的 RecyclerView.Adapter // 创建并绑定到自定义的 RecyclerView.Adapter
val adapter = recyclerView.bindAdapter<CustomBean> { val adapter = recyclerView.bindAdapter<MyEntity> {
onBindData { listData } onBindData { listData }
onBindItemView( onBindItemView(
Hikageable = { Hikageable = {
@@ -87,8 +87,8 @@ val adapter = recyclerView.bindAdapter<CustomBean> {
textSize = 16f textSize = 16f
} }
} }
) { hikage, bean, position -> ) { hikage, entity, position ->
hikage.get<TextView>("text_view").text = bean.name hikage.get<TextView>("text_view").text = entity.name
} }
} }
``` ```

View File

@@ -217,7 +217,7 @@ root.addView {
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
init { init {
addView { addView<FrameLayout.LayoutParams> {
TextView { TextView {
text = "Hello, World!" text = "Hello, World!"
textSize = 16f textSize = 16f

View File

@@ -14,23 +14,23 @@ project.samples-app.packageName=com.highcapable.hikage.demo
project.samples-app.versionName=universal project.samples-app.versionName=universal
project.samples-app.versionCode=1 project.samples-app.versionCode=1
project.hikage-core.namespace=${project.groupName}.core project.hikage-core.namespace=${project.groupName}.core
project.hikage-core.version="1.0.1" project.hikage-core.version="1.0.2"
project.hikage-core-lint.namespace=${project.groupName}.core.lint project.hikage-core-lint.namespace=${project.groupName}.core.lint
project.hikage-core-lint.identifier=${project.groupName}:hikage-core:${project.hikage-core.version} project.hikage-core-lint.identifier=${project.groupName}:hikage-core:${project.hikage-core.version}
project.hikage-core-lint.min-api=9 project.hikage-core-lint.min-api=9
project.hikage-core-lint.registry-v2-class="${project.hikage-core-lint.namespace}.HikageIssueRegistry" project.hikage-core-lint.registry-v2-class="${project.hikage-core-lint.namespace}.HikageIssueRegistry"
project.hikage-extension.namespace=${project.groupName}.extension project.hikage-extension.namespace=${project.groupName}.extension
project.hikage-extension.version="1.0.0" project.hikage-extension.version="1.0.1"
project.hikage-extension-betterandroid.namespace=${project.groupName}.extension.betterandroid project.hikage-extension-betterandroid.namespace=${project.groupName}.extension.betterandroid
project.hikage-extension-betterandroid.version="1.0.0" project.hikage-extension-betterandroid.version="1.0.1"
project.hikage-extension-compose.namespace=${project.groupName}.extension.androidx.compose project.hikage-extension-compose.namespace=${project.groupName}.extension.androidx.compose
project.hikage-extension-compose.version="1.0.0" project.hikage-extension-compose.version="1.0.0"
project.hikage-compiler.namespace="${project.groupName}.compiler" project.hikage-compiler.namespace="${project.groupName}.compiler"
project.hikage-compiler.version="1.0.0" project.hikage-compiler.version="1.0.1"
project.hikage-widget-androidx.namespace=${project.groupName}.widget.androidx project.hikage-widget-androidx.namespace=${project.groupName}.widget.androidx
project.hikage-widget-androidx.version="1.0.0" project.hikage-widget-androidx.version="1.0.1"
project.hikage-widget-material.namespace=${project.groupName}.widget.google.material project.hikage-widget-material.namespace=${project.groupName}.widget.google.material
project.hikage-widget-material.version="1.0.0" project.hikage-widget-material.version="1.0.1"
# Maven Publish Configuration # Maven Publish Configuration
SONATYPE_HOST=CENTRAL_PORTAL SONATYPE_HOST=CENTRAL_PORTAL
RELEASE_SIGNING_ENABLED=true RELEASE_SIGNING_ENABLED=true

View File

@@ -131,7 +131,8 @@ libraries:
version: 3.7.0 version: 3.7.0
com.android.tools.lint: com.android.tools.lint:
lint: lint:
version: 31.12.1 version: 31.9.0
auto-update: false
lint-api: lint-api:
version-ref: <this>::lint version-ref: <this>::lint
lint-checks: lint-checks:

View File

@@ -211,7 +211,7 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
if (!performer.annotation.requireInit) defaultValue("{}") if (!performer.annotation.requireInit) defaultValue("{}")
}.build() }.build()
) )
lparamsClass?.second?.let { lparamsClass?.second?.takeIf { !performer.annotation.final }?.let {
addParameter( addParameter(
ParameterSpec.builder( ParameterSpec.builder(
name = "performer", name = "performer",
@@ -343,7 +343,8 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
override val lparams: KSClassDeclaration?, override val lparams: KSClassDeclaration?,
override val alias: String?, override val alias: String?,
override val requireInit: Boolean, override val requireInit: Boolean,
override val requirePerformer: Boolean override val requirePerformer: Boolean,
override val final: Boolean
) : HikageAnnotationSpec { ) : HikageAnnotationSpec {
companion object { companion object {
@@ -360,12 +361,13 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
val alias = annotation.arguments.getOrNull<String>("alias") val alias = annotation.arguments.getOrNull<String>("alias")
val requireInit = annotation.arguments.getOrNull<Boolean>("requireInit") ?: false val requireInit = annotation.arguments.getOrNull<Boolean>("requireInit") ?: false
val requirePerformer = annotation.arguments.getOrNull<Boolean>("requirePerformer") ?: false val requirePerformer = annotation.arguments.getOrNull<Boolean>("requirePerformer") ?: false
val final = annotation.arguments.getOrNull<Boolean>("final") ?: false
// Solve the actual content of the annotation parameters. // Solve the actual content of the annotation parameters.
val declaration = Processor.createViewDeclaration(NAME, alias, ksClass) val declaration = Processor.createViewDeclaration(NAME, alias, ksClass)
val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams) val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams)
return HikageViewSpec(resolvedLparams, alias, requireInit, requirePerformer) to declaration return HikageViewSpec(resolvedLparams, alias, requireInit, requirePerformer, final) to declaration
} }
} }
} }
@@ -375,7 +377,8 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
override val lparams: KSClassDeclaration?, override val lparams: KSClassDeclaration?,
override val alias: String?, override val alias: String?,
override val requireInit: Boolean, override val requireInit: Boolean,
override val requirePerformer: Boolean override val requirePerformer: Boolean,
override val final: Boolean
) : HikageAnnotationSpec { ) : HikageAnnotationSpec {
companion object { companion object {
@@ -393,6 +396,7 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
val alias = annotation.arguments.getOrNull<String>("alias") val alias = annotation.arguments.getOrNull<String>("alias")
val requireInit = annotation.arguments.getOrNull<Boolean>("requireInit") ?: false val requireInit = annotation.arguments.getOrNull<Boolean>("requireInit") ?: false
val requirePerformer = annotation.arguments.getOrNull<Boolean>("requirePerformer") ?: false val requirePerformer = annotation.arguments.getOrNull<Boolean>("requirePerformer") ?: false
val final = annotation.arguments.getOrNull<Boolean>("final") ?: false
// Solve the actual content of the annotation parameters. // Solve the actual content of the annotation parameters.
val resolvedView = view?.declaration?.getClassDeclaration(resolver) ?: error("Internal error.") val resolvedView = view?.declaration?.getClassDeclaration(resolver) ?: error("Internal error.")
@@ -407,7 +411,7 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
} }
val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams) val resolvedLparams = Processor.resolvedLparamsDeclaration(NAME, resolver, declaration, lparams)
return HikageViewDeclarationSpec(resolvedView, resolvedLparams, alias, requireInit, requirePerformer) to declaration return HikageViewDeclarationSpec(resolvedView, resolvedLparams, alias, requireInit, requirePerformer, final) to declaration
} }
} }
} }
@@ -417,6 +421,7 @@ class HikageViewGenerator(override val environment: SymbolProcessorEnvironment)
val alias: String? val alias: String?
val requireInit: Boolean val requireInit: Boolean
val requirePerformer: Boolean val requirePerformer: Boolean
val final: Boolean
} }
private data class Performer( private data class Performer(

View File

@@ -45,6 +45,9 @@ import kotlin.reflect.KClass
* @param requireInit whether to force the `init` parameter to be called, default is false. * @param requireInit whether to force the `init` parameter to be called, default is false.
* @param requirePerformer whether to force the `performer` parameter to be called, default is false, * @param requirePerformer whether to force the `performer` parameter to be called, default is false,
* this parameter will be ignored when no `performer` parameter is needed here. * this parameter will be ignored when no `performer` parameter is needed here.
* @param final whether to declare this layout as "final layout", default is false, that is,
* whether this layout inherits from or is [ViewGroup], the `performer` parameter will not be generated.
* After set to `true`, [lparams] and [requirePerformer] will no longer be valid.
*/ */
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
@@ -53,5 +56,6 @@ annotation class HikageView(
val lparams: KClass<*> = Any::class, val lparams: KClass<*> = Any::class,
val alias: String = "", val alias: String = "",
val requireInit: Boolean = false, val requireInit: Boolean = false,
val requirePerformer: Boolean = false val requirePerformer: Boolean = false,
val final: Boolean = false
) )

View File

@@ -48,6 +48,9 @@ import kotlin.reflect.KClass
* @param requireInit whether to force the `init` parameter to be called, default is false. * @param requireInit whether to force the `init` parameter to be called, default is false.
* @param requirePerformer whether to force the `performer` parameter to be called, default is false, * @param requirePerformer whether to force the `performer` parameter to be called, default is false,
* this parameter will be ignored when no `performer` parameter is needed here. * this parameter will be ignored when no `performer` parameter is needed here.
* @param final whether to declare this layout as "final layout", default is false, that is,
* whether this layout inherits from or is [ViewGroup], the `performer` parameter will not be generated.
* After set to `true`, [lparams] and [requirePerformer] will no longer be valid.
*/ */
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
@@ -57,5 +60,6 @@ annotation class HikageViewDeclaration(
val lparams: KClass<*> = Any::class, val lparams: KClass<*> = Any::class,
val alias: String = "", val alias: String = "",
val requireInit: Boolean = false, val requireInit: Boolean = false,
val requirePerformer: Boolean = false val requirePerformer: Boolean = false,
val final: Boolean = false
) )

View File

@@ -24,7 +24,8 @@
package com.highcapable.hikage.widget.android package com.highcapable.hikage.widget.android
import android.widget.AbsListView import android.view.SurfaceView
import android.webkit.WebView
import android.widget.ActionMenuView import android.widget.ActionMenuView
import android.widget.AutoCompleteTextView import android.widget.AutoCompleteTextView
import android.widget.Button import android.widget.Button
@@ -101,7 +102,7 @@ private object SpaceDeclaration
@HikageViewDeclaration(CheckedTextView::class) @HikageViewDeclaration(CheckedTextView::class)
private object CheckedTextViewDeclaration private object CheckedTextViewDeclaration
@HikageViewDeclaration(ExpandableListView::class, AbsListView.LayoutParams::class) @HikageViewDeclaration(ExpandableListView::class, final = true)
private object ExpandableListViewDeclaration private object ExpandableListViewDeclaration
@HikageViewDeclaration(Spinner::class) @HikageViewDeclaration(Spinner::class)
@@ -143,13 +144,13 @@ private object TextSwitcherDeclaration
@HikageViewDeclaration(ActionMenuView::class, ActionMenuView.LayoutParams::class) @HikageViewDeclaration(ActionMenuView::class, ActionMenuView.LayoutParams::class)
private object ActionMenuViewDeclaration private object ActionMenuViewDeclaration
@HikageViewDeclaration(CalendarView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(CalendarView::class, final = true)
private object CalendarViewDeclaration private object CalendarViewDeclaration
@HikageViewDeclaration(DatePicker::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(DatePicker::class, final = true)
private object DatePickerDeclaration private object DatePickerDeclaration
@HikageViewDeclaration(TimePicker::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(TimePicker::class, final = true)
private object TimePickerDeclaration private object TimePickerDeclaration
@HikageViewDeclaration(RatingBar::class) @HikageViewDeclaration(RatingBar::class)
@@ -173,19 +174,25 @@ private object ViewFlipperDeclaration
@HikageViewDeclaration(ViewAnimator::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(ViewAnimator::class, FrameLayout.LayoutParams::class)
private object ViewAnimatorDeclaration private object ViewAnimatorDeclaration
@HikageViewDeclaration(SurfaceView::class)
private object SurfaceVieweclaration
@HikageViewDeclaration(VideoView::class) @HikageViewDeclaration(VideoView::class)
private object VideoViewDeclaration private object VideoViewDeclaration
@HikageViewDeclaration(Toolbar::class, Toolbar.LayoutParams::class) @HikageViewDeclaration(WebView::class, final = true)
private object WebViewDeclaration
@HikageViewDeclaration(Toolbar::class, final = true)
private object ToolbarDeclaration private object ToolbarDeclaration
@HikageViewDeclaration(GridLayout::class, GridLayout.LayoutParams::class) @HikageViewDeclaration(GridLayout::class, GridLayout.LayoutParams::class)
private object GridLayoutDeclaration private object GridLayoutDeclaration
@HikageViewDeclaration(GridView::class, AbsListView.LayoutParams::class) @HikageViewDeclaration(GridView::class, final = true)
private object GridViewDeclaration private object GridViewDeclaration
@HikageViewDeclaration(ListView::class, AbsListView.LayoutParams::class) @HikageViewDeclaration(ListView::class, final = true)
private object ListViewDeclaration private object ListViewDeclaration
@HikageViewDeclaration(ImageView::class) @HikageViewDeclaration(ImageView::class)
@@ -200,10 +207,10 @@ private object TableLayoutDeclaration
@HikageViewDeclaration(TableRow::class, TableRow.LayoutParams::class) @HikageViewDeclaration(TableRow::class, TableRow.LayoutParams::class)
private object TableRowDeclaration private object TableRowDeclaration
@HikageViewDeclaration(NumberPicker::class, LinearLayout.LayoutParams::class) @HikageViewDeclaration(NumberPicker::class, final = true)
private object NumberPickerDeclaration private object NumberPickerDeclaration
@HikageViewDeclaration(SearchView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(SearchView::class, final = true)
private object SearchViewDeclaration private object SearchViewDeclaration
@HikageViewDeclaration(Switch::class) @HikageViewDeclaration(Switch::class)
@@ -212,5 +219,5 @@ private object SwitchDeclaration
@HikageViewDeclaration(TabHost::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(TabHost::class, FrameLayout.LayoutParams::class)
private object TabHostDeclaration private object TabHostDeclaration
@HikageViewDeclaration(TabWidget::class, LinearLayout.LayoutParams::class) @HikageViewDeclaration(TabWidget::class, final = true)
private object TabWidgetDeclaration private object TabWidgetDeclaration

View File

@@ -30,6 +30,18 @@ import com.highcapable.hikage.core.base.HikageFactoryBuilder
import com.highcapable.hikage.core.base.HikagePerformer import com.highcapable.hikage.core.base.HikagePerformer
import com.highcapable.hikage.core.base.Hikageable import com.highcapable.hikage.core.base.Hikageable
/**
* @see ViewGroup.addView
* @see Hikageable
* @return [Hikage]
*/
@JvmName("addViewTyped")
inline fun <reified LP : ViewGroup.LayoutParams> ViewGroup.addView(
index: Int = -1,
factory: HikageFactoryBuilder.() -> Unit = {},
performer: HikagePerformer<LP>
) = Hikageable<LP>(context = context, factory = factory, performer = performer).apply { addView(root, index) }
/** /**
* @see ViewGroup.addView * @see ViewGroup.addView
* @see Hikageable * @see Hikageable
@@ -39,7 +51,7 @@ inline fun ViewGroup.addView(
index: Int = -1, index: Int = -1,
factory: HikageFactoryBuilder.() -> Unit = {}, factory: HikageFactoryBuilder.() -> Unit = {},
performer: HikagePerformer<ViewGroup.LayoutParams> performer: HikagePerformer<ViewGroup.LayoutParams>
) = Hikageable(context = context, factory = factory, performer = performer).apply { addView(root, index) } ) = addView<ViewGroup.LayoutParams>(index, factory, performer)
/** /**
* @see ViewGroup.addView * @see ViewGroup.addView

View File

@@ -78,7 +78,7 @@ private object AppCompatTextViewDeclaration
@HikageViewDeclaration(AppCompatToggleButton::class) @HikageViewDeclaration(AppCompatToggleButton::class)
private object AppCompatToggleButtonDeclaration private object AppCompatToggleButtonDeclaration
@HikageViewDeclaration(AppCompatToolbar::class, AppCompatToolbar.LayoutParams::class) @HikageViewDeclaration(AppCompatToolbar::class, final = true)
private object AppCompatToolbarDeclaration private object AppCompatToolbarDeclaration
@HikageViewDeclaration(AppCompatCheckedTextView::class) @HikageViewDeclaration(AppCompatCheckedTextView::class)
@@ -87,7 +87,7 @@ private object AppCompatCheckedTextViewDeclaration
@HikageViewDeclaration(SwitchCompat::class) @HikageViewDeclaration(SwitchCompat::class)
private object SwitchCompatDeclaration private object SwitchCompatDeclaration
@HikageViewDeclaration(AppCompatSearchView::class) @HikageViewDeclaration(AppCompatSearchView::class, final = true)
private object AppCompatSearchViewDeclaration private object AppCompatSearchViewDeclaration
@HikageViewDeclaration(LinearLayoutCompat::class, LinearLayoutCompat.LayoutParams::class) @HikageViewDeclaration(LinearLayoutCompat::class, LinearLayoutCompat.LayoutParams::class)

View File

@@ -24,8 +24,36 @@
package com.highcapable.hikage.widget.androidx.constraintlayout package com.highcapable.hikage.widget.androidx.constraintlayout
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.utils.widget.ImageFilterButton
import androidx.constraintlayout.utils.widget.ImageFilterView
import androidx.constraintlayout.utils.widget.MockView
import androidx.constraintlayout.utils.widget.MotionButton
import androidx.constraintlayout.utils.widget.MotionLabel
import androidx.constraintlayout.utils.widget.MotionTelltales
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(ConstraintLayout::class, ConstraintLayout.LayoutParams::class) @HikageViewDeclaration(ConstraintLayout::class, ConstraintLayout.LayoutParams::class)
private object ConstraintLayoutDeclaration private object ConstraintLayoutDeclaration
@HikageViewDeclaration(MotionLayout::class, ConstraintLayout.LayoutParams::class)
private object MotionLayoutDeclaration
@HikageViewDeclaration(ImageFilterButton::class)
private object ImageFilterButtonDeclaration
@HikageViewDeclaration(ImageFilterView::class)
private object ImageFilterViewDeclaration
@HikageViewDeclaration(MockView::class)
private object MockViewDeclaration
@HikageViewDeclaration(MotionButton::class)
private object MotionButtonDeclaration
@HikageViewDeclaration(MotionLabel::class)
private object MotionLabelDeclaration
@HikageViewDeclaration(MotionTelltales::class)
private object MotionTelltalesDeclaration

View File

@@ -27,5 +27,5 @@ package com.highcapable.hikage.widget.androidx.recyclerview
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(RecyclerView::class, RecyclerView.LayoutParams::class) @HikageViewDeclaration(RecyclerView::class, final = true)
private object RecyclerViewDeclaration private object RecyclerViewDeclaration

View File

@@ -28,8 +28,8 @@ import androidx.viewpager.widget.ViewPager
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(ViewPager::class, ViewPager.LayoutParams::class) @HikageViewDeclaration(ViewPager::class, final = true)
private object ViewPagerDeclaration private object ViewPagerDeclaration
@HikageViewDeclaration(ViewPager2::class) @HikageViewDeclaration(ViewPager2::class, final = true)
private object ViewPager2Declaration private object ViewPager2Declaration

View File

@@ -24,7 +24,6 @@
package com.highcapable.hikage.widget.google.material.appbar package com.highcapable.hikage.widget.google.material.appbar
import android.widget.Toolbar
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.MaterialToolbar
@@ -33,7 +32,7 @@ import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(AppBarLayout::class, AppBarLayout.LayoutParams::class) @HikageViewDeclaration(AppBarLayout::class, AppBarLayout.LayoutParams::class)
private object AppBarLayoutDeclaration private object AppBarLayoutDeclaration
@HikageViewDeclaration(MaterialToolbar::class, Toolbar.LayoutParams::class) @HikageViewDeclaration(MaterialToolbar::class, final = true)
private object MaterialToolbarDeclaration private object MaterialToolbarDeclaration
@HikageViewDeclaration(CollapsingToolbarLayout::class, CollapsingToolbarLayout.LayoutParams::class) @HikageViewDeclaration(CollapsingToolbarLayout::class, CollapsingToolbarLayout.LayoutParams::class)

View File

@@ -24,9 +24,8 @@
package com.highcapable.hikage.widget.google.material.bottomappbar package com.highcapable.hikage.widget.google.material.bottomappbar
import androidx.appcompat.widget.Toolbar
import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.bottomappbar.BottomAppBar
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(BottomAppBar::class, Toolbar.LayoutParams::class) @HikageViewDeclaration(BottomAppBar::class, final = true)
private object BottomAppBarDeclaration private object BottomAppBarDeclaration

View File

@@ -24,9 +24,8 @@
package com.highcapable.hikage.widget.google.material.bottomnavigation package com.highcapable.hikage.widget.google.material.bottomnavigation
import android.widget.FrameLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(BottomNavigationView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(BottomNavigationView::class, final = true)
private object BottomNavigationViewDeclaration private object BottomNavigationViewDeclaration

View File

@@ -24,9 +24,8 @@
package com.highcapable.hikage.widget.google.material.navigation package com.highcapable.hikage.widget.google.material.navigation
import android.widget.FrameLayout
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(NavigationView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(NavigationView::class, final = true)
private object NavigationViewDeclaration private object NavigationViewDeclaration

View File

@@ -24,9 +24,8 @@
package com.highcapable.hikage.widget.google.material.navigationrail package com.highcapable.hikage.widget.google.material.navigationrail
import android.widget.FrameLayout
import com.google.android.material.navigationrail.NavigationRailView import com.google.android.material.navigationrail.NavigationRailView
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(NavigationRailView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(NavigationRailView::class, final = true)
private object NavigationRailViewDeclaration private object NavigationRailViewDeclaration

View File

@@ -25,12 +25,11 @@
package com.highcapable.hikage.widget.google.material.search package com.highcapable.hikage.widget.google.material.search
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.appcompat.widget.Toolbar
import com.google.android.material.search.SearchBar import com.google.android.material.search.SearchBar
import com.google.android.material.search.SearchView import com.google.android.material.search.SearchView
import com.highcapable.hikage.annotation.HikageViewDeclaration import com.highcapable.hikage.annotation.HikageViewDeclaration
@HikageViewDeclaration(SearchBar::class, Toolbar.LayoutParams::class) @HikageViewDeclaration(SearchBar::class, final = true)
private object SearchBarDeclaration private object SearchBarDeclaration
@HikageViewDeclaration(SearchView::class, FrameLayout.LayoutParams::class) @HikageViewDeclaration(SearchView::class, FrameLayout.LayoutParams::class)