Libbra
A currency tracker app demonstration. It refreshes currency list every single second based on the main currency. In addition to that, main currency is selectable.
Install / Use
/learn @nuhkoca/LibbraREADME
Libbra
<p align="center"><img src="art/preview.png" alt="Libbra Preview" height="800"></p>Libbra is a sample app that allows to track currency exchanges. This app presents modern approach to Android application development using Kotlin and latest tech-stack.
This project is a hiring task by Revolut. The goal of the project is to demonstrate best practices, provide a set of guidelines, and present modern Android application architecture that is modular, scalable, maintainable and testable. This application may look simple, but it has all of these small details that will set the rock-solid foundation of the larger app suitable for bigger teams and long application lifecycle management.
Table of Contents
Development
Environment setup
First off, you require the latest Android Studio 3.6.0 (or newer) to be able to build the app.
Moreover, to sign your app for release, please refer to keystore.properties to find required fields.
# Signing Config
signing.store.password=<look>
signing.key.password=<look>
signing.key.alias=<look>
signing.store.file=<look>
Code style
To maintain the style and quality of the code, are used the bellow static analysis tools. All of them use properly configuration and you find them in the project root directory .{toolName}.
| Tools | Config file | Check command | Fix command |
|---------------------------------------------------------|----------------------------------------------------------------------------------:|---------------------------|---------------------------|
| detekt | default-detekt-config | ./gradlew detekt | - |
| ktlint | - | ./gradlew ktlintCheck | ./gradlew ktlintFormat |
| spotless | /spotless | ./gradlew spotlessCheck | ./gradlew spotlessApply |
| lint | /.lint | ./gradlew lint | - |
All these tools are integrated in pre-commit git hook, in order ensure that all static analysis and tests passes before you can commit your changes. To skip them for specific commit add this option at your git command:
git commit --no-verify
The pre-commit git hooks have exactly the same checks as Github Actions and are defined in this script. This step ensures that all commits comply with the established rules. However the continuous integration will ultimately be validated that the changes are correct.
Design
App support different screen sizes and the content has been adapted to fit for mobile devices and tablets. To do that, it has been created a flexible layout using one or more of the following concepts:
- Use constraintLayout
- Avoid hard-coded layout sizes
- Create alternative layouts
- Use the smallest width qualifier
- Use the available width qualifier
- Add orientation qualifiers
In terms of design has been followed recommendations android material design comprehensive guide for visual, motion, and interaction design across platforms and devices. Granting the project in this way a great user experience (UX) and user interface (UI). For more info about UX best practices visit link.
Moreover, has been implemented support for dark theme with the following benefits:
- Can reduce power usage by a significant amount (depending on the device’s screen technology).
- Improves visibility for users with low vision and those who are sensitive to bright light.
- Makes it easier for anyone to use a device in a low-light environment.
| Page | Light Mode | Dark Mode | |-------|---------------------------------------------------|------------------------------------------| | Currency | <img src="art/light_mode.png" width="300"> |<img src="art/dark_mode.png" width="300"> |
Architecture
The architecture of the application is based, apply and strictly complies with each of the following 5 points:
- A single-activity architecture, using the Navigation component to manage fragment operations.
- Android architecture components, part of Android Jetpack for give to project a robust design, testable and maintainable.
- Pattern Model-View-ViewModel (MVVM) facilitating a separation of development of the graphical user interface.
- S.O.L.I.D design principles intended to make software designs more understandable, flexible and maintainable.
- Modular app architecture allows to be developed features in isolation, independently from other features.
Modules
Modules are collection of source files and build settings that allow you to divide a project into discrete units of functionality. In this case apart from dividing by functionality/responsibility, existing the following dependence between them:
The above graph shows the app modularisation:
:appdepends on:rules.:rulesdepends on nothing.
App module
The :app module is an com.android.application, which is needed to create the app bundle. It is also responsible for initiating the dependency graph and another project global libraries, differentiating especially between different app environments.
Rules modules
The :rules module is an com.android.library, basically contains lint checks for the entire project.
Architecture components
Ideally, ViewModels shouldn’t know anything about Android. This improves testability, leak safety and modularity. ViewModels have different scopes than activities or fragments. While a ViewModel is alive and running, an activity can be in any of its lifecycle states. Activities and fragments can be destroyed and created again while the ViewModel is unaware.
Passing a reference of the View (activity or fragment) to the ViewModel is a serious risk. Lets assume the ViewModel requests data from the network and the data comes back some time later. At that moment, the View reference might be destroyed or might be an old activity that is no longer visible, generating a memory leak and, possibly, a crash.
<img src="art/design_pattern.png">The communication between the different layers follow the above diagram using the reactive paradigm, observing changes on components without need of callbacks avoiding leaks and edge cases related with them.
Tech-stack
This project takes advantage of many popular libraries, plugins and tools of the Android ecosystem. Most of the libraries are in the stable version, unless there is a good reason to use non-stable dependency.
Dependencies
- Jetpack:
- Android KTX - provide concise, idiomatic Kotlin to Jetpack and Android platform APIs.
- [AndroidX](https://dev
