ConfigurNation - Annotation based Kotlin Interfaces for Android SharedPreferences

Overview

ConfigurNation

Annotation based Kotlin Interfaces for Android SharedPreferences

License Development Bintray

Installation

Gradle

Dependencies

implementation 'com.izikode.izilib:configurnation:0.9'
kapt 'com.izikode.izilib:configurnation-compiler:0.9'

Source sets

ConfigurNation generates Kotlin source files, so you need to include the generation folder into your source sets.

android {
   ...
   sourceSets {
        main {
            java {
                srcDir "${buildDir.absolutePath}/generated/source/kaptKotlin/"
            }
        }
    }
}

Usage

#1 SETUP your mapping interface

@ConfigurNation( name = "SampleAppConfig", mode = Context.MODE_PRIVATE )
interface ConfigMap { ... }
  • Create your mapping interface and decorate with @ConfigurNation.
    • The name variable is the name of the generated Config class.
    • The mode variable is the mode assigned to the inner SharedPreferences object.
    • The mapping interface can be named anything, the qualified name of the class will be used as the SharedPreferences identifier.
@ConfigurMember
fun aBool(): Boolean
  • Declare abstract functions inside your interface, for your Config fields.
    • Decorate the config fields with @ConfigurMember
    • The name of the function is the name of the field inside the Config class.
    • The return type of the function is the type of data that will be stored.
      • Only valid SharePreferences types are supported at the moment. Those are:
        • Boolean
        • Float
        • Integer
        • Long
        • String

#2 BUILD your project

#3 USE

val config = SampleAppConfig(context)
  
/* write */
config.aBool = true
  
/* read */
val value = config.aBool

#4 MEMBER PARAMS

The ConfigurMember annotation has two parameters for more complex functions. The type controls how the data of the member are retrieved and stored and supports Synchronous, Asynchronous and Mixed modes. The withVariants flag controls whether a member has Key-based Variants under the same name or not.

For a full example of those parameters, see the Sample project.

Licence

Copyright 2018 Fanis Veizis

Licensed 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 at

    http://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.
You might also like...
Special-waddle - MiniGDX Game Template With Kotlin

MiniGDX Game Template Create your first game using miniGDX by clicking the "Use

Web blog application written on Kotlin with Ktor framework

polytech-blog Web blog application written on Kotlin with Ktor framework Docker was used to create docker image Docker Compose was used to create cont

A component for flip animation on Android, which is similar to the effect in Flipboard iPhone/Android
A component for flip animation on Android, which is similar to the effect in Flipboard iPhone/Android

android-flip Aphid FlipView is a UI component to accomplish the flipping animation like Flipboard does. A pre-built demo APK file for Android OS 2.2+

:rocket: Ultimate Android Reference - Your Road to Become a Better Android Developer
:rocket: Ultimate Android Reference - Your Road to Become a Better Android Developer

The goal of this project is to provide a hand-picked collection of Android libraries, tools, open-source projects, books, blogs, tutorials - you name

Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

Allows the easy creation of animated transition effects when the state of Android UI has changed
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Actions for android animations. Inspired by libgdx scene2d actions.
Actions for android animations. Inspired by libgdx scene2d actions.

Android Animations Actions Actions for android animations. Inspired by libgdx scene2d actions. The main goal of this project is making creating of com

Android library for swipable gestures
Android library for swipable gestures

Swipper Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conv

Android Library that lights items for tutorials or walk-throughs etc...
Android Library that lights items for tutorials or walk-throughs etc...

Spotlight Gradle dependencies { implementation 'com.github.takusemba:spotlight:x.x.x' } Usage val spotlight = Spotlight.Builder(this) .setTarg

Releases(v0.9)
Owner
Fanis Veizis
Android headbanger
Fanis Veizis
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Circle based animations for Android (min. API 11)

CircularTools Circle based animations for Android (min. API 11) Currently implemented: Circular reveal Circular transform Radial reaction Reveal:YouTu

AutSoft 209 Jul 20, 2022
Material Design text field that comes in a box, based on (OLD) Google Material Design guidelines.

TextFieldBoxes A new Material Design text field that comes in a box, based on Google Material Design guidelines. ???? 中文看这里 UPDATE NOTICE 1.4.5 Releas

Mark Wang 769 Jan 7, 2023
Web-based media manager with duplication detection, tagging, and more

reelchest ?? ??️ ??️ A basic web-based media manager. Download or upload clips,

Sebastian Aigner 7 Jan 3, 2022
RX-based async paradigm, Room, DI (Hilt), Retrofit, MVVM, Jetpack, Lottie, Transitions

CatBreedsApp RxJava, Room, DI (Hilt), Jetpack, Shared element transition. clean MVVM architecture, Retrofit Cats need your help, we want to build an a

Cristian Dumitrache 3 Oct 14, 2022
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
🎢 Zoom Recycler Layout Manager For Android Kotlin

Zoom Recyler Layout An beautiful Zoom Animation Library for RecyclerView Items in Android using Kotlin. Preview 1. Horizontal Scroll 2. Vertical Scrol

Sanju S 778 Jan 2, 2023
An simple & awesome animation library written in Kotlin for Android

An simple & awesome animation library written in Kotlin for Android

Romman Sabbir 53 Oct 17, 2022
Support extension to use Android ViewBinding quickly and smooth transform from kotlin-synthetic-extension.

ViewBinding Delegate Extension Support extension to use Android ViewBinding quickly and smooth transform from kotlin-synthetic-extension. Binding inst

Cuong V. Nguyen 3 Dec 13, 2021
A mix of random small libraries for Kotlin, the smallest reside here until big enough for their own repository.

klutter Random small libraries, usually extensions making other libraries happier. Versions later than 2.x are for JDK 8 and newer only. Maven Depende

Kohesive 140 Nov 1, 2022