Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute representation for actions #221

Open
mvglasow opened this issue Mar 19, 2017 · 0 comments
Open

Attribute representation for actions #221

mvglasow opened this issue Mar 19, 2017 · 0 comments

Comments

@mvglasow
Copy link

mvglasow commented Mar 19, 2017

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

  • toString() returns a string representation which can be passed to a constructor of the class to recreate an identical copy of the instance. The string returned must contain all necessary information for this. For complex types, such as OmniArea, this string is an XML representation of all fields. Consequently, it may not always be suitable for user output.
  • getValue() returns a string representation suitable for user display, which is used to prepopulate rule descriptions and, for some data types, to populate the entry field UI. It may not always be suitable for parsing.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant