Feature #433

Import/Export model config

Added by Espen Solbu over 5 years ago. Updated over 5 years ago.

Status:NewStart date:05/09/2012
Priority:NormalDue date:
Assignee:Android Dashboard Developers% Done:

0%

Category:-Spent time:-
Target version:3.5 Maintenance

Description

The config for a model should be file import and exportable. Preferably in XML, JSON or other structured textual representation.


Subtasks

Task #434: Implement ability to "share" exported modelconfigNewAndroid Dashboard Developers

Task #438: Implement ability to import model configNewAndroid Dashboard Developers

Task #439: Implement ability to export Model configNew

Associated revisions

Revision 467
Added by Hans Cappelle over 5 years ago

refs #433 fixing issue with import of hub, left open is selection of file by user. closes #493 using factory instead

History

#1 Updated by Hans Cappelle over 5 years ago

Espen Solbu wrote:

The config for a model should be file-exportable. Preferably in XML or other structured textual representation.

I would go for a text file containing json formatted objects. Android has good support for json. Parsing an object from json could be done with:

JSONObject json = new JSONObject(content.toString());
String someValue = json.get("someKey");

And then provide a ctor for the domain objects accepting a JSONObject. And use teh get method to set its properties back.

Writing as jsonObject would be:

JSONObject json = new JSONObject();
json.put("someKey", someValue);

Much faster and cleaner than having to create XML and then use SAX parser to get parsed again.

#2 Updated by Espen Solbu over 5 years ago

JSON should be fine (i think)
I am not very familiar with JSON, but i assume it supports nested structures, so that the config can contain an arbitrary number of channels, alarms etc.
(we can achieve this without nested structures as well, but would require some additional work on parsing)

My goal is to be able to store configuration outside the app, in a format that can be manually edited or revision controlled.
Later we can also provide a import mechanism

#3 Updated by Espen Solbu over 5 years ago

  • Subject changed from Exportable modelconfig to Import/Export model config
  • Description updated (diff)

#4 Updated by Hans Cappelle over 5 years ago

Espen Solbu wrote:

JSON should be fine (i think)

For api level 8 we will have to create or own json strings. This stackoverflow post has valid information: http://stackoverflow.com/questions/5571092/convert-object-to-json-in-android

Also listing gson library where (no experience myself) this could be done automatically: http://code.google.com/p/google-gson/

I'll give it a try soon.

#5 Updated by Espen Solbu over 5 years ago

Not sure it is worth the effort then.. don't really want to add additional libraries either.
could we dump SQL related to given model and channels to file?

Or at last resort (before abandoning the task) we could use binary files.

#6 Updated by Hans Cappelle over 5 years ago

Espen Solbu wrote:

Not sure it is worth the effort then.. don't really want to add additional libraries either.
could we dump SQL related to given model and channels to file?

Or at last resort (before abandoning the task) we could use binary files.

Espen

I used to gson lib on one of my own projects yesterday and it works like a charm. I didn't get the collection working right away but with just a single Object per file I could export to sdcard within minutes and get them back imported.

In this case we then only have to check that on import the item doesn't exist yet and if so ask the user which one to keep. We won't be able to check on ID's then though since the database could be filled with all other items. Would it be save to check on model name for instance? That is something the user should maintain.

btw why not use libraries? If you really insist in avoiding libraries we can still use the json implementation from android but then we need to serialise and deserialise each class member.

Another option is to use the Serialisable interface in java. I haven't tested this on Android though.

#7 Updated by Espen Solbu over 5 years ago

That does sound good!

My reason for avoiding libraries is due to size. Until yesterday, i have been using my HTC Desire. This phone has very limited space, and because of this, i am very skeptical to anything that takes additional size. What is the added size for this library?

Regarding import. I'd say just add every model from the file, regardless of same name. Most uses of this would be to export before upgrading, then importing after upgrade.
(basically only neccessary for us developers that move between local builds with developer key, and the "official builds" with my specific key.

I anticipate my model configuration to be fairly complex when i start to use this, so i would hate to have to manually configure every time...
(3 planes and 1 helicopter with telemetry)

#8 Updated by Espen Solbu over 5 years ago

  • Target version changed from 3.0 FrSky hub and sensors to 3.5 Maintenance

#9 Updated by Hans Cappelle over 5 years ago

Espen Solbu wrote:

My reason for avoiding libraries is due to size. Until yesterday, i have been using my HTC Desire. This phone has very limited space, and because of this, i am very skeptical to anything that takes additional size. What is the added size for this library?

I just checked and apps2SD is supported by the app already. I agree though that we should keep it as small as possible.

Size is around 180kb if I remember well. I'll look at stripping it to the essential classes (=open source).

#10 Updated by Espen Solbu over 5 years ago

180kb should not be a problem. No need to spend time on stripping.
I am wondering if we should modify the task though,
Right now, i would actually prefer to be able to import/export the entire configuration (channel, models and everything). Even though it would be nice to export individual models as well...

Also available in: Atom PDF