Posted past times Shailen Tuli, DPE
Today we're releasing the source code for the official Google I/O 2018 for Android app.
The 2018 version constitutes a comprehensive rewrite of the app. For many years, the app has used a ContentProvider + SyncAdapter architecture. This year, nosotros rewrote the app using Architecture Components as well as brought the code inwards sync amongst the Android team's electrical current recommendations for edifice modern apps.
Architecture
We followed the recommendations position out inwards the Guide to App Architecture for writing modular, testable as well as maintainable code when deciding on the architecture for the app. We kept logic away from Activities as well as Fragments as well as moved it to ViewModels. We observed information using LiveData as well as used the Data Binding Library to bind UI components inwards layouts to the app's information sources.
The overall architecture of the app tin john move summarized inwards this diagram:
We used a Repository layer for treatment information operations. IOSched's information comes from a few dissimilar sources — user information is stored inwards Cloud Firestore (either remotely or inwards a local cache for offline use), user preferences as well as settings are stored inwards SharedPreferences, conference information is stored remotely as well as is fetched as well as stored inwards retention for the app to utilization — as well as the repository modules are responsible for treatment all information operations as well as abstracting the information sources from the residual of the app. If nosotros always wanted to swap out the Firestore backend for a dissimilar information source inwards the future, our architecture allows us to create as well as thence inwards a build clean way.
We implemented a lightweight domain layer, which sits betwixt the information layer as well as the presentation layer, as well as handles discrete pieces of concern logic off the UI thread. Examples.
We used Dagger2 for dependency injection as well as nosotros heavily relied on dagger-android to abstract away boilerplate code.
We used Espresso for basic instrumentation tests as well as JUnit as well as Mockito for unit of measurement testing.
Firebase
The utilization of Firebase technologies has grown inwards the app every bit the Firebase platform has matured. The 2018 version uses the next Firebase components:
- Cloud Firestore is our source for all user information (events starred or reserved past times a user). Firestore gave us automatic sync as well as besides seamlessly managed offline functionality for us.
- Firebase Cloud Functions allowed us to run backend code. The reservations characteristic heavily depended on Functions checking a user's condition (only attendees were allowed to build reservations), checking infinite availability as well as persisting reservation condition inwards Firestore.
- Firebase Cloud Messaging permit us inform the app virtually changes to conference information on our server. Conference information is mostly static, but it does alter from fourth dimension to time, specially afterwards the keynote. The app has traditionally used a ping-and-fetch model when working amongst conference data, as well as nosotros retained that usage this year.
- Remote Config helped us care in-app constants. In previous years, nosotros had constitute ourselves unable to inform users when information non straight related to the conference schedule — WiFi information, conference shuttle schedule, etc. — changed unexpectedly. Remote Config helped us update such values inwards a lightweight manner.
Kotlin
We made an early on determination to rewrite the app from scratch to pick out it inwards work amongst modern Android architecture. Using Kotlin for the rewrite was an slow choice: nosotros loved Kotlin's expressive, concise, as well as powerful syntax; nosotros constitute that Kotlin's back upward for security features including nullability as well as immutability made our code to a greater extent than resilient; as well as nosotros leveraged the enhanced functionality provided past times Android Ktx extensions.
Material Design
At I/O 2018, the Material Design squad announced Material Theming, giving apps much greater mightiness to customize Material Design to pick out to a greater extent than of their product's brand. As nosotros launched the app earlier Material Theming, nosotros couldn't utilization all of the novel components but nosotros managed to sneak a duet inwards similar the novel Bottom App Bar amongst inset Floating Action Button as well as nosotros were able to contain a lot of the conference's branding elements.
Future plans
The rewrite of the app brings the code inwards sync amongst Android's opinionated recommendations virtually edifice apps, as well as it resulted inwards a cleaner, to a greater extent than maintainable codebase. We'll proceed working on the app, incorporating JetPack components every bit they choke available as well as finding opportunities to showcase platform features that are expert fits for the app. Developers tin john follow changes to the code on GitHub.