Skip to content

Instantly share code, notes, and snippets.

@Aditya-gupta99
Last active September 14, 2023 20:12
Show Gist options
  • Save Aditya-gupta99/3f2f97d03915b9ba0b52efb803263f0d to your computer and use it in GitHub Desktop.
Save Aditya-gupta99/3f2f97d03915b9ba0b52efb803263f0d to your computer and use it in GitHub Desktop.



MSoC'23 Final Report - The Mifos Initiative | Refactor Android Client & Rewrite using Android SDK


Contents

Pre MSoC

  • I played a crucial role in the development of the Android client from the very beginning. My dedication was evident even before I officially joined the team, as I proactively tackled the documented issues on the GitHub repository, methodically resolving existing bugs within the project's architecture. Furthermore, a noteworthy achievement was unlocked when we successfully upgraded the Gradle build and addressed login bugs associated with Retrofit in our project. Going beyond these accomplishments, I also provided assistance to a group of budding contributors, mentoring them as they took their initial steps into the world of open-source collaboration.

Work Accomplished

Reviewing existing Pull-Requests

  • In the Android client project, there had been an accumulation of nearly 200 pending Pull Requests dating back to 2016. In response to this backlog, I undertook the responsibility of reviewing and addressing these PRs. To mitigate potential merge conflicts, I made the decision to close the Java-based PRs and subsequently created new PRs in Kotlin for the more critical issues. Through this concerted effort, I successfully reduced the PR count to a much more manageable 12.

  • This proactive approach towards tackling the PR backlog not only contributes to a more streamlined and efficient codebase but also demonstrates a steadfast commitment to preserving the project's overall health and sustainability.

Project Upgradation

  • Android client previously used Kotlin version 1.7.0, which included support for kotlin-android-extensions. However, since kotlin-android-extensions is only supported up to Kotlin version 1.7.0, I have upgraded the project to Kotlin version 1.8.10. As part of this upgrade, I have removed the kotlin-android-extensions plugin and added the kotlin-parcelize plugin.

  • I have undertaken the process of upgrading all other dependencies to their latest versions in order to rectify existing bugs and enable the incorporation of new features. This strategic initiative is intended to enhance the competitiveness of the application and ensure its alignment with current trends.

  • The upgrade process has been completed within the following pull requests.

    1. PR #1967: Kotlin version upgrade
    2. PR #2007: Upgrade all dependencies

Java to Kotlin Migration

ButterKnife to ViewBinding Migration

Navigation Components

UI Enhancement

  • Initially, our user interface suffered from numerous issues, ranging from bugs to deficiencies in padding, color formatting, text size, and alignment. These shortcomings not only hindered the user experience but also left a negative impression on our users. To address these concerns and enhance the overall design and usability, I decided to implement the Material 3 design principles. This involved a comprehensive transformation of our UI components, aligning them with the Material 3 guidelines to ensure a more intuitive and user-friendly experience.

  • A distinguished User Interface has the capacity to generate immediate appeal towards the application, whereas an exceptional User Experience has the ability to leave a profound and enduring impression on the users.

  • I have attached a screenshot below that depicts the interface following the migration to Material 3.

Dagger2 to Hilt Migration

  • Previously, Dagger 2 was employed for dependency injection, and when using Dagger, setting up a ViewModelFactory necessitated a substantial amount of boilerplate code. As a result, I transitioned to Hilt, a framework that streamlines much of this boilerplate code, including the creation of a component interface and its implementation.

  • This Pull Request demonstrates the migration that has been completed.

MVP to MVVM Migration

  • Three months ago, the Android client application was utilizing the MVP (Model-View-Presenter) architecture. Since then, I have completely transitioned the project to follow the MVVM (Model-View-ViewModel) architecture pattern. As part of this migration, I have restructured the codebase so that repositories now handle the retrieval of data from the DataManager.kt module. Additionally, I have adopted the practice of injecting these repositories into their respective ViewModel classes through constructor injection.

  • We have created a repositories package that lists all of the repository interfaces and their implementation. The reason for creating an interface was that it followed two fundamental SOLID principles:

    • Open/Closed
    • Dependency Inversion
  • I have employed the use of LiveData in our ViewModel components to facilitate the observation of states within our application.I have implemented sealed classes to encapsulate objects, and data classes to encapsulate MutableLiveData instances. As part of MVVM migration efforts, I have compiled a comprehensive list of all the pull requests associated with these changes.

    1. PR #2025: MVP to MVVM Migration
    2. PR #2029: MVP to MVVM Migration
    3. PR #2030: MVP to MVVM Migration
    4. PR #2031: MVP to MVVM Migration
    5. PR #2032: MVP to MVVM Migration
    6. PR #2033: MVP to MVVM Migration
    7. PR #2034: MVP to MVVM Migration

Fineract SDK Dependencies Upgradation

  • Initially, Fineract SDK entails the utilization of outdated dependency versions. In response to this circumstance, I have initiated a comprehensive endeavor aimed at modernizing all remaining dependencies to their most recent iterations. This meticulous process has been instigated with the overarching objectives of rectifying extant bugs, facilitating the seamless integration of novel functionalities, and ultimately bolstering the overall competitiveness of the application. The paramount goal is to align the SDK with contemporary industry trends and standards.

  • Jitpack utilizes Java 8 for deploying Android libraries. In order to enable Jitpack to operate with Java 17, I have authored a jitpack.yml configuration file to specify the use of JDK 17.

  • I have provided the details of my pull request below.

    1. PR #59: Upgrade all dependencies
    2. PR #68: Changed Base URL
    3. PR #70: Added jitpack.yml file
    4. PR #73: Removed --add-opens and upgraded gradle to 8.0

Fineract SDK Integration

  • Previously, all REST API calls were managed by creating service classes, resulting in the generation of boilerplate code. This practice not only increased the size of the application but also resulted in a suboptimal user experience.And also, any modifications to the backend necessitated extensive code changes within the Android client, making it a challenging and time-consuming task.

  • I have implemented the fineract-android-sdk, which offers significant advantages in terms of development efficiency. This SDK streamlines the process by automating many of the labor-intensive and repetitive tasks associated with making REST API calls. also, it enhances the flexibility of our Android client application. In the event of any backend modifications, we can make the necessary adjustments within the Fineract SDK without the need to modify the Android client codebase. This decoupling of the backend and client code simplifies maintenance and ensures that our application remains adaptable to changes in the backend infrastructure.

MVVM

Architectural Design of Android Client

Unit tests for ViewModels

  • Following the transition from MVP to MVVM architecture, a critical component of our endeavors entailed the establishment of rigorous unit testing methodologies. More precisely, I steered our attention toward the development of exhaustive unit tests for ViewModels.

  • Previously, unit tests were originally implemented for the presenter components. However, I subsequently undertook the task of replacing all of these presenter unit tests with unit tests specifically designed for the view models, ensuring comprehensive coverage of 100%.

  • I have utilized the Mockito testing framework, in conjunction with the JUnit testing framework to create and submit the following Pull Requests.

    1. PR #2039: Unit Test for Viewmodels : Login, LoanCharges, Search, SyncClients and ClientCharge
    2. PR #2040: Unit Test for Viewmodels : Client, Center, Group and Document List

Improving Github Actions

  • Previously, GitHub Actions were configured to utilize JDK 8, which has become outdated in light of contemporary software components. As a response to this, I have adjusted the GitHub Actions configuration to utilize JDK 17.

  • You can observe the alterations here.

Project Cleanup

  • After implementing the aforementioned modifications, it is incumbent upon me to undertake the task of cleaning up unused elements and reorganizing all files into well-defined packages according to their respective features.

  • This Pull Request serves as an illustration of the cleanup efforts undertaken.

Impact

  • The transition of the Android client from Java to Kotlin represents a pivotal milestone in Migration. This shift not only allows us to leverage the capabilities of Jetpack Compose in the future but also empowers us to harness the rich ecosystem of Kotlin libraries.

  • The transition from MVP to MVVM architecture marked a significant and transformative evolution in the project's structural framework. The judiciously constructed repositories package, coupled with exhaustive unit testing for ViewModels, has significantly bolstered the platform's dependability, scalability, and ease of maintenance.

  • Following the successful implementation of Material 3, the user interface exhibits a remarkable visual appeal, leaving a highly favorable impression on users.

  • The implementation of the Fineract SDK has significantly streamlined our processes by automating numerous labor-intensive and repetitive tasks associated with initiating REST API requests. Furthermore, it has notably augmented the adaptability and versatility of our Android client.

What more can be done?

  • So far, I have exclusively focused on composing unit tests for a subset of our view models. Moving forward, we can extend this practice to cover all of the existing view models within our application.Also, we can initiate the process of creating unit tests for our repository classes. Furthermore, it would be beneficial to commence the development of Instrumentation Tests to facilitate comprehensive UI testing for our application.

  • During the implementation of the Fineract SDK, I have encountered several issues with the SDK, which include non-functional endpoints and inaccuracies in data fields. It is imperative that we address these issues in order to ensure the successful integration continues.

  • Jetpack Compose offers a more efficient approach to UI implementation compared to the traditional View-based UI approach in Android clients. The View-based approach can lead to inefficiencies in terms of memory usage and application performance. In contrast, Jetpack Compose employs a declarative programming model to express the UI, simplifying the process of understanding and designing the user interface. Instead of imperatively manipulating the view hierarchy, Jetpack Compose's declarative approach results in faster performance and reduced memory usage, making it a superior choice for modern Android app development.

Conclusion

  • Compared to three months ago, the Android client is far better now, and I'm confident that with further improvements, it will keep getting better. Continuously refactoring code and keeping an eye on quality are the keys to Android Development.

  • I had a great experience throughout this three-month-long program. I received tremendous support from the community as well as my mentors Avinash M Vijayvargiya and Rajan Maurya during this three-month journey. I would also like to thank Ed Cable for his outstanding support. The weekly check-ins were excellent. I had a great opportunity to bond with the community, as well as solve some problems that I encountered in the interim. I learned and grew a great deal as a result of this experience. It would be my pleasure to contribute to this organization in the future, as well as to assist new contributors to get started in this community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment