metagloss 0.0.2

Package net.sf.metagloss.preference

Provides the AnnotatedPreferenceActivity along with its set annotations for binding and constraining data.

See:
          Description

Class Summary
AnnotatedPreferenceActivity Shows a PreferenceScreen where each Preference#setSummary(CharSequence) can be configured with annotations to be updated to reflect the current value of the Preference.
 

Annotation Types Summary
BindPreference Annotation type to make a Preference's value reflected in its summary field.
BooleanString Annotation type to set the format of Preference#setSummary(CharSequence) for CheckBoxPreferences to something other than true or false.
FloatConstraint Annotation type to set the valid numerical range for an EditTextPreference.
IntegerConstraint Annotation type to set the valid numerical range for an EditTextPreference.
PreferenceResource Annotation type to set the root XML preference screen.
 

Package net.sf.metagloss.preference Description

Provides the AnnotatedPreferenceActivity along with its set annotations for binding and constraining data. Each bound view's summary text is invoked upon updating the value.

Nonsensical example

preferences.xml

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android">
    <EditTextPreference
        android:title="Enter text"
        android:key="normal_text"
        android:defaultValue="hello" />
    <ListPreference 
        android:title="Choose a poet"
        android:key="poets"
        android:defaultValue="William Blake"
        android:entries="@array/poets"
        android:entryValues="@array/poets" />
    
    <PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:key="numerical_constraints"
        android:title="Numerical constraints">
        <EditTextPreference
            android:title="Constrained integer"
            android:key="constrained_int"
            android:numeric="integer"
            android:defaultValue="0" />
        <EditTextPreference 
            android:title="Constrained float"
            android:key="constrained_float"
            android:numeric="decimal|signed"
            android:defaultValue="0.0"/>
        </PreferenceScreen>
    
    <CheckBoxPreference
        android:title="Check me"
        android:key="check_me"
        android:defaultValue="false" />
    <CheckBoxPreference 
        android:title="Too much"
        android:key="too_much"
        android:defaultValue="false" />
    <CheckBoxPreference 
        android:title="Nothing special"
        android:key="nothing_special"
        android:defaultValue="false" />

</PreferenceScreen>

DemoPrefs.java

@PreferencesResource(R.xml.preferences)
public class DemoPrefs extends AnnotatedPreferenceActivity
{
    // child preference screen \\ 
    public static final String PREF_SCREEN_SUB = "numerical_constraints";
    
    // preference views \\
    
    @BindPreference("Current value reads '%s' - set a new value?")
    public static final String PREF_ENTER_TEXT = "normal_text";
    
    @BindPreference("%s will lead the way.")
    public static final String PREF_CHOOSE_POET = "poets";
    
    @IntegerConstraint(max=420)
    @BindPreference("integer value set to %s.")
    public static final String PREF_CONSTRAINED_INT = "constrained_int";
    
    @FloatConstraint(min=-10, max=10)
    @BindPreference("signed float value is %s, approximately.")
    public static final String PREF_CONSTRAINED_FLOAT = "constrained_float";
    
    @BooleanString(checked="rejoices", unchecked="is sad")
    @BindPreference("The checkbox %s.")
    public static final String PREF_CHECK_ME = "check_me";
    
    @BooleanString(checked="", unchecked="not ")
    @BindPreference("This is %stoo much")
    public static final String PREF_TOO_MUCH = "too_much";
    
    @BindPreference()
    public static final String PREF_NOTHING_SPECIAL = "nothing_special";
}
To try out the example, check out metagloss-test project and run the DemoActivity.

The metagloss-test project is currently only under svn:
svn co https://metagloss.svn.sourceforge.net/svnroot/metagloss/trunk/metagloss-test metagloss-test