nowinandroid 一个完全由 Kotlin 和 Jetpack Compose 构建的功能完整的 Android 应用程序。它遵循 Android 设计和开发的最佳实践,旨在为开发者提供有用的参考。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Go to file
madroid 7c6a45eec1
Update ArchitectureLearningJourney.md
3 years ago
.github Update pull_request_template.md (#65) 3 years ago
.google Adds packaging data for AS samples (#2) 3 years ago
.idea/codeStyles Make code style default for project (#67) 3 years ago
app Merge pull request #56 from sud007/fix/nia-naming-convention 3 years ago
app-nia-catalog Fix Bug #41 3 years ago
benchmark Update baseline profile 3 years ago
build-logic Merge branch 'github/main' 3 years ago
core-common Catch exceptions in the flow.asResult method 3 years ago
core-data Rename NiaPreferencesLocalDataSource to NiaPreferencesDataSource 3 years ago
core-data-test Add common build convention for feature modules 3 years ago
core-database Merge pull request #56 from sud007/fix/nia-naming-convention 3 years ago
core-datastore Rename NiaPreferencesLocalDataSource to NiaPreferencesDataSource 3 years ago
core-datastore-test Add common build convention for feature modules 3 years ago
core-model remove suppress annotation prefix and add todo 3 years ago
core-navigation remove suppress annotation prefix and add todo 3 years ago
core-network Rename NiaNetwork & NiaPreferences, add DataSource suffix 3 years ago
core-testing Add common build convention for feature modules 3 years ago
core-ui Merge pull request #55 from SimonMarquis/fix/navigation-bar-item-ripple 3 years ago
docs Update ArchitectureLearningJourney.md 3 years ago
feature-author Merge branch 'github/main' 3 years ago
feature-foryou Use checked parameter instead of !isSelected (#50) 3 years ago
feature-interests Merge branch 'github/main' 3 years ago
feature-topic Add common build convention for feature modules 3 years ago
gradle Update Android Gradle Plugin 3 years ago
kokoro Add multi-column support for cards on the for you feed 3 years ago
scripts Add github-specific setup (#1) 3 years ago
spotless Configure spotless for kts and xml files 3 years ago
sync Rename NiaPreferencesLocalDataSource to NiaPreferencesDataSource 3 years ago
tools Make code style default for project (#67) 3 years ago
.gitignore Make code style default for project (#67) 3 years ago
CODE_OF_CONDUCT.md Add github-specific setup (#1) 3 years ago
CONTRIBUTING.md Fix markdown links in CONTRIBUTING.md 3 years ago
LICENSE Add initial app scaffolding 3 years ago
README.md Merge pull request #4 from SimonMarquis/patch-2 3 years ago
build.gradle.kts Add staging build variant, move staging URL out of source control 3 years ago
gradle.properties Build faster? 3 years ago
gradlew Replace buildSrc with version catalog 3 years ago
gradlew.bat Add initial app scaffolding 3 years ago
secrets.defaults.properties Add staging build variant, move staging URL out of source control 3 years ago
settings.gradle.kts Refactor navigation 3 years ago

README.md

Now in Android

Now in Android App [Work in progress 🚧]

This is the repository for the Now in Android app.

Now in Android is a fully functional Android app built entirely with Kotlin and Jetpack Compose. It follows Android design and development best practices and is intended to be a useful reference for developers. As a running app, it's intended to help developers keep up-to-date with the world of Android development by providing regular news updates.

The app is currently in early stage development and is not yet available on the Play Store.

Features

Now in Android displays content from the Now in Android series. Users can browse for links to recent videos, articles and other content. Users can also follow topics they are interested in or follow specific authors.

Screenshots

Screenshot showing For You screen Screenshot showing Interests screen Screenshot showing Topic detail screen

Development Environment

Now in Android uses the Gradle build system and can be imported directly into the latest stable version of Android Studio (available here). The debug build can be built and run using the default configuration.

Once you're up and running, you can refer to the learning journeys below to get a better understanding of which libraries and tools are being used, the reasoning behind the approaches to UI, testing, architecture and more, and how all of these different pieces of the project fit together to create a complete app.

NOTE: Building the app using an M1 Mac will require the use of Rosetta. See the following bug for more details.

Architecture

The Now in Android app follows the official architecture guidance and is described in detail in the architecture learning journey.

Build

The debug variant of app uses local data to allow immediate building and exploring the UI.

The staging and release variants of app make real network calls to a backend server, providing up-to-date data as new episodes of Now in Android are released. At this time, there is not a public backend available.

The benchmark variant of app is used to test startup performance and generate a baseline profile (see below for more information).

app-nia-catalog is a standalone app that displays the list of components that are stylized for Now in Android.

Testing

To facilitate testing of components, Now in Android uses dependency injection with Hilt.

Most data layer components are defined as interfaces. Then, concrete implementations (with various dependencies) are bound to provide those interfaces to other components in the app. In tests, Now in Android notably does not use any mocking libraries. Instead, the production implementations can be replaced with test doubles using Hilt's testing APIs (or via manual constructor injection for ViewModel tests).

These test doubles implement the same interface as the production implementations, and generally provide a simplified (but still realistic) implementation with additional testing hooks. This results in less brittle tests that may exercise more production code, instead of just verifying specific calls against mocks.

Examples:

  • In instrumentation tests, a temporary folder is used to store the user's preferences, which is wiped after reach test. This allows using the real DataStore and exercising all related code, instead of mocking the flow of data updates.

  • There are Test implementations of each repository, which implement the normal, full repository interface and also provide test-only hooks. ViewModel tests use these Test repositories, and thus can use the test-only hooks to manipulate the the state of the Test repository and verify the resulting behavior, instead of checking that specific repository methods were called.

UI

UI components are designed according to Material 3 guidelines and built entirely using Jetpack Compose.

The app has two themes:

  • Dynamic color - uses colors based on the user's current color theme (if supported)
  • Default theme - uses predefined colors when dynamic color is not supported

Each theme also supports dark mode.

The app uses adaptive layouts to support different screen sizes.

Find out more about the UI architecture here.

Baseline profiles

The baseline profile for this app is located at app/src/main/baseline-prof.txt. It contains rules that enable AOT compilation of the critical user path taken during app launch. For more information on baseline profiles, read this document.

Note: The baseline profile needs to be re-generated for release builds that touched code which changes app startup.

To generate the baseline profile, select the benchmark build variant and run the BaselineProfileGenerator benchmark test on an AOSP Android Emulator. Then copy the resulting baseline profile from the emulator to app/src/main/baseline-prof.txt.

License

Now in Android is distributed under the terms of the Apache License (Version 2.0). See the license for more information.