Tuesday, March 15, 2016

My contribution to Mifos Android Client

Mifos(mifos.org) is  the open source financial software and it's mission is to provide banking solution to poor. It has complete range of financial services needed for an effective financial inclusion solution.
 Core engine which is java based have all the banking functionalities such as 
  • creating loan product,saving product, Multiple Lending Methodologies such as Individual lending
  • Grameen Joint Liability group lending
  • Multi-tranche loans
  • Standing instructions for automated payments
  • co-op lending
Full Range of Deposit Products
  • Passbook savings
  • Fixed (term) deposits
  • Recurring deposits
  • Current accounts
Client facing android & web softwares have developed to interact with the core engine.
I have worked on both android & web application during my internship period.
My task was to add Surveys and Social Performance Management Scorecards in Mifos X Android Client. This Survey will be used to determine the financial condition of a person/family, based on the score in Survey it will determined whether they need financial help.

Backend server exposes the survey API. I have access the API endpoints to get active surveys from Server. Parsed the json to get survey questions & options. Capture the user response and post it back to server as scorecard.

Android recent material design used in the application. As Material design introduced in Android 5.0, to make it compatible with previous version app compat lib used in the app along with android design library.

What problem it solves?

This mobile survey tool will enable businesses to better understand the needs and interests of low-income consumers, while providing additional revenue for some of the world's poorest people.

What are the technical  challenges faced? 

  •  Some of the Survey question have two selection option and some have eight options. So it was challenging for me to generate radiobutton dynamically.
  • To transfer ArrayList of values from android fragment to activity. 
  • To update the Scorecard( user response) while user decide to change the response. 

So I fetched active surveys from Server and displayed in android listview.
When you select a particular survey it will take you to the question & options of that particular survey.
As few question have 2 options & few has 7 options, so it was challenging for me to display radiobutton dynamically based on the no of options. I have used viewpager widget to scroll to go to next question. 
I need to store QuestionId, ResponseId & ResponseValue of each question  and submit the scorecard value to Server.

Android provides a lot of options for storing data but the preference related settings can be easily stored and maintained using SharedPreferences class.
In this case I have used Android SharedPreferences to store and retrieve user selected responses . Create a separate SharedPreference utility class with methods to save, add, remove and get Scorecards from SharedPreferences.
Android SharedPreferences class does not provide a way to store a List or ArrayList or any collection. In order to store a list (even array, set or any collection) under a key, we convert the list (or collection) to JSON format using Gson and store it as string. While retrieving we convert the JSON string back to list and return it.
Layout Files.
In src folder, create a new class Scorecard in the package . 

SharedPreference class
Create a new class SharedPreference in the package . This class defines methods to save, add, remove and get Scorecards from SharedPreferences.Here we use Gson to convert List to JSON string in saveScorecards method and back again to List in getScorecards method.
This file defines custom layout for ListView item which is used by SurveyListAdapter.
In src folder, create a new class SurveyListAdapter in the package . This is the custom list adapter class which displays survey name, description.
In src folder, create a new class SurveyQuestionFragment in the package 
  • This class displays list of questions and options.
  • On radio button selection changed it adds that response in Scorecards by saving it in SharedPreferences. 
SurveyQuestion Activity
This is the main activity class.
  • When the app starts, it begins a new FragmentTransaction and starts SurveyQuestionFragment.
  • SurveyQuestionFragment is placed in Viewpager widget. When you scroll the widget it loads the next question in the series dynamically.
  • When you go back and update selection,it updates Scorecard and saves in SharedPreference.
Output Screens

No comments:

Post a Comment