Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / CONTRIBUTING.md

CONTRIBUTING.md26.8 KiBRenderedCodeRaw
1# Contributing
2
3Modern Apps is a monorepo of ~57 Android apps sharing one design system and a set of common
4library modules. See [README.md](README.md) for what the project is and the list of apps.
5
6This document is the rulebook: the conventions the code follows, which of them are enforced
7mechanically, and how to run those checks yourself.
8
9---
10
11## Before you start
12
13- **If you are implementing a feature, open an issue first** so you don't waste time on a
14 feature that won't be included.
15- **Include photos demonstrating your code works.** Not needed if the change is short
16 (<10 lines) or common sense is proof enough.
17- **AI code is allowed** generally, as long as you have demonstrated that your code works.
18- **AI is not allowed for translations**, and neither is any translation software like
19 Google Translate.
20
21---
22
23## Getting set up
24
25| Requirement | Version | Notes |
26| :--- | :--- | :--- |
27| JDK | 21 | The PR check still runs 17; the release build runs 21 |
28| Android SDK | compileSdk 37 | `minSdk 31`, `targetSdk 37` |
29| NDK | 29.0.14206865 | Only needed for modules with Rust |
30| Rust | 1.97.0 | Pinned in `rust-toolchain.toml`; target `aarch64-linux-android` |
31
32Point `local.properties` at your SDK. Apps build **arm64-only** by default.
33
34**Gradle memory.** `gradle.properties` defaults to a small daemon heap (`-Xmx8g`,
35`-Xms512m`, 2 workers) sized for scoped `:module:` builds — the thing agents and
36day-to-day dev actually run. `./install all` auto-escalates to the big heap for
37the full ~100-module build, so don't raise the default. If your machine needs
38different values, override them for your machine in
39`~/.gradle/gradle.properties` (which takes precedence), the way CI does:
40
41```properties
42org.gradle.jvmargs=-Xmx6144m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC
43org.gradle.workers.max=2
44```
45
46**The configuration cache is on repo-wide.** Any build logic you add must be
47configuration-cache compatible — resolve `File`s at configuration time and don't capture
48script objects in a task action.
49
50### Building and installing
51
52```bash
53./install voxels # ./gradlew :games:voxels:installDev
54./install release calculator # release variant
55./install all # every app module
56```
57
58`./install` accepts slash or colon paths (`games/voxels` == `games:voxels`) and auto-prefixes
59game shorthands. All repo scripts (`install`, `dhu`, `search`, `analyze`) are bash-only —
60run them from git-bash on Windows.
61
62**There is no `debug` build type.** Only `dev` and `release` exist — `debug` variants are
63disabled in the app convention. `dev` is `release` with minification off and
64`isDebuggable = true`, and `testBuildType = "dev"`. Every app gets `BuildConfig.DEV_BUILD`;
65gate experimental work on it so R8 strips it from release builds.
66
67---
68
69## What is actually enforced
70
71Mind the gap between intent and enforcement. Most rules below are declared `Severity.ERROR`,
72but the app convention demotes them to `warning`, so they are **reported, not blocking**. Only
73the two rules listed as `fatal` can fail a build.
74
75| Check | Blocks? | Where |
76| :--- | :--- | :--- |
77| `./gradlew :compileDevKotlin` | **Yes** | The only automated PR gate |
78| `./gradlew checkMetadata` | **Yes** | First step of the release workflow |
79| `ToastUsage` lint | **Yes** (`fatal`) | Local `./gradlew lint` only — CI builds with `-x lint` |
80| `DirectComposeAnimation` lint | **Yes** (`fatal`) | Local `./gradlew lint` only — CI builds with `-x lint` |
81| The other 6 custom lint rules | No | Reported by `./gradlew lint` |
82| `scripts/*.sh` audits | No | Manual only |
83| Unit tests | No | CI builds with `-x test` |
84
85**CI only checks that the code compiles.** Everything else is on you. Run this before pushing:
86
87```bash
88./gradlew :compileDevKotlin # what CI will run
89./gradlew lint # ToastUsage is fatal, the rest advisory
90./gradlew checkMetadata # enforced at release time
91bash scripts/lint_hardcoded_strings.sh
92bash scripts/check_preview_metadata.sh
93bash scripts/lint_rust_length.sh # Rust files over 500 lines, advisory
94```
95
96Treat the advisory rules as mandatory for code you write or touch. Older modules predate them
97and are being migrated; a violation you can see in `maps/util/` is not permission to add
98another.
99
100---
101
102## Adding a new app
103
1041. Create the module directory (nested is fine: `games/<name>`).
1052. `include(":<name>")` in `settings.gradle.kts`.
1063. Apply the convention plugin and declare only what is yours:
107
108```kotlin
109plugins {
110 id("common-conventions-app")
111 id("common-conventions-preview-metadata") // if the listing uses Compose previews
112}
113
114launcherIcon {
115 symbol = "calculate" // a Material Symbols name; required
116}
117
118android {
119 defaultConfig {
120 applicationId = "com.vayunmathur.calculator"
121 }
122}
123
124dependencies {
125 implementation(project(":library:network"))
126}
127```
128
1294. Add `metadata_data/<module-key>.md` (see [Store metadata](#store-metadata)).
1305. Add the app to the three hardcoded lists that nothing validates:
131 `.github/workflows/issue_labeler.yml` (`validApps`),
132 `.github/ISSUE_TEMPLATE/bug_report.yml`, and `.github/ISSUE_TEMPLATE/feature_request.yml`.
1336. Add it to the table in `README.md`.
134
135**The module key** is the Gradle path with `/` replaced by `-`, so `games/voxels` →
136`games-voxels`. It is used for the metadata filename and the screenshot directory.
137
138**`applicationId` is the only identity you declare.** `namespace` is derived as
139`com.vayunmathur<gradle path>`, so the package follows the module path and cannot be chosen
140independently.
141
142### What the convention already gives you
143
144Don't redeclare: `compileSdk`, `minSdk`, `targetSdk`, `ndkVersion`, `namespace`,
145`versionCode`/`versionName` (both read from `version.txt`), signing, build types, Compose
146setup, locale config, or reproducible-archive settings. You automatically get `:library`,
147`:library:ui`, `:lint-rules`, Compose BOM, lifecycle, serialization and `kotlin-test`.
148
149**Material 3 is deliberately not a direct dependency.** Consume Material only through
150`:library:ui`, which re-exports it via `api`. Do not add `androidx.compose.material3` to an
151app module.
152
153**Launcher icons are generated, not committed.** `launcherIcon { symbol = "..." }` downloads
154the Material Symbol at a pinned commit and generates the foreground and adaptive-icon XML. Do
155not add `ic_launcher_foreground.xml` or mipmap PNGs.
156
157---
158
159## Module layout
160
161Every file's package must be `com.vayunmathur.<app>.<root>`, where `<root>` is one of exactly
162these 13:
163
164```
165ui data domain platform network intents service
166provider widget notifications auth sync telephony
167```
168
169| Root | Holds |
170| :--- | :--- |
171| `ui/` | Screens and composables; `ui/components/`, `ui/dialogs/` |
172| `data/` | Entities, Room databases, repositories, stores, preferences |
173| `domain/` | Pure logic — no Android, no Compose |
174| `platform/` | ViewModels, Workers, framework glue, backup agents |
175| `network/` | HTTP and protocol clients |
176| `service/` | `Service` subclasses |
177| `provider/` | `ContentProvider`s |
178| `intents/` | Cross-app IPC entry points |
179| `widget/` | App widgets and Glance |
180| `notifications/`, `auth/`, `sync/`, `telephony/` | Narrower, for the apps that need them |
181
182**`util/` is not a root.** It is the thing being migrated away from — several older modules
183still have one. Split it:
184
185| Instead of | Use |
186| :--- | :--- |
187| `util` | `domain/` (pure logic) or `platform/` (Android glue) |
188| `api` | `network/` |
189| `model` | `data/` |
190| `viewmodel` | `platform/` |
191| `ipc` | `intents/` |
192| `glance` | `widget/glance/` |
193| `crypto`, `format`, `syntax` | `domain/…` |
194| `imap`, `smtp`, `remote` | `network/…` |
195| `saf`, `sink` | `data/…` |
196| `ime`, `tts` | `platform/…` |
197| `composer` | `ui/composer/` |
198
199### The app root package is a closed set of four files
200
201A file directly in `com.vayunmathur.<app>` may only be:
202
203| File | Contract |
204| :--- | :--- |
205| `MainActivity.kt` | Only `class MainActivity : ComponentActivity()` — no top-level functions, vals, or composables |
206| `Route.kt` | Only `sealed interface Route : NavKey` plus its nested route objects |
207| `Navigation.kt` | Only `@Composable fun Navigation(...)` |
208| `*Application.kt` | Only the `Application` subclass, named the same as the file |
209
210Anything else belongs in a folder. `backup/` is the reference module — it satisfies every rule;
211`notes/` is a close second and also demonstrates `intents/`.
212
213Shared modules (`com.vayunmathur.library`, `.e2ee`, `.sdk`, `.cast.protocol`, `.games`,
214`.tools`, `.personal`) are exempt from this rule and from one-composable-per-file.
215
216**JNI escape hatch.** A class whose fully-qualified name is frozen by `RegisterNatives` can
217opt out with this exact comment anywhere in the file:
218
219```kotlin
220// PACKAGE STRUCTURE EXCEPTION (JNI)
221```
222
223---
224
225## Compose
226
227### One public composable per file
228
229Exactly one **public, top-level** `@Composable` per file, named the same as the file.
230Overloads of that composable and any number of `private`/`internal` helpers may share it. A
231second differently-named public composable goes in its own file under `ui/`,
232`ui/components/`, or `ui/dialogs/`.
233
234### Never use a raw `Scaffold`
235
236Not `androidx.compose.material3.Scaffold`, and not the thin `com.vayunmathur.library.ui.Scaffold`
237wrapper. Use one of the shared scaffolds from `:library:ui`, which own window insets and
238content padding once so screens don't re-derive padding by hand:
239
240`AppScaffold` · `DetailScaffold` · `DetailLazyColumn` · `ListPage` · `LazyListScaffold` ·
241`TabbedPagerScaffold` · `TopAppBarOverlay` (full-bleed)
242
243`AppScaffold` requires `scrollBehavior` rather than defaulting it, so every screen states how
244its bar reacts to scrolling, and it hands `PaddingValues` to its content instead of applying
245them, so lists can scroll under the bars.
246
247Per-file opt-out, when a screen genuinely needs its own:
248
249```kotlin
250// RAW SCAFFOLD EXCEPTION: <reason>
251```
252
253### Insets belong to the host
254
255Do not call `imePadding()`, `navigationBarsPadding()` or `systemBarsPadding()` in a reusable
256component under `com.vayunmathur.library.ui`. `MainNavigation` applies the IME inset once for
257every screen it hosts, and a standalone Activity applies it once at its root scaffold. A
258component that also applies one makes it count twice. App screens are free to apply insets —
259the rule is scoped to the shared UI library.
260
261### Theme
262
263Every app wraps its content in `DynamicTheme { }` from `:library:ui`. Material You is
264unconditional — there is no static fallback palette and no per-app brand colour, which is what
265`minSdk 31` buys. It uses `MaterialExpressiveTheme`, so **read corner radii from
266`MaterialTheme.shapes`** rather than writing `RoundedCornerShape(12.dp)` at the call site.
267Shapes, typography and motion are deliberately not overridden.
268
269Pass `darkTheme` explicitly only if the app has its own light/dark/auto setting; `null` follows
270the system.
271
272### Icons
273
274Every icon is a function in `library/ui/.../Icons.kt`. **Never import
275`androidx.compose.material.icons.*`, and never call `Icon()` or `painterResource()` from an app
276module** — `Icons.kt` is the one place allowed to.
277
278```kotlin
279@Composable
280fun IconAdd(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =
281 AppIcon(Icons.Filled.Add, "Add", modifier, tint)
282```
283
284The indirection exists because it makes two correctness properties automatic: a non-null
285`contentDescription` is baked in so accessibility can't be forgotten, and directional icons use
286`Icons.AutoMirrored.*` so RTL is handled centrally.
287
288To add one: check the ~450 that already exist, then add a three-line `IconXxx` in the right
289`// --- section ---` with the identical signature. **Name it for what it means here, not for
290the upstream glyph** — `IconMine` is `Brightness7`, `IconEraser` is `Backspace`. If Material has
291no suitable glyph, put a 24dp vector in `library`'s res and wrap `painterResource` the same way.
292
293### Never use `Toast`
294
295This is one of two lint rules marked `fatal`. Toasts render outside the app's Material
296surface, ignore the theme, can't carry an action, and are silently suppressed when the app is
297backgrounded on Android 12+ — so the case people reach for a Toast in, reporting from
298background work, is the case where it may never appear.
299
300```kotlin
301rememberMessenger().show(...) // inside a composable
302AppMessages.show(...) // from a ViewModel, Worker, or Activity
303```
304
305Use a notification when the message has to outlive the current screen.
306
307Per-file opt-out, for a UI-less component with no scaffold collecting `AppMessages` — a
308notification trampoline that finishes immediately, for instance:
309
310```kotlin
311// TOAST EXCEPTION: <reason>
312```
313
314### Never animate directly with `androidx.compose.animation`
315
316The other `fatal` rule, `DirectComposeAnimation`. Motion written at a call site carries no
317intent: the same interaction picks up a different duration and curve on each screen, and a spec
318written with no arguments silently takes Compose's own default instead of the motion scheme the
319app is themed with. Reach for the helper that names the interaction:
320
321| Instead of | Use | From |
322| :--- | :--- | :--- |
323| `animateDpAsState` / `animateFloatAsState` / `animateColorAsState` | `animatedDp` / `animatedFloat` / `animatedColor` | `library.ui` |
324| `AnimatedVisibility` + `fadeIn`/`scaleIn`/`expandVertically` | `FadeVisibility` / `PopVisibility` / `ExpandVisibility` / `BannerVisibility` | `library.ui` |
325| `AnimatedContent` | `SwappedContent` / `SwappedTopBar` | `library.ui` |
326| `Modifier.animateItem(...)` | `itemMotion()` | `library.ui` |
327| a press-shape `animateIntAsState` | `pressedShape(pressed)` | `library.ui` |
328| a hand-rolled entrance | `Modifier.staggeredEntrance(index, arriving)` | `library.ui` |
329| a shared element across a nav change | `sharedText` / `sharedContainer` / `sharedCrop` / `SharedEditableText` / `MorphPage()` | `library.util` |
330| a card that becomes a much bigger thing | `sharedCrop` — crops its contents instead of reflowing (`sharedContainer`) or scaling (`sharedText`) them | `library.util` |
331| a hand-rolled exit for chrome the user navigates away from | `Modifier.dropsAway()` / `Modifier.sinksBelow()` / `Modifier.expandFromLine()` | `library.util` |
332
333Imperative one-off motion on `androidx.compose.animation.core.Animatable` is **not** flagged — a
334game board wave or a camera capture flash is genuinely bespoke, and wrapping it would be a
335passthrough that names nothing. `com.vayunmathur.library.*` is exempt because the helpers are
336built there, and `com.vayunmathur.launcher.*` is exempt because its home screen is built on
337`animateBounds` and `Animatable`. Anything else that genuinely needs the raw API opts out per
338file with the exact marker:
339
340```kotlin
341// RAW ANIMATION EXCEPTION: <reason>
342```
343
344### Screens are stateless; a binder wires the ViewModel
345
346A `*UiContract.kt` next to the ViewModel in `platform/` declares the state and callbacks. The
347`*Screen` composable is stateless and takes that state. A thin `*Page` composable collects
348from the ViewModel and calls the screen. This is what lets `intents/` entry points and
349screenshot previews reuse a screen with literal state.
350
351---
352
353## Data and storage
354
355**Room 3 only.** The literal string `androidx.room.` is flagged — including in comments and
356KDoc — because Room 3 dropped the `SupportSQLite` API that Room 2's `openHelperFactory(...)`
357depended on, and SQLCipher is wired through `setDriver(SQLCipherDriver(...))` instead. Three
358renames you will hit:
359
360- `@TypeConverter` / `@TypeConverters` → `@ColumnTypeConverter` / `@ColumnTypeConverters`
361- `withTransaction { }` → `withWriteTransaction { }` or `withReadTransaction { }`
362- `Migration.migrate` now takes a suspending `androidx.sqlite.SQLiteConnection`
363
364Room 2 staying on the runtime classpath via `androidx.work:work-runtime` is expected and must
365not be excluded — WorkManager needs it.
366
367**Never call `buildDatabase(...)` directly.** Subclass
368`com.vayunmathur.library.room.RoomRepository<DB>` and expose DAOs, Flows and suspend
369operations from it, then get that repository as a process-wide singleton from Activities,
370Services, Workers, Receivers, widgets and assistant intents. Building the database at each call
371site scatters construction, duplicates DAO holders, and risks leaking a component `Context`
372into a long-lived database.
373
374Opting in:
375
376```kotlin
377plugins { alias(libs.plugins.ksp) }
378
379dependencies {
380 implementRoom(libs)
381 implementation(project(":library:room"))
382}
383```
384
385Schemas are committed under `<module>/schemas/`.
386
387---
388
389## Networking
390
391Go through `com.vayunmathur.library.network.NetworkClient` rather than raw OkHttp, Retrofit or
392`HttpURLConnection`. Depend on `:library:network`, declare `android.permission.INTERNET`, and
393initialise once in `MainActivity`:
394
395```kotlin
396NetworkClient.init(this, TrustBundle.FIRST_PARTY)
397```
398
399TLS validates against a bundle of pinned roots shipped in `library/network/src/main/assets/ca/`,
400not the system store. Pick the narrowest `TrustBundle` that covers your hosts —
401`FIRST_PARTY`, `STANDARD`, `EXTENDED`, or `SYSTEM` for user-supplied hosts (VPN,
402custom mail servers, the browser).
403
404Note that `:library:map`, `:library:image` and `:library:downloadservice` declare `INTERNET`
405themselves, so depending on one gives your app network access through manifest merge. Account
406for that in your store metadata.
407
408Per-app protocol code lives in `network/`; the transport comes from the library.
409
410---
411
412## Cross-app IPC
413
414Apps expose data to their siblings through a signature-level permission and an invisible
415activity, so only APKs signed with the same key can call in:
416
417```xml
418<permission
419 android:name="com.vayunmathur.notes.permissions.ACCESS_NOTES"
420 android:protectionLevel="signature" />
421
422<activity android:name=".intents.GetIntent"
423 android:exported="true"
424 android:theme="@android:style/Theme.NoDisplay"
425 android:permission="com.vayunmathur.notes.permissions.ACCESS_NOTES" />
426```
427
428The endpoint subclasses `AssistantIntent<In, Out>` from `:library` and overrides one method:
429
430```kotlin
431class GetIntent : AssistantIntent<Unit, List<NoteData>>(
432 Unit.serializer(), ListSerializer(NoteData.serializer())
433) {
434 override suspend fun performCalculation(input: Unit): List<NoteData> =
435 NotesRepository.get(this).getAll().map { NoteData(it.title, it.content) }
436}
437```
438
439The wire DTO lives in `:library` (`com.vayunmathur.library.intents.<app>.<Dto>`) so both sides
440compile against the same type and no one hand-parses anything. Serializers are passed
441explicitly because generics are erased. On the consumer side the convention is
442`<Thing>Client.kt` plus `<Thing>Protocol.kt`.
443
444This is how MA OpenAssistant's tool calling reaches other apps. Games report achievements to
445MA GameHub through a `ContentProvider` instead, via `:sdk:games`.
446
447---
448
449## Strings and translations
450
451**No hardcoded user-visible text.** Everything goes in `res/values/strings.xml` and is read
452with `stringResource(R.string.x)` or `getString(...)`. This covers `Text("…")`,
453`label = { Text("…") }`, `placeholder = { Text("…") }`, and — despite a stale comment in the
454script — `contentDescription`.
455
456**Use `<plurals>`, never string-gluing.** `if (n == 1) "" else "s"` is a violation; the
457one-versus-many split is language-specific.
458
459Decorative single characters (`×`, `→`, `⌫`, …) and interpolation-only strings are exempt.
460Adding a new symbol means editing the allow-list in `scripts/filter_text.py`.
461
462Write a translator-facing comment above each string naming the screen, the widget and the
463surrounding format.
464
465**Translations happen on [Weblate](https://hosted.weblate.org/projects/modern-apps/), not in
466PRs.** Add only `values/strings.xml`; Weblate owns every `values-<lang>/strings.xml`. Empty
467per-locale skeletons are normal, which is why `MissingTranslation` is disabled. Translations
468may not even be included in a PR that adds new strings, due to the way Weblate is set up.
469
470After pulling Weblate translations, run `./gradlew fixStrings` — it repairs contributions where
471`<xliff:g>` markup was escaped and would otherwise render literally in the UI.
472
473Logging goes through `android.util.Log`. Timber is not a dependency and adding one to satisfy a
474lint check would be the wrong way round.
475
476---
477
478## Store metadata
479
480Every app module needs a `metadata_data/<module-key>.md`. Line 1 is the store short
481description and the whole file is the full description, so the
482format is strict and `./gradlew checkMetadata` enforces it both ways — a missing file and an
483orphaned file are both errors.
484
485```
486A modern, open-source calculator with a graphing engine
487
488Features:
489- Scientific and basic calculator modes
490- Function graphing with root, intercept, min/max, and intersection detection
491- Material You design
492
493Internet only used for: live currency exchange rates in the unit converter
494```
495
4961. Line 1 is the summary, **at most 80 characters** — Play and F-Droid cap it there.
4972. Line 2 is blank.
4983. Line 3 is exactly `Features:`.
4994. Then one or more `- ` bullets, and nothing else.
5005. Then a blank line, then a single connectivity line, exactly one of:
501 - `100% offline`
502 - `Requires internet`
503 - `Internet required only for initial asset downloads`
504 - `Internet only used for: <feature(s)>`
505
506Use the last form only when the app still mostly works without a connection. Claims must match
507the code: check the `INTERNET` permission and the hosts the app actually contacts, including
508ones merged in from library modules.
509
510### Listing screenshots
511
512Apps render their store screenshots from Compose previews. Add
513`id("common-conventions-preview-metadata")`, put previews in `src/screenshotTest/kotlin/`, and
514run `./gradlew :<module>:metadata` to write numbered PNGs into per-form-factor
515buckets under `metadata_data/photos/<module-key>/` — `phone/`, `tablet/`,
516`large-tablet/`, `tv/`, `wear/`, using the Triple-T spellings verbatim. That
517directory is wiped and rewritten each time.
518
519Preview functions must:
520
521- carry **both** `@PreviewTest` and `@Preview` — `@Preview` alone silently discovers no tests
522- be **members of a class**, not top-level, or they land in a `…Kt` facade the engine skips
523- be named `Preview1Foo`, `Preview2Bar`, … — **the number is the listing order
524 within its bucket**, so renumber if you reorder
525- carry a `group` naming the bucket (`phone`, `tablet`, `large-tablet`, `tv`,
526 `wear`) — wide/expanded layouts go to `large-tablet`, car views fold into
527 `phone` (Play has no car type)
528- use only literal state; they render with no ViewModel, no database and no device
529- use the shared device spec and `showSystemUi = true`
530
531`calculator/src/screenshotTest/` is the worked example. Layoutlib has no wallpaper, so Material
532You falls back to the default palette in previews.
533
534Two apps opt out with an explanatory comment and commit images by hand, because Layoutlib
535cannot render them: `camera` (needs a real camera) and `games/voxels` (a Vulkan surface).
536
537Run `bash scripts/check_preview_metadata.sh` to verify all of the above.
538
539---
540
541## Native Rust
542
543Put the crate at `<module>/src/main/rust/`, add it to the workspace `members` in the root
544`Cargo.toml`, then:
545
546```kotlin
547androidComponents {
548 onVariants { variant ->
549 variant.sources.jniLibs?.addStaticSourceDirectory(
550 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
551 )
552 }
553}
554
555rustNativeLib("measure_vio", "measure")
556```
557
558Registering the `jniLibs` source directory is your job — the helper does not do it. Builds are
559`--locked --release`, arm64 only unless you pass `extraAbis`, and serialized across modules
560because implicit toolchain installs aren't concurrency-safe. Paths are remapped and
561`SOURCE_DATE_EPOCH` honoured so builds stay reproducible.
562
563The workspace denies `unsafe_code`, `unwrap_used`, `panic`, `indexing_slicing` and
564`missing_docs`, so write fallible code with explicit error handling.
565
566**Packaging 32-bit is two-sided:** the app opts in with `nativeAbis { armv7 = true }` *and* the
567Rust module must opt in with `extraAbis`. CI currently installs only the aarch64 Rust target.
568
569**Vulkan shaders** live in `src/main/rust/shaders/` and are compiled by Gradle, not `build.rs`.
570Pass `shaders = listOf("*.vert", "*.frag")` (globs under `shaders/`) and optionally
571`glslcArgs` to `rustNativeLib`. The `:<module>:compileShaders` task writes `<name>.spv` to
572`build/spirv/` with the NDK's glslc, and the crate loads it with
573`include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../../build/spirv/<name>.spv"))`.
574`./check` and `./test` run the task before cargo. If you run cargo by hand, run it first.
575Don't commit `.spv` files.
576
577---
578
579## Dependencies
580
581`settings.gradle.kts` sets `FAIL_ON_PROJECT_REPOS`, so modules must never declare their own
582repositories, and every third-party repo is content-scoped. Adding a dependency from a new host
583is deliberately a visible, explicit change.
584
585Prefer an existing shared module over a new dependency:
586
587| Module | Purpose |
588| :--- | :--- |
589| `:library` | Base — nav keys, shared IPC DTOs, `AssistantIntent` |
590| `:library:ui` | Compose layer — Material re-export, `Icons.kt`, scaffolds, `DynamicTheme`, messages |
591| `:library:network` | `NetworkClient` and the pinned CA trust bundles |
592| `:library:room` | Room 3 + SQLCipher |
593| `:library:map` | Vector map rendering |
594| `:library:ml` | On-device inference |
595| `:library:ocr` | On-device OCR |
596| `:library:image` / `:library:media` | Image loading / audio-video playback |
597| `:library:e2ee-p2p` | End-to-end encryption and peer-to-peer |
598| `:library:widgets` / `:library:work` | Glance widgets / WorkManager helpers |
599| `:library:biometric` / `:library:ink` | Biometric prompts / stylus ink |
600| `:library:downloadservice` | Foreground downloads for large assets and models |
601| `:library:locationprovider` | Location provider abstraction |
602| `:library:aosp-stubs` | Compile-only hidden-API stubs |
603| `:sdk:games` / `:sdk:cast` / `:sdk:openassistant` | Games hub, casting, assistant tool calling |
604
605See [SUPPLY_CHAIN_RISKS.md](SUPPLY_CHAIN_RISKS.md) before adding anything third-party.
606
607---
608
609## Tests
610
611Unit tests go in `<module>/src/test/java/...`, mirroring the main package, using `kotlin.test`
612and JUnit 4. `androidTest` is legacy here — the on-device screenshot generator is gone, and
613`src/androidTest/**/MetadataScreenshots.kt` is treated as an error.
614
615The `screenshotTest` source set exists to generate store images, not to catch regressions; no
616baseline is committed and nothing diffs against one.
617
618CI does not run tests. Run them locally.
619
620---
621
622## Git
623
624**The first line of a commit message** is at most ~80 characters:
625
626```
627appname: feature description in a few words (#123)
628```
629
630Drop the issue number if there isn't one. Use the module or area as the prefix.
631
632After the first line, leave a blank line and write a full body, wrapped at ~72 characters: what
633changed and why, the context (the bug or symptom, root cause, constraints, alternatives you
634rejected), notable implementation details, the user-visible effect, and how you verified it.
635Release notes are generated from commit messages, so a complete body makes for better notes.
636
637`.gitattributes` normalises the whole tree to LF, so you should never see a line-ending diff. If
638`git diff --stat` reports far more changed lines than you actually touched, your editor rewrote
639the file's line endings — fix that rather than committing the churn.