biotinker / LibreTasks

An updated form of Omnidroid
Apache License 2.0
82 stars 22 forks source link

Attribute representation for actions #221

Open mvglasow opened 7 years ago

mvglasow commented 7 years ago

The DataType class, from which all attribute data types are derived, defines two methods for returning a string representation of the attribute. As I understand it, the representation is the following

When attributes are passed to actions, the CoreActionsDbHelper#fillParamWithEventAttrib() method takes care of that. Code: https://github.com/biotinker/LibreTasks/blob/master/LibreTasks/src/app/model/CoreActionsDbHelper.java#L236

It takes an instance of a DataType descendant and appends it to a StringBuilder. Internally, StringBuilder calls the toString() method—which means that the string representation passed to the object is the one which is guaranteed to be parseable, but not necessarily user friendly.

As a result, notifications will display XML for complex data types. It has become more of an issue with a few extensions I’m currently developing, such as speech output and new data types, which are complex internally but can be simplified to a short string for display purposes. For example, instead of simply reading out battery percentage (one figure), I now get an entire XML document (one root element with two children) read out. Try it—it’s fun! Alas, it’s not very practical…

On the other hand, other actions might actually require a parseable representation of the data (think of a new action that stores the current location as a POI in a navigation app), so simply passing getValue() to actions may possibly break other use cases.

Any ideas on how that can be addressed?