Skip to content

Conversation

@mradzinski
Copy link
Contributor

@mradzinski mradzinski commented Aug 13, 2016

Changelog

Hey guys! This PR adds a new functionality called "Historial de donaciones"... 💥 🎉 🤘 👍

Changes:

  • Updated to latest build tools (23.0.3)
  • Organisations names and values in preferences have been reduced to a single string array that maps name to value using a pipe character and are dynamically loaded. There are three reasons for this change:
    1. It creates a more scalable approach by simplifying the addition of new organisations (we no longer have to maintain two string-arrays but just one).
    2. Index synchronisation. Having two string-arrays requires them both to be synchronised in a way that indexes should match (ex: ASH should match the array position of Animales sin Hogar). The newly implemented approach prevents bugs by enforcing synchronicity.
    3. It allows to match a value with a name through code allowing for future scalability (multiple programmed donations maybe?).
  • onOptionsItemSelected has been changed to use a switch statement instead of multiple if.
  • Fixed the tools:context of splash, settings and main activity layouts.
  • Extracted all preferences hardcoded messages into strings

New Additions:

  • Added a SQLite Database (DatabaseHelper class) with a History table which holds an historical of donations. It has been implemented using a classical Android approach (an ORM would've been an overdo). The history table is pretty simple, it just holds the organisation full name and an already pre-formatted date (dd/MM/yyyy HH:mm). The reason to hold a the date this way is purely related to the performance of the ListView and how it internally recycles its views.
  • Added a History DAO class. As per now it has only one method which is the one used to insert a new history entity. CRUD operations can be added later if required
  • Added SimpleCursorLoader. Loaders require of a ContentProvider and adding one to the project is kind of an overdo (couldn't find a single use case where we wanted to share the history with another app), so this class acts as a Loader but uses straight DB connections and cursors. SimpleCursorLoader extends AsyncTaskLoader and is based on Android's Loader class.
  • Added a new Activity to display the donations history to the user. The same can be accessed through a new menu entry called "Historial de donaciones". I chose to use a ListView instead of a RecyclerView for the solely reason that a RV would've added too much complexity for such a simple task (not to mention that the RV support library is ~0.7MB). This activity has included an empty layout in case users haven't donated yet and a non-flashing progress dialog. The progress dialog will always be displayed for at least for 1.2 seconds. From a user perspective it introduces consistency. If it shows up some times and not others it seems like something isn't working correctly.
  • Added an Utility class which contains common helper methods.
  • Added a title to the preferences DatePicker dialog.
  • Added a title to the preferences TimePicker dialog.

Todo:

  • Upon first execution get previously sent donation messages from the SMS ContentProvider and add them to our database. I'll try resolving this in a future PR.

I've tried to adhere as much as possible to the previously existent code. Let me know if everything's alright, if you like the idea or if anything needs to be fixed! 😬

@reviewsbix
Copy link

Hi @mradzinski thanks for the PR!! We'll review this when we have a chance and will let you know :)

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

Successfully merging this pull request may close these issues.

2 participants