Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msasikanth/android-resource-poet
Kotlin DSL to create Android resource XML
https://github.com/msasikanth/android-resource-poet
android kotlin xml
Last synced: 3 months ago
JSON representation
Kotlin DSL to create Android resource XML
- Host: GitHub
- URL: https://github.com/msasikanth/android-resource-poet
- Owner: msasikanth
- License: apache-2.0
- Created: 2023-01-18T15:16:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T09:51:46.000Z (5 months ago)
- Last Synced: 2024-09-09T11:48:17.010Z (5 months ago)
- Topics: android, kotlin, xml
- Language: Kotlin
- Homepage:
- Size: 243 KB
- Stars: 40
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Android Resource Poet
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.sasikanth/android-resource-poet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.sasikanth/android-resource-poet)
![CI Checks](https://github.com/msasikanth/android-resource-poet/actions/workflows/ci.yml/badge.svg)Kotlin DSL to create Android resource XML
## Adding to your project
```kotlin
implementation("dev.sasikanth:android-resource-poet:")
```## Basic usage
```kotlin
val xml: String = resourceXml {
string(name = "app_name") {
value = "Twine"
translatable = false
}dimen(name = "ball_radius") {
value = "30dp"
}
}// Write XML to file
val fileWriter: OutputStreamWriter = // configure file output stream
fileWriter.write(xml)
```## Supported resource types (WIP)
String
```kotlin
resourceXml {
string(name = "") {
value = "" // Required
translatable = false // Optional - Default true
}
}
````String Array
```kotlin
resourceXml {
stringArray(name = "") {
items = arrayOf("") // Required
translatable = false // Optional - Default true
}
}
````Plurals
```kotlin
resourceXml {
stringPlurals(name = "") {
translatable = false // Optional - Default true
item {
quantity = "" // Required
value = "" // Required
}
}
}
````Boolean
```kotlin
resourceXml {
boolean(name = "") {
value = true // Optional - Default false
}
}
```Color
```kotlin
resourceXml {
color(name = "") {
value = "" // Required
}
}
```Dimen
```kotlin
resourceXml {
dimen(name = "") {
value = "" // Required
}
}
```Integer
```kotlin
resourceXml {
integer(name = "") {
value = "" // Required
}
}
```Integer Array
```kotlin
resourceXml {
integerArray(name = "") {
values = intArrayOf() // Required
}
}
```Style
```kotlin
resourceXml {
style(name = "") {
parent = "" // Optional - Default emptyitem {
name = "" // Required
value = "" // Required
}
}
}
```## License
```
Copyright 2023 Sasikanth MiriyampalliLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttps://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```