I am new to android and writing an learning app for children in primary school. The app is for practicing simple calculations (add and subtract).
So far, I have finished the UI design and written a simple proof-of-concept implementation to demonstrate the basic usage of the app.
The design for one of the activities (addition of 123 and 456) would look like this:
|-----------------------------|
| |c| 1 |c| 2 |c| 3 |
| |
| 4 5 6 |
| -------------------- |
| | r1 | | r2 | | r3 | |
| |
| |
| 1 | 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 | 0 |
| cancel | check |
|-----------------------------|
The numbers (0-9) in the numblock are views that can be drag&dropped to the carry fields (|c|
) or the result fields (|r1|
etc). Values already dropped to the carry or result fields also can be moved (again with drag&drop) to another carry or result field.
There are going to be multiple practice modes, e.g.:
|-----------------------------|
| 1 + 9 = |r1|r2| |
| 2 + 8 = |r1|r2| |
| 3 + 7 = |r1|r2| |
| 4 + 6 = |r1|r2| |
| 5 + 5 = |r1|r2| |
| |
| |
| 1 | 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 | 0 |
| cancel | check |
|-----------------------------|
or:
|-----------------------------|
| 1 2 3 4 5 |
| | | | | | |
| |+| |+| | |
| | | | |
| |r1| |r2| | |
| | | | |
| \ \ / |
| \ |-| |
| \ | |
| \ |r3| |
| \ / |
| \ / |
| |+| |
| | |
| |r4| |
| |
| |
| 1 | 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 | 0 |
| cancel | check |
|-----------------------------|
For my current implementation, I have all the drag&drop stuff in one activity and the layout is one single .xml
file.
I would like to reuse the code for the drag&drop functionality in some way to keep the code clean and not have the same functionality implemented in many different activities.
I have already read about fragments in android and thought about making one fragment for the numblock and one fragment for each area where the numbers would be dropped, but as far as I researched, drag&drop between fragments is not really the way to go here (drag and drop between two fragments, the proposed solution does not seem to be very elegant).
Right now, I am thinking about just creating all content but the numblock dynamically in onCreate()
of a single activity depending on the required mode. I would like your opinion on this approach. Are there probable issues when going that way?
Is there another way to achieve the same functionality and keep the code maintainable? Have you suggestions on how I could design my code as simple and maintainable as possible? How would you design an app with the required functionality?
The general advice that leaving design decisions until you have to make them would certainly apply here. I am sure there are hundreds of ways in which you could organise code like this.
In the Activity (or could be a Fragment) you so far have the following functionality:
Can you split those different functionalities out somehow?
Are there things that are good candidates for making there own classes?
How will these elements communicate with each other?
How are you going to create a new instance of the Activity?
I haven't even begun to answer your question and yet this answer is getting very long.
The most important question is what do you want from the design? I'm guessing the answer is to make it as easy as possible to add new types of problem to the app.
Things that might help you:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With