Skip to content

Near Earth Asteroids app is the second project in the Android Kotlin Nanodegree Program from Udacity.

Notifications You must be signed in to change notification settings

filipebezerra/near-earth-asteroids-app-android-kotlin

Repository files navigation

Near-Earth Asteroids App Project

Project Overview

Near-Earth Asteroids app is the second project in the Android Kotlin Nanodegree Program from Udacity, it showcases data related to Near-Earth objects provided para NeoWs API provided by Nasa APIs.

Also it showcases daily astronomy pictures of the day, also provided by Nasa APIs.

Project Specification

RecyclerView

CRITERIA MEETS SPECIFICATIONS
Create and reuse views in an Android app using RecyclerView The app displays a list of asteroids in the Main Screen by using a RecyclerView, when tapping an item the app opens Details screen.

Network

CRITERIA MEETS SPECIFICATIONS
Build an application that connects to an internet server to retrieve and display live data The asteroids displayed in the screens are downloaded from the NASA API
Use networking and image best practices to fetch data and images The NASA image of the day is displayed in the Main Screen

Database and Caching

CRITERIA MEETS SPECIFICATIONS
Create a database to store and access user data over time The app can save the downloaded asteroids in the database and then display them also from the database. The app filters asteroids from the past
Implement offline caching to allow users to interact with online content offline The app downloads the next 7 days asteroids and saves them in the database once a day using workManager with requirements of internet connection and device plugged in. The app can display saved asteroids from the database even if internet connection is not available

Accessibility

CRITERIA MEETS SPECIFICATIONS
Add talkback and push-button navigation to make an Android app accessible The app works correctly in talk back mode, it provides descriptions for all the texts and images: Asteroid images in details screen and image of the day. It also provides description for the details screen help button

Suggestions applied

  1. Modify the app to support multiple languages, device sizes and orientations.
    • Application supports language as English, Spanish and Portuguese/BR
    • Applications adapts its layout to landscape and portrait orientations accordingly
  2. Provide styles for the details screen subtitles and values to make it consistent, and make it look like in the designs.
    • Application applies theming, styling, typography and coloring from Materil Design best practices

Showcase

Live Running

Project reviews

Code Review

Libraries Used

  • Jetpack Foundation - Components for core system capabilities, Kotlin extensions and support for multidex and automated testing.
    • AppCompat - Degrade gracefully on older versions of Android.
    • Android KTX - Write more concise, idiomatic Kotlin code.
  • Architecture - A collection of libraries that help you design robust, testable, and maintainable apps. Start with classes for managing your UI component lifecycle and handling data persistence.
    • Data Binding - Declaratively bind observable data to UI elements.
    • Lifecycles - Create a UI that automatically responds to lifecycle events.
    • LiveData - Build data objects that notify views when the underlying database changes.
    • Navigation - Handle everything needed for in-app navigation.
    • Room - Access your app's SQLite database with in-app objects and compile-time checks.
    • ViewModel - Store UI-related data that isn't destroyed on app rotations. Easily schedule asynchronous tasks for optimal execution
    • WorkManager - Manage your Android background jobs.
  • UI - Details on why and how to use UI Components in your apps - together or separate
    • Fragment - A basic unit of composable UI.
    • Browser - Display webpages in the user's default browser
    • Constraintlayout - Position and size widgets in a flexible anf efficient way with relative positioning
    • Material Components for Android - Material Design toolkit to design and code high-quality digital experiences
  • Third party and miscellaneous libraries
    • Glide for image loading
    • Kotlin Coroutines for managing background threads with simplified code and reducing needs for callbacks
    • Retrofit 2 - A type-safe HTTP client for Android and Java
    • OkHttp 3 - OkHttp is an HTTP client that’s efficient by default:
      • HTTP/2 support allows all requests to the same host to share a socket.
      • Connection pooling reduces request latency (if HTTP/2 isn’t available).
      • Transparent GZIP shrinks download sizes.
      • Response caching avoids the network completely for repeat requests.
    • Moshi - Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects
    • Facebook Shimmer - An easy, flexible way to add a shimmering effect to any view in an Android app
    • Timber - A logger with a small, extensible API which provides utility on top of Android's normal Log class

Getting Started

Development Environment

The app is written entirely in Kotlin and uses the Gradle build system.

To build the app, use the gradlew build command or use "Import Project" in Android Studio.

Android Studio IDE setup

For development, the latest version of Android Studio is required. The latest version can be downloaded from here.

Architecture

The architecture is built around Android Architecture Components.

Near-Earth Asteroids follows the recommendations laid out in the Guide to App Architecture when deciding on the architecture for the app. We kept logic away from Activities and Fragments and moved it to ViewModels. We observed data using LiveData and used the Data Binding Library to bind UI components in layouts to the app's data sources.

Near-Earth Asteroids uses a Repository layer for handling data operations. Data comes from NASA API sources.

Near-Earth Asteroids uses Navigation component to simplify into a single Activity app.

Near-Earth Asteroids uses Room for persistance layer and ORM modelling.

Near-Earth Asteroids uses WorkManager to performance long-running tasks as such the initial dataset loading and daily fetches of new data available from NeoWs API.

Firebase

The app makes considerable use of the following Firebase components:

  • Firebase Crashlytics helps you track, prioritize, and fix stability issues that erode app quality, in realtime. Spend less time triaging and troubleshooting crashes and more time building app features that delight users.
  • Firebase Performance Monitoring to get insights into how your app performs from your users’ point of view, with automatic and customized performance tracing.

You need to create a Firebase account and setup Firebase in the project.

It's important to complete the configuration and add a Firebase configuration file, which is google-services.json into the module (app-level) directory of the app.

Nasa API key

Near-Earth Asteroids uses the Nasa APIs to load near earth Asteroid information and astronomy picture of the day. To use the API, you will need to obtain a free developer API key. See the Nasa API portal for instructions.

Once you have the key, add this line to the gradle.properties file, either in your user home directory (usually ~/.gradle/gradle.properties on Linux and Mac) or in the project's root folder:

nasa_api_key=<your NASA access key>

Bugsnag API Key

Near-Earth Asteroids uses the Bugsnag to monitors application stability so we can make data-driven decisions on whether we should be building new features, or fixing bugs. To use the API, you will need to obtain a free developer API key. See the Bugsnag site for instructions.

Once you have the key, add this line to the gradle.properties file, either in your user home directory (usually ~/.gradle/gradle.properties on Linux and Mac) or in the project's root folder:

bugsnag_api_key=<your Bugsnag access key>