-
-
Notifications
You must be signed in to change notification settings - Fork 538
About the app module
SuperDragonXD edited this page Apr 2, 2026
·
4 revisions
The app module is the heart of the Lawnicons Android application. It's where you'll find the code for the user interface, application logic, and data management. We've structured this module using Modern Android Development (MAD) principles to promote clarity and maintainability.
The app module primarily follows an architecture similar to Model-View-ViewModel (MVVM). This pattern separates concerns into distinct layers:
flowchart LR
UI["UI Layer<br/>(Jetpack Compose:<br/>Screens & Components)"]
VM["ViewModel Layer<br/>(Business Logic & UI State)"]
REPO["Data Layer<br/>(Repositories & Data Abstraction)"]
DATA["Data Sources<br/>(Local XML/Assets/Prefs,<br/>Remote APIs via Retrofit)"]
DATA --> REPO
REPO --> VM
VM --> UI
- UI Layer: Built with Jetpack Compose. This layer is responsible for displaying data to the user and capturing user input. For more details, see UI Layer (Compose).
- ViewModel Layer: Manages UI-related state and contains the business logic. ViewModels react to user events and interact with Repositories to fetch or update data. Dive deeper in ViewModel & State Management.
- Data Layer (Repositories): This layer abstracts the underlying data sources (like local files, SharedPreferences, or remote APIs). Repositories provide a clean API for ViewModels to access data, often using Kotlin Flow for reactive updates. Explore this in Data Layer & Repositories.
- Dependency Injection: We use Metro to manage dependencies between these layers, making the code more modular and easier to test. Learn more at Dependency Injection (Metro).
Here's a breakdown of the main packages within the app module (app/src/main/kotlin/app/lawnchair/lawnicons/) and what they do:
-
Root package (
app.lawnchair.lawnicons)-
MainActivity.kt: The app's single entry point (Activity). It sets up Jetpack Compose, determines screen size, and handles intents likeICON_PICKER_INTENT_ACTION. -
LawniconsApplication.kt: The customApplicationclass. Initializes Metro by creating theLawniconsGraphviacreateGraphFactory<LawniconsGraph.Factory>(). -
LawniconsGraph.kt: The Metro dependency graph, annotated with@DependencyGraph(LawniconsScope::class). ImplementsViewModelGraphand exposes theMetroViewModelFactoryImpl.
-
-
data/api/- Contains Retrofit interfaces that define how the app communicates with external web services:
GitHubContributorsAPI,IconRequestSettingsAPI, andAnnouncementsAPI.
- Contains Retrofit interfaces that define how the app communicates with external web services:
-
data/model/- Defines Kotlin
data classes (for example,IconInfo,GitHubContributor,Announcement,IconRequestModel). These classes represent the data structures used throughout the app. Many are marked@Serializablefor use with Kotlinx Serialization.
- Defines Kotlin
-
data/repository/- Contains concrete implementations of the Repository pattern, each annotated with
@ContributesBinding(LawniconsScope::class)to automatically bind to their interfaces. -
home/:IconRepository(icon loading & search),AnnouncementsRepository(home screen announcements),GetIconInfo.kt(XML parsing helper). -
iconrequest/:IconRequestRepository(unthemed app detection),IconRequestHandler(request flow logic),GetSystemPackageList.kt,AdaptiveIconBitmap.kt. - Root level:
NewIconsRepository(new icons diff),OssLibraryRepository(open-source licenses),GitHubContributorsRepository(GitHub API),PreferenceManager.kt(SharedPreferences wrapper).
- Contains concrete implementations of the Repository pattern, each annotated with
-
di/- Houses Metro module interfaces that provide dependencies not available via constructor injection:
-
GithubApiModule.kt: ProvidesGitHubContributorsAPI(Retrofit service forhttps://api.github.com/). -
WebsiteApiModule.kt: ProvidesIconRequestSettingsAPI,AnnouncementsAPI, and a sharedOkHttpClientwith caching. -
PreferencesModule.kt: Provides preference-related dependencies. -
MetroViewModelFactoryImpl.kt: TheMetroViewModelFactoryimplementation, populated by Metro's@ContributesIntoMapViewModel map.
-
ui/- Holds all Jetpack Compose UI code.
-
Lawnicons.kt: The root Composable containing theNavDisplaywhich manages navigation between screens using Navigation3. -
NavigationState.kt: Custom back-stack state holder withrememberNavigationState()andNavigationState.toEntries(). -
Navigator.kt: Handles forward navigation and back actions by updating theNavigationState. -
theme/: Defines the app's visual appearance, includingLawniconsTheme.kt(Material 3 Expressive, dynamic colors, contrast modes) andLawniconsColor.kt. -
components/: Reusable UI elements.core/has generic components (likeLawniconsScaffold.kt,SimpleListRow.kt), while other subpackages have feature-specific ones. -
destination/: Each feature has its own subpackage containing both the screen Composable and its ViewModel:-
home/:Home.kt(home screen),HomeViewModel.kt(icon list, search, announcements). -
about/:About.kt(about screen). -
contributors/:Contributors.kt,ContributorsViewModel.kt. -
acknowledgements/:Acknowledgements.kt,AcknowledgementsViewModel.kt. -
newicons/:NewIcons.kt,NewIconsViewModel.kt. -
iconrequest/:IconRequest.kt,IconRequestViewModel.kt. -
debugmenu/:DebugMenu.kt,DebugMenuViewModel.kt.
-
-
util/: Helper functions and constants (Constants.kt,PreviewUtils.kt).
Found an issue or have a suggestion for this wiki? Please let us know!
- Home
- Getting started
- Architecture
- Key Feature Explanations
- Troubleshooting for Developers
- Project Glossary