Demo app, that helps you to be aware of earthquakes nearby. Based on data from http://earthquake.usgs.gov/
The app demonstrates principles of Clean Architecture in Android. You can read the original post from Uncle Bob or one of the first thoughts about it in Android. MVP pattern is used for the presentation layer.
- The main screen notifies users if there are any earthquakes with given from settings magnitude and distance from them. If there is more than one earthquake satisfying settings, only the closest one is shown.
- The settings screen gives a possibility to set maximal distance, to which we should show the alert and minimal magnitude needed to show the alert. Both of these parameters are used as filters for Earthquakes alert.
- The list of all earthquakes in the last day sorted by the distance from the user without filtering. It supports offline mode and will show cached data even in a case of lack of internet connection. If users click on an earthquake, a webpage with more details is opened through the default browser.
- Simple info screen, containing basic application info.
To show some of the nowadays Android developer toolkits and facilitate the development process, the project uses some libraries:
- Retrofit 2 is the #1 library for network calls at the moment.
- RxJava 2 brings the possibility to work with streams of data and helps to connect different Clean Architecture layers with each other.
- Dagger 2 helps to achieve Dependency Inversion principle through Dependency Injection mechanisms.
- Moxy helps to handle Android Activities and Fragments lifecycle so that you don't have to think about them in your views and presenters.
- RxPermissions helps to work with permissions directly from the business logic using usual Context and not a concrete Activity.
- Timber helps to create a different logic of logging depending on build types. In the example, we turn on the logging only in
debug
. - ObjectBox (beta) helps to store objects in a (more or less :) convenient way.
- MapStruct reduces the boilerplate needed to map one class to other.
- LeakCanary watches for memory leaks.
- (Branch
conductor
) Conductor provides a more convenient way to create Android View-based applications. - (Branch
conductor
) ButterKnife tries to reduce the boilerplate needed to inflate views.
There are some example tests of Interactors and Presenters that show how we can create local tests without instrumentation. These tests cover the most complex logic in the app.
In the example, we have two Dagger components regardless the fact that actually, their lifecycle in the application is the same. This was made for a demo purpose.
There are next features that may be made to do these example even more complete as a Clean Architecture example.
- Make logic of GPS permissions more complex and suggest user open Settings screen if there are problems with them.
- Add possibility to manually change the default location.
- Add Android Service or BroadcastListener that will check if there are new earthquakes alerts.
- In addition to 3, push a system notification about it.
- Show earthquakes on Google Map.
- Add filtering to the "All earthquakes" screen.