Konfigure
An Application Configuration Library based on Kotlin Property Delegation
Install / Use
/learn @TradeMe/KonfigureREADME
Konfigure
Kotlin Property Delegation-based application configuration library. Tailored for Android, but ready for multiplatform.
Download
// Base module
implementation "nz.co.trademe.konfigure:konfigure:${current.version}"
// Android module, including UI
implementation "nz.co.trademe.konfigure:konfigure-android:${current.version}"
// Extra: Firebase Remote Config
implementation "nz.co.trademe.konfigure:konfigure-firebase:${current.version}"
Usage
- Create a config source, or optionally use
FirebaseRemoteConfigSourcefrom thekonfigure-firebasemodule
object LocalSource: ConfigSource {
override val all: Map<String, String>
get() = TODO("Provide some config key-value pairs")
}
- Create a config subclass
class AppConfig: Config(configSources = listOf(LocalSource))
- Add some configuration items
class AppConfig: Config(configSources = listOf(LocalSource)) {
// The most simple config item, which uses the property name as a
// key and sensible non-null default values
val someSimpleItem: Boolean by config()
// Add a simple config item
val someItem: Boolean by config(
key = "item_key",
defaultValue = false
)
// OR, using `konfigure-android`, add a displayable config item
val someEditableItem: Boolean by config(
key = "item_key_2",
defaultValue = false,
title = "Something",
description = "Some editable config item",
group = "Some group"
)
}
- Use it!
val config = AppConfig()
// Use the property! This will check your config sources, look for overrides, and if it doesn't
// find anything will use the defaultValue parameter
if (config.someItem) {
TODO("Do something cool")
}
Konfigure supports much more advanced usages however. By adding custom metadata, you can customise the behaviour of konfigure to your hearts content. For more examples, check out the sample.
Modules
Konfigure contains a number of modules, which are useful for different things. Here's a quick run down of what they all do - more information can be found within these modules.
konfigure
This is the base module for Konfigure, which contains the core logic. Usage is as describe in the usage section of this README.
konfigure-android
This module contains Android-specific utilities, as well as a UI component which allows you to change the value of the config items within the app. In here you'll find things like SharedPreferencesOverrideHandler which gives you easily persistable overrides, as well as ConfigActivity and ConfigView for presenting overrides.
konfigure-firebase
This module contains a pre-build Firebase Remote Config source. Eventually this could be made multiplatform, as the Firebase SDK can be found on most platforms Kotlin/Multiplatform supports.
Contributing
We love contributions, but make sure to checkout CONTRIBUTING.MD first!
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
