anticafe / SimpleWeather1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Weather app

  • The Android app to display 7 days weather forecast in a ListView.
  • Written in Kotlin.
  • Follow the Clean Architecture (Data - Domain - Presentation layers) with MVVM.
  • Weather data source: OpenWeatherMaps API.
  • Allow user to input the searching term (from 3 characters).
  • Caching mechanism: offline first (with cache expiry is 10 seconds in Debug mode, and 60 seconds in Release mode), then online later.
  • Support orientation change: keep the current search term & forecast result after rotating screen.
  • Error handling: Network issue (no network, timeout), Invalid city keyword, Invalid API key or exceed quota, When searching term is less than 3 characters.
  • Support the disability to scale large text.
  • Support the disability to read out the text using TalkBack controls.

TechStack

Languages

  • Kotlin
  • Groovy: Gradle (build.gradle)
  • YAML: Gradle Version Catalogs (libs.version.toml), Detekt (detekt.yml)

Libraries

  • Jetpack: LiveData, ViewModel, Lifecycle, Room, ViewBinding
  • Material Design, ConstraintLayout
  • Coroutines & Flow
  • Dagger Hilt
  • Retrofit, OkHttp, Gson.
  • hidden-secrets-gradle-plugin to hide the API key in the .so native lib.

Testing, formatting & analysis

How to build & run

  • Requires tools/SDK: Android Studio Dolphin | 2021.3.1, Android SDK API level 33 & NDK, Java 11.
  • To run the Detekt (static code analysis): ./gradlew detekt.
  • To view all the Spotless (code formatting) errors/warning: ./gradlew spotlessCheck.
  • To apply the Spotless fix automatically: ./gradlew spotlessApply.
  • To run Android Lint: ./gradlew app:lintDebug.
  • To run unit test: ./gradlew testDebugUnitTest.
  • To run instrumented test: ./gradlew connectedAndroidTest.
  • To check the out-of-date dependencies: ./gradlew dependencyUpdates -Drevision=release.

Project structure & diagram

Structure

| com.bmtriet.simpleweather

|---- data

|---- ---- local

|---- ---- ----- dao

|---- ---- ----- datasource

|---- ---- ----- entity

|---- ---- mapper

|---- ---- network

|---- ---- ----- datasource

|---- ---- ----- error

|---- ---- ----- interceptor

|---- ---- ----- response

|---- ---- ----- service

|---- ---- repository

|---- di

|---- domain

|---- ---- model

|---- ---- reposity-interface

|---- ---- usecase

|---- presentation

|---- ---- UI model

|---- ---- adapter + viewholder

|---- ---- home (Activity + Fragment + ViewModel)

|---- utils

Diagram

Database diagram

Checklist

  • Clean Architecture with MVVM.
  • Show the Weather Forecast in the ListView. Error handling as well as caching handling.
  • Secure the OpenWeatherMap API key (inside .so). There is no perfect solution to hide API key on the app side.
  • Testing: Unit + Instrumented.
  • Static code analysis.
  • Support accessibility (screen reader) with TalkBack
  • Support accessibility with TalkBack

Remaing things to do

Due to time constraint, I cannot finish these thing. It would be the improvement later.

  • Setup CI/CI workflow.
  • Modularization (at least 4 modules: data, domain, presentation, utils).
  • Try the Jetpack Compose as the replacement of XML layout.

About


Languages

Language:Kotlin 91.6%Language:C++ 7.8%Language:CMake 0.6%