Config helps to manage the different build settings of your app.
Java Groovy IDL
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
gradle/wrapper
lib
.gitignore
Android-Config.iml
LICENSE
Makefile
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Android-Config

Android-Config helps to manage the different build settings of your app.

How it works

Config loads and parses .properties files placed in the res/raw folder of your application (it loads a debug file if debuggable is true), then exposes a class with a set of getParam methods. It's built around the same principle as Android-Features.

Implementation

First create a folder in your res folder named raw, then place two files there, one for the live build and one for the debug/dev (I usually name them config_app_debug.properties and config_app.properties)

Then open the files and specify your settings using the following format (we parse them with java.util.Properties).

URL = http://marteinn.se
AGE = 3600
TRACKING = 1

(Integer values 1 and 0 can also be treated as booleans).

After that you need to include the utility and run createInstance when your app starts, I recommend you place it in application onCreate, like this:

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        Config.createInstance().load(this,
            R.raw.config_app_debug,
            R.raw.config_app);
    }
}

You can also skip the validation part and load the configuration file directly.

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        Config.createInstance().load(this, R.raw.config_app_debug);
    }
}

Then retrive the various settings with these methods:

Config.getInstance().getParam("URL"); // http://marteinn.se
Config.getInstance().getIntParam("AGE"); // 3600
Config.getInstance().getBooleanParam("TRACKING"); // true

Setup

Locally

Download config.aar and move it to your libs folder, then make sure you got libs specified as a flatDir in gradle.config

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

After that just include it as any other dependency.

dependencies {
	compile 'se.marteinn.utils.config:config:1.0@aar'
}

Contributing

Want to contribute? Awesome. Just send a pull request.

License

Android-Features is released under the MIT License.