cbitstech / Purple-Robot

Sensing and automation platform for Android.
Other
38 stars 19 forks source link

Declarative user interfaces #249

Open audaciouscode opened 9 years ago

audaciouscode commented 9 years ago

Implement declarative native UIs. UIs are expressed in standard Android XML and fetched from a remote server. UI XML includes a Purple Robot namespace that enables us to map user interactions to outcomes specified by PR scripts. For example:

<ImageButton src=”@drawable/button_image”
    …>
    <robot:Argument name=”foo”>bar</robot:Argument>
    <robot:OnClick>
        // Script that runs when button is pressed here.

        PurpleRobot.emitToast(foo, true); // Toasts “bar” on press
    </robot:OnClick>
</ImageButton>

Developer needs to identify the existing Android components suitable for inclusion in the XML that the system will adopt as well as appropriate arguments to be passed to the various components. Example:

<ListView android:id=”@+id/listView” …> robot:RowTemplate <LinearLayout android:orientation=”vertical” …> <TextArea android:id=”@+id/text_field1 … /> <TextArea android:id=”@+id/text_field2 … /> /robot:RowTemplate robot:items

    <robot:item robot:text_field1=”hello” robot:text_field2=”world” />
/robot:items
</ListView>

Bonus points if the layouts may also be expressed in scripting-friendly data structures, including JSON or S-Expressions.