Fourth Week of Coding : 26 June - 2 July

Hello everyone, do you want to know what is the progress of our project?😏

Obviously, I am here to share that with you. So let’s have a look at the work done in the fourth week of this amazing journey🧐-

This week I had set up Gitlab CI for our trainer app, Completed the offline support for the trainer app using SQLite database, added syncing UI in the app to differentiate the downloaded content, testing 2–3 issues that were mentioned in the last blog that they are resolved or not. Wait guys let’s discuss all this in detail😀-

Set up CI/CD Pipeline to automatically build apk/artefact

Without CI/CD it difficult to check whether the particular code will build properly or not and we have to think about a local clone of the project or any other option to get its latest apk. To solve this I had set up the CI/CD Pipeline as well with the MR sent last week and in the one sent this week also.

Resolved Issues: #112

committed here - ce83405a 

Last run Pipeline: #327895681

CI is also added to offline-support MR.

Completed offline support

Initially, in the last MR documents on the media page and every media file get downloaded and then played there is not any support for storing any type of data locally to the device to make it available offline.

Therefore I had added an SQL database to the trainer app to store data. This week I had completed my pending work related to this which was just started last week.

Now the updated list of documents get saved to the local database whenever a user visits the media page with an active internet connection and if a user visits this page in offline mode even in that case he is able to use the application in the same manner as it is in online mode, in this case, it is fetching data from a local database.

When a user clicks on any media file if it does not download it takes some time to get downloaded the first time and show a progress UI. Let’s suppose if it is already downloaded in that case it gets played instantly without waiting for a newer version but every time when user clicks on the media either it is already downloaded or not, it hits the API to update the media file. In offline mode, nothing update happens and it played the last cached version stored in the device and in online mode, it instantly plays the last cached version and hit the API to listen for any updates on this file.

SQL Database Schema & Logic

  1. When the application launches it creates a media table with 4 columns-
  • id- stores the id of the document with which it is stored on dhis2
  • name- stores display Name of the document
  • fileuri- will be not null only when the document is downloaded and saved on the device, it stores the local location of the document on the device and in other cases its value is null
  • mimeType- it stores the content Type or media type of the document like application/pdf, video/mp4, etc. to play the media using the fileopener2 plugin

2. Logic for storing a list of documents of media page-

  • when a user visits this page new list will be fetched from dhis2 and now we need to take care of 3 cases : 

(1) DELETE : Document ids not present in the new list but present in our local DB. These documents are deleted from dhis2 and need to be deleted from local DB as well.

(2) UPDATE : After completing the first step, local DB is left only with those ids which need an update. We just update the particular row of their ids of local DB with whatever new corresponding data we received.

(3) CREATE : Now those document ids of a new list that are not passed through step 2 are one of those of newly added documents. We just need to create a new document with their data in our local DB.

These steps will take care of all cases for making a list of documents available offline.

committed here: e8b93759

3. Logic for offline support of media files-

  • Whenever the user clicks on the media file it gets downloaded and saved to the device local storage and its corresponding file location and mimeType gets updated to the fileuri and mimeType key of local DB for that document. And on the next time, a user doesn’t need to wait for it to get downloaded it gets played from the last saved location.
  • I had used PERSISTENT storage and cordova-file-plugin to save the file to the device.

committed here: 65ddad02

Resolved Issues: #69

Corresponding MR: !195

Pipeline: #329574660

Added Sync Based UI

I had added 3 types of sync symbols ( Pending, Completed, Error ) in the media page list.

I had also added a progress bar that shows the ongoing sync state.

committed here: bf49a629

Testing of Issues

There are some issues whose testing I have to do last week. Let’s discuss them one by one-

  1. Track app usage data ( #36 )
  • We want to track the usage of our app and gets its report on dhis2 or tracker app.
  • For that, the page visit is set up for all pages means whenever the user visits any page then it gets recorded on local device storage as a counter of visits to that page.
  • Now the need is to shift this data to dhis2 via Web API in an App Usage Tracker Program. This part is not done.

2. Role-based restricted access for viewing tracked entities ( #44 )

  • We want that the TEI should be visible only to the person who had created it other person visibility to this should be restricted.
  • This part is not working and since we had updated the mHBS app from dhis2 after 3 years it has a lot of changes and the new codebase is completely in Kotlin and well architectured and segregated.
  • Therefore this part need rework. This is not working in the new app. You can have a look at the latest mHBS tracker app codebase from here.

3. Need to create a new program stage in dhis2 ( #10 )

  • This issue is also cannot be closed for now.
  • There is no commit in the latest code that can solve this for now.
  • Needs rework.

Works Done in the Fourth Week

  1. Set up CI/CD to automatically build the apk and check for errors.
  2. Added full offline support for the media page for both media files and a list of documents.
  3. Added file synced based UI for each media file.
  4. Tested 3 Issues.

Important Links

  1. Merge Request: Having code related to full offline support & SQL implementation of media page.
  2. Solved Issue: #69 #112
  3. Gitlab Pipeline : #329574660 #327895681
  4. Tested Issues : #36 #44 #10

Work to be done in the next week

  1. Working on Issue #36 
  • Shifting all app usage data from local storage to dhis2

      2. Working on Issue #44

  • Restricting the access of other users for viewing tracked entities

      3. Working on Issue #10

  • create a new program stage in dhis2


Popular posts from this blog

End of this Amazing Journey: GSoC-21

Community Bonding at LibreHealth

First Week of Coding : 7June -11 June