Background
I'm trying to keep an app which is as modular as possible.
The app will have have tasks which it performs on different intervals. My goal is to make it as easy possible to add new tasks with minimal understanding of the underlying architecture and without having to modify other files but at the same time not over complicating the code.
It would be perfect if all you needed to do to add a new task is to create the file and that's it.
This will require loading the tasks in runtime which I don't really like, I could live with a single place where all the registration is done (this also enabled toggling of the task)
Right now I've have an abstract task class which has a piece of static code which registers all tasks (basically adds them to a list).
Problem
Each task will have their own set of preferences and possibly resources.
Dividing strings and array is pretty easy by using prefixes for the names but the main issue comes with the preferences.
Right now I'm using a PreferenceActivity
to display my preferences.
The general settings are loaded from an XML file. Each task's preferences are located in a separate PreferenceScreen
. All tasks have only one thing common and that is an "Enabled" checkbox.
I don't want to store all the preferences in one file as it has the possibility to get quite messy that way.
Current solution
Right now each task have a method setupPreferences(PreferenceScreen)
in which they can add whatever options they want. This however has the downside of being programmatically which is not all that bad but I'd like to avoid that if possible.
Desired solution
The optimal solution would be if each task could have their own XML file which is loaded and added to the root PreferenceScreen
, as far as I know however this is not possible, the only way to load it is into a PreferenceActivity
.
Other notes
If anyone has any other suggestions on dividing resources in android feel free to share them :)
Thanks
Nicklas
Clarification
The tasks I'm talking about are never third party, they will internal only. This is more of a way to early on get a good structure of this app.