Dynamic scripts in android

256 Views Asked by At

My Scenario

Suppose my android activity has a screen like this:

See the screenshot

All the fields are populated according to a response received from API. In the above scenario, the API response told to insert

  1. One Single line input field for entering User's name
  2. One date picker field to enter User's D.O.B
  3. One Single line field to enter user's age.
  4. One Radio field to select User's marital status.
  5. One Single line field to Enter User's Spouse's name.

The hard part is the following.

My Requirement

Suppose if the API also gives instructions (dynamic scripts) on what to do on user interaction, Like...

  • Show error when name field entry is more than 50 characters.
  • Fill the age field automatically when the user picks from D.O.B field.
  • Hide the Spouse Name field when the user picks radio button 'single'

The instruction may be anything from validating user entered values to hide/show UI elements (and these instructions may change from time to time and my client code must run without any modifications).

How can it be implemented on Android client side?

Current Implementation

The current implementation of API gives dynamic javascript instructions to the WEB CLIENT what to do. I can make the server give a separate set of instructions (separate script in python, ruby or anything) for the ANDROID CLIENT.

I'm trying to implement the same functionality in Android (and in iOS in the near future).

My Doubts Are

  1. What is the right way to implement this?
  2. How can I run a dynamic script in android (may it be python, js, ruby etc)
  3. Can the script manipulate android UI elements? (If the script knows the ID, tag etc of the View)
0

There are 0 best solutions below