Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.48 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.48 KB

constretto-android

Useful Constretto project extensions for Android. Build Status

Quickstart

1. Add annotations to your POJO

public class ScreenPreferences {
	
	@Configuration // implies that the preference name in the SharedPreferences store is "brightness"
	private String brightness;

	@Configuration("length") // implies that the preference name in the SharedPreferences store is "length"
	private Integer scale;

	public String getBrightness() {
		return brightness; 
	}

	public Integer getScale() {
		return scale;
	}

}

2. Create Constretto Configuration

SharedPreferences prefs = this.getSharedPreferences("org.constretto.app", Context.MODE_PRIVATE);
ConstrettoConfiguration conf = ConstrettoAndroidBuilder.createConfigurationForSharedPreferences(prefs);

3. Inject configuration

final ScreenPreferences screenPreferences = configuration.as(ScreenPreferences.class);

Planned features

  • a ConfigurationStore implementation that wraps a SharedPreferences store
  • an easy way of creating a ConstrettoConfiguration object for a SharedPreferences

Follow development at the github issue tracker