|
| 1 | +# Now in Android Project |
| 2 | + |
| 3 | +Now in Android is a native Android mobile application written in Kotlin. It provides regular news |
| 4 | +about Android development. Users can choose to follow topics, be notified when new content is |
| 5 | +available, and bookmark items. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +This project is a modern Android application that follows the official architecture guidance from Google. It is a reactive, single-activity app that uses the following: |
| 10 | + |
| 11 | +- **UI:** Built entirely with Jetpack Compose, including Material 3 components and adaptive layouts for different screen sizes. |
| 12 | +- **State Management:** Unidirectional Data Flow (UDF) is implemented using Kotlin Coroutines and `Flow`s. `ViewModel`s act as state holders, exposing UI state as streams of data. |
| 13 | +- **Dependency Injection:** Hilt is used for dependency injection throughout the app, simplifying the management of dependencies and improving testability. |
| 14 | +- **Navigation:** Navigation is handled by Jetpack Navigation 2 for Compose, allowing for a declarative and type-safe way to navigate between screens. |
| 15 | +- **Data:** The data layer is implemented using the repository pattern. |
| 16 | + - **Local Data:** Room and DataStore are used for local data persistence. |
| 17 | + - **Remote Data:** Retrofit and OkHttp are used for fetching data from the network. |
| 18 | +- **Background Processing:** WorkManager is used for deferrable background tasks. |
| 19 | + |
| 20 | +## Modules |
| 21 | + |
| 22 | +The main Android app lives in the `app/` folder. Feature modules live in `feature/` and core and shared modules in `core/`. |
| 23 | + |
| 24 | +## Commands to Build & Test |
| 25 | + |
| 26 | +The app and Android libraries have two product flavors: `demo` and `prod`, and two build types: `debug` and `release`. |
| 27 | + |
| 28 | +- Build: `./gradlew assemble{Variant}`. Typically `assembleDemoDebug`. |
| 29 | +- Fix linting/formatting: `./gradlew --init-script gradle/init.gradle.kts spotlessApply` |
| 30 | +- Run local tests: `./gradlew {variant}Test` |
| 31 | +- Run single test: `./gradlew {variant}Test --tests "com.example.myapp.MyTestClass"` |
| 32 | +- Run local screenshot tests: `./gradlew verifyRoborazziDemoDebug` |
| 33 | + |
| 34 | +### Instrumented tests |
| 35 | + |
| 36 | +- Gradle-managed devices to run on device tests: `./gradlew pixel6api31aospDebugAndroidTest`. Also `pixel4api30aospatdDebugAndroidTest` and `pixelcapi30aospatdDebugAndroidTest`. |
| 37 | + |
| 38 | +### Creating tests |
| 39 | + |
| 40 | +#### Instrumented tests |
| 41 | + |
| 42 | +- Tests for UI features should only use `ComposeTestRule` with a `ComponentActivity`. |
| 43 | +- Bigger tests live in the `:app` module and they can start activities like `MainActivity`. |
| 44 | + |
| 45 | +#### Local tests |
| 46 | + |
| 47 | +- [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) for most assertions |
| 48 | +- [cashapp/turbine](https://github.com/cashapp/turbine) for complex coroutine tests |
| 49 | +- [google/truth](https://github.com/google/truth) for assertions |
| 50 | + |
| 51 | +## Continuous integration |
| 52 | + |
| 53 | +- The workflows are defined in `.github/workflows/*.yaml` and they contain various checks. |
| 54 | +- Screenshot tests are generated by CI, so they shouldn't be checked into the repo from a workstation. |
| 55 | + |
| 56 | +## Version control and code location |
| 57 | + |
| 58 | +- The project uses git and is hosted in https://github.com/android/nowinandroid. |
0 commit comments