Introduction
enviroCar Mobile is an Android application for smartphones that can be used to collect Extended Floating Car Data. A Bluetooth OBD2 adapter is used to communicate with the app while driving. This enables read access to data from the vehicle’s engine control. The data is recorded along with the smartphone’s GPS position data. The driver can view statistics about his drives and publish his data as open data. The latter happens by uploading tracks to the enviroCar server, where the data is available under the ODB licence for further analysis and use. The data can also be viewed and analysed via the enviroCar website.
In this year’s Google Summer of Code 2022, I have worked on various aspects that focus on replacing/ updating the deprecated libraries with newer and updated versions. Along with the library updates, I have also added new functionalities and improved the user interface of the app.
The main aspects of my contributions are as follows:
- Migration of RxJava from version 2 to 3.
- Replacement of Butter Knife View Binding with Android Jetpack View Binding.
- Implementation of RxJava based event-bus to replace Otto event-bus.
- Replacement of the deprecated SQLBrite library.
- Enhancement of the user interface and new features.
Goal 1: Migration of RxJava from version 2 to 3
RxJava is a Java library that enables Functional Reactive Programming in Android development. It raises the level of abstraction around threading in order to simplify the implementation of complex concurrent behaviour. At its core, RxJava simplifies development. A developer need not worry too much about the details of how to perform operations that should occur on different threads. This is particularly attractive since threading is challenging to get right and, if not correctly implemented, can cause some of the most difficult bugs to debug and fix.
Currently, the Android project is using an outdated RxJava version 2 instead of the latest version 3. RxJava is used because of the compelling interface and its user-friendly services. Several libraries used in the app are also dependent on RxJava, Hence this makes the update of RxJava important. RxJava 3 has some major changes compared to RxJava 2 these include superior threading, error-handling and caching capabilities.
Implementation details
I have migrated the project from RxJava 2 to RxJava 3(see Issue and PR). Along with the RxJava, I have updated a few other dependent libraries like androidRoomRxJava, RxAndroid and RxPreferences. RxJava 3 provides extra benefits such as parallel execution and retry mechanisms. Now the app takes full advantage of RxJava library and is in a fully functional state.
Goal 2: Replacement of Butter Knife View Binding with Android Jetpack View Binding
We decided to replace the deprecated Butter Knife View Binding with Jetpack View Binding to provide a cleaner approach for separating views from models.
Butter Knife is a 3rd party library made to address the issue of using findViewById() functions to reference and interact with views. It helped reduce boilerplate code but we also had to set up a Bind annotation every time we wanted to interact with a view. Then View Binding was introduced starting at Gradle version 3.6. A build feature which led to the deprecation of Butter Knife and a decrease in the use of findViewById() functions.
View Binding is a feature that allows developers to more easily write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module. A binding class instance contains direct references to all views that have an ID in the corresponding layout.
Before the start of the project, Butter Knife was being used to interact with the views. I replaced this with Jetpack View Binding. There are a few advantages of View Binding, for example :
- Jetpack view binding is compile time safe.
- It builds the app faster.
- Less boilerplate referencing.
- No more BindView annotations.
- Provides Type safety.
- Provides Null safety.
Implementation details
If view binding is enabled for a module, a binding class is generated for each XML layout file that the module contains. Each binding class contains references to the root view and all views that have an ID. The name of the binding class is generated by converting the name of the XML file to Pascal case and adding the word “Binding” to the end (see Issue and PR).
Goal 3: Implementation of RxJava based event bus to replace Otto event bus
The main idea behind event bus is that it can easily connect two objects/two classes that have different life cycles or a very different hierarchy. An event bus enables the direct connection of those two classes. We can have an event starting from class A notifying class B with the only mediator itself.
The app utilises the Otto library’s event bus implementation, which became deprecated for a while and thus, will not be maintained any more. The app also uses reactive components of RxJava and RxAndroid. Applying an event bus implementation based on these libraries would be a huge improvement.
Advantages of RxJava based event bus over Otto:
- Predefined methods for functionalities like subscribe and publish events are comparatively easier.
- The team can have more control over threading techniques.
- Various operators that can be used for data manipulation if needed.
Implementation details
Currently the app uses event-bus libraries like Otto, EventBus, startActivityForResult Intent etc for updating other fragments on behalf of the current job. This is now replaced by an event-bus(RxBus) This eventBus is based on RxJava/ ReactiveX/ RxAndroid libraries. With the help of this event bus our application can communicate efficiently with different objects and life cycles located at different layers of the hierarchy (see Issue and PR).
Goal 4: Replacement of the deprecated SQLBrite library
Currently the enviroCar-app uses SQLBrite library for semantics to queries. But it has been deprecated and archived and is no longer supported. This specific library dependency needs to be replaced with a newer library that follows the same implementation pattern and provides similar functionality.
The SQLBrite is a lightweight wrapper around SupportSQLiteOpenHelper and ContentResolver which introduces reactive stream semantics to queries. Its database features are now offered by SQLDelight. SQLBrite’s only responsibility is to be a mechanism for coordinating and composing the notification of updates to tables such that we can update queries as soon as the data changes.
SQLDelight has various features which were not offered by SQLBrite, such as:
- Comprehends existing SQL schema.
- Generates typesafe code and classes for any labelled SQL statements.
- Verifies schema, statements and migrations at compile-time.
- Makes refactoring and maintaining SQL much simple and easier.
- SQLDelight is better when dealing with multi-table databases.
Implementation details
I have replaced the deprecated SQLBrite library with SQLDelight library(See here) Followed the same implementation pattern as SQLBrite and replaced all references and usage with SQLDelight. SQLDelight generates typesafe kotlin APIs from your SQL statements. It verifies your schema, statements, and migrations at compile-time and provides IDE features like autocomplete and refactoring which make writing and maintaining SQL simple. (see Issue and PR).
Enhancement of the user interface and new functionalities
Apart from successfully achieving all of my specified and assigned goals for the GSOC 2022 period, I have worked on new features and functionalities and also fixed bugs to provide a better user experience in the enviroCar app (see Issues and PRs).
Some of my notable contributions are:
- Added different Currency Option in the Logbook (see issue and PR).
- Redesigned UI for Sign In and Sign Up activities (see issue and PR).
- Login/ Register button in LogBook section (see issue and PR).
- Swipe-to-Refresh in My Tracks section (see issue and PR).
- Locked Scrolling in Dashboard fragment (see issue and PR).
If you would like to know more about my Google Summer of Code 2022 work, please refer to my weekly reports, mid-term blog, introductory blog and GitHub-PRs.
Summary
For me, the GSOC 2022 was a fabulous learning experience. By contributing to the enviroCar app, I have learned a lot of things in this short stint in the various aspects of SDLC (software development lifecycle), such as:
- Working on in-depth library functionalities.
- Advanced debugging techniques.
- Identifying potential bugs/ features.
- Working on large codebase.
- Taking a new feature through the software development cycle.
- Implementing Agile development practices in real-time scenarios.
- Collaborating with the organization on steering the overall project.
We have worked and completed all the specified goals and objectives. This included upgrading most of the third party and open source libraries that have become outdated throughout the project. As a result, newer features and functionalities can be easily added seamlessly without any hassles in the future. I will continue to contribute to the enviroCar android app by implementing better features from a user’s point of view and will ship my current features to prod. I will also help maintain the GitHub repository and share my knowledge with new developers contributing to the app.
I would like to express my gratitude to Mr. Sai Karthikeya, who was my mentor during the GSOC 2022 period. He has helped me a lot in structuring my deliverables, reviewing my contributions and resolving any issues. I could not have asked for a better mentor. He was diligent and helped me improve my deliverables in such a way that it would create a larger impact to the team and the community. I would also like to thank Mr. Sebastian Drost and Mr. Benjamin Pross who helped me on initiating my contributions last year at enviroCar.
In the end, I want to thank 52°North for giving me this spectacular opportunity to spend my summer and contribute to the enviroCar project as part of Google Summer of Code 2022.
Gaurav Mishra says
I want to contribute in this project. I have knowledge of core Java and also know HTML, and CSS. It would give me an opportunity to learn new things as well as will contribute in development.
Rohit Rathore says
I want to contribute in this project. I have a knowledge about core java, Sql,Nosql Databse .
Eike says
Dear visitor,
we are welcoming everyone willing to contribute to our projects. There is no need to leave an according comment, just take a look at our contributors documentation and get in touch.
You are welcome!
Kind regards,
Eike
Gaurav Uniyal says
I want to contribute in this project. I have knowledge of core Java, C and also know HTML, and CSS. It would give me an opportunity to learn new things as well as will contribute in development.
Henning Bredel says
Dear visitor,
we are welcoming everyone willing to contribute to our projects. There is no need to leave an according comment, just take a look at our contributors documentation and get in touch.
You are welcome!
Kind regards