Third Week of Coding : 19 June - 25 June

This was the third week of the coding phase and it was good. This week majorly, I had worked on the way to play the video blobs that I had fetched from the server last week and showing the pdf files in the app. I had worked on the offline support of the application as well. Let’s see everything in detail-

Added a feature to play all type media files in app

We have 2 types of media files videos and pdfs which we have to show in our app’s media section. Let’s see what approach I had chosen to achieve that and why?

  1. Firstly I had downloaded the blob object of the media that is being uploaded on the dhis2 using XMLHttpRequest.
  2. Then I had created a local temporary space in the memory to save the file.
  3. And lastly using the fileOpener2 plugin, I had opened that file using the supported apps that are already available on the user’s device.

This seems simpler but really It takes a lot of time to figure out how actually Cordova handles all this stuff🤔because I am not much familiar with the Cordova platform but finally I had made it. Actually, for videos I had initially used the most popular thing that is iframe but it didn’t work and I had changed it with the video element of HTML, and it gets working 😍. But the problem arises when I am trying to open pdf because in the browsers there are inbuilt plugins that handle pdf opening and all but for the android, there is no such thing therefore I need to use external apps with the help of fileOpener2 plugin. 

Final Output: Now one can upload pdfs and videos on the dhis2 resources and it will be fetched to our trainer app and can be accessed with the internet.

Have a look at the PR related to this task: Added mediaPage and Populated with real data Fetched from bmgfdev instance and Added support to play all media files of type blob (!194) 

Related Issues : #190 #77 #39

Added SQLite Database for storing data locally

We want our application to be active in offline mode as well therefore I had decided to use the sqlite database of the cordova plugin. Let’s look at the implementation part of the offline-support of media section:

 1. I had made a mhbsTarinerDb and media table to store the data of all the cuments. I will be storing a name (displayName of the document), id (dhis2 id of the document on the server), fileUri (location of the file if this media is downloaded). 

2. When the users click on the media tab then a list will be made from the documents available on the local db and it is shown on the tab at the same time an API call is initiated to the server if a user is online and we received a success response we will update our local db and media tab with this new data.

3. When a user clicks on particular media files then as stated earlier a blob object is downloaded and from it, we make a local file and save it to the device, now one point gets added that is we will store its location to our db as well and when the user again clicks on the particular files then similar thing happen means old content is shown till the new one is not downloaded and when new content is ready it gets updated to our db.

This part is almost ready and is under testing you can look at its progress from the offline-support branch of my forked repo. Worked done till now in offline support of media tab is here.

Work Done this Week

  1. Added a feature to play all type of media files in the app.
  • The list of all documents uploaded on the bmgfdev instance ( here ) is visible in the app.
  • Videos Media & Pdf files both can be opened and can be accessed through the app.

      2. Added SQLite database to store data locally and to provide offline support. 

Planning of next Week

  1. Finish pending work of Offline support and create PR for that.
  2. Adding CI to Trainer App: Continuous integration through Gitlab CI (#112) 
  3. Testing of some issues — 

Important Links

  1. Added mediaPage and Populated with real data Fetched from bmgfdev instance and Added support to play all media files of type blob (!194)
  2. Issue #190
  3. Issue #77 
  4. Issue #39
  5. Added SQL Database for storing data locally (26ad4006) · Commits · Bhavesh Sharma / mHBS-trainer · GitLab

Comments

Popular posts from this blog

First Week of Coding : 7June -11 June

End of this Amazing Journey: GSoC-21

Community Bonding at LibreHealth