|
1 | 1 | <!-- |
2 | | - ~ SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors |
| 2 | + ~ SPDX-FileCopyrightText: 2016-2026 Nextcloud GmbH and Nextcloud contributors |
3 | 3 | ~ SPDX-FileCopyrightText: 2016-2024 Stefan Niedermann <info@niedermann.it> |
4 | 4 | ~ SPDX-License-Identifier: GPL-3.0-or-later |
5 | 5 | --> |
6 | 6 | # Contributing guide |
7 | 7 |
|
| 8 | +Thanks for helping out with Nextcloud Notes for Android. This guide covers how to report a bug, how to set up the |
| 9 | +project, and what a pull request has to satisfy before it can be merged. |
| 10 | + |
8 | 11 | ## Submitting bug reports |
9 | 12 |
|
10 | | -If you find a bug, feel free to [open an issue](https://github.com/nextcloud/notes-android/issues/new). But please provide these information in the comment: |
| 13 | +Please [open an issue](https://github.com/nextcloud/notes-android/issues/new/choose) and pick the **🐞 Bug report** |
| 14 | +template. It asks for everything maintainers need, and filling it in completely is the fastest way to get your report |
| 15 | +triaged: |
11 | 16 |
|
12 | | -**Android version:** e. g. 6.0.1 Marshmallow |
| 17 | +- Notes Android version, Notes server version, Nextcloud Android (Files) app version and Nextcloud server version |
| 18 | +- Android version and device |
| 19 | +- Where you installed the app from (Google Play, F-Droid or self-built) |
| 20 | +- Steps to reproduce, expected behaviour and, if possible, screenshots or a log |
13 | 21 |
|
14 | | -**Device**: e. g. Motorola Moto G 2015 |
| 22 | +Before opening an issue, please read the [FAQ](FAQ.md) and search the existing issues. Note that this repository is only |
| 23 | +about the **Android app** — problems with the [Notes server app](https://github.com/nextcloud/notes/issues) or the |
| 24 | +[Nextcloud Android app](https://github.com/nextcloud/android/issues) belong in their own repositories. |
15 | 25 |
|
16 | | -**System language**: English (US), German, … |
| 26 | +## Adding new features |
17 | 27 |
|
18 | | -**App version:** e. g. v0.8.1 |
| 28 | +For anything beyond a small fix, please [open an issue](https://github.com/nextcloud/notes-android/issues/new/choose) |
| 29 | +first and ask whether the feature is wanted. It would be disappointing to build something and then have the pull request |
| 30 | +rejected for a reason you could not have known about. This is especially true for changes that touch several subsystems |
| 31 | +or require an architectural decision. |
19 | 32 |
|
20 | | -**App source:** Google Play Store, F-Droid or self-built? |
| 33 | +## Project setup |
21 | 34 |
|
22 | | -**Steps to reproduce:** |
23 | | - 1. open the app |
24 | | - 2. click on a note |
25 | | - 3. use the top left back-arrow |
26 | | - 4. … |
| 35 | +| Setting | Value | |
| 36 | +|---|---| |
| 37 | +| Language for new code | **Kotlin** (see [Code style](#code-style)) | |
| 38 | +| minSdk / targetSdk / compileSdk | 28 / 36 / 37 | |
| 39 | +| Authentication | Nextcloud [Android SingleSignOn](https://github.com/nextcloud/Android-SingleSignOn) | |
27 | 40 |
|
28 | | -### Copy & Paste |
29 | | - **Android version:** e. g. 6.0.1 Marshmallow |
30 | | - |
31 | | - **Device**: e. g. Motorola Moto G 2015 |
32 | | - |
33 | | - **System language**: English (US), German, … |
34 | | - |
35 | | - **App version:** e. g. v0.8.1 |
36 | | - |
37 | | - **App source:** Google Play Store, F-Droid or self-built? |
38 | | - |
39 | | - **Steps to reproduce:** |
40 | | - 1. open the app |
41 | | - 2. click on a note |
42 | | - 3. use the top left back-arrow |
43 | | - 4. … |
| 41 | +Import the project into Android Studio (a recent stable release that supports AGP 9) or build from the command line |
| 42 | +with the Gradle wrapper. To run the app you need a Nextcloud server with the |
| 43 | +[Notes server app](https://github.com/nextcloud/notes) installed, and the Nextcloud Files app on the device or emulator |
| 44 | +to provide the SSO account. |
44 | 45 |
|
45 | | -## Adding new features |
| 46 | +### Build flavors |
| 47 | + |
| 48 | +| Flavor | Application ID | Purpose | |
| 49 | +|---|---|---| |
| 50 | +| `fdroid` | `it.niedermann.owncloud.notes` | F-Droid release | |
| 51 | +| `play` | `it.niedermann.owncloud.notes` | Google Play release | |
| 52 | +| `dev` | `it.niedermann.owncloud.notes.dev` | Development builds, installable next to a release build | |
| 53 | +| `qa` | `it.niedermann.owncloud.notes.qa` | Per-pull-request test builds | |
| 54 | + |
| 55 | +### Common commands |
| 56 | + |
| 57 | +```bash |
| 58 | +# Assemble a debug APK |
| 59 | +./gradlew assembleDevDebug # or assembleFdroidDebug / assemblePlayDebug |
| 60 | + |
| 61 | +# Unit tests |
| 62 | +./gradlew test # all variants |
| 63 | +./gradlew testFdroidDebugUnitTest # one variant |
| 64 | + |
| 65 | +# Android lint |
| 66 | +./gradlew lintDevDebug # the variant CI checks |
| 67 | +./gradlew lintFdroidDebug |
| 68 | + |
| 69 | +# Lint plus unit tests |
| 70 | +./gradlew check |
| 71 | + |
| 72 | +# Instrumented tests (device or emulator required) |
| 73 | +./gradlew connectedAndroidTest |
| 74 | +``` |
| 75 | + |
| 76 | +APKs are written to `app/build/outputs/apk/`. |
| 77 | + |
| 78 | +## Code style |
| 79 | + |
| 80 | +Formatting is defined by [`.editorconfig`](.editorconfig): 4 spaces, UTF-8, a maximum line length of 120 characters, no |
| 81 | +trailing whitespace, and exactly one trailing newline at the end of every file. The standard Android Studio formatter |
| 82 | +picks these up automatically. |
| 83 | + |
| 84 | +### New files are Kotlin |
| 85 | + |
| 86 | +Kotlin is the language of this project. **Every new source file must be a `.kt` file** — a dedicated |
| 87 | +[CI check](.github/workflows/detectNewJavaFiles.yml) fails the pull request when a new `.java` file is added. |
| 88 | + |
| 89 | +A large amount of Java is still present as legacy that is being migrated away from. Editing, debugging and fixing that |
| 90 | +Java is normal and expected: fix a bug in a Java class by editing that Java class rather than converting it as a side |
| 91 | +effect of an unrelated change. |
| 92 | + |
| 93 | +### Conventions |
| 94 | + |
| 95 | +- Keep files small — 300 lines is the ceiling. A file already at that size must not grow; put new code in a new Kotlin |
| 96 | + file (extension function, use case, mapper, state or model class) and keep the edit to the existing file to the |
| 97 | + minimum that wires it up. |
| 98 | +- One top-level type per file, and separate files for models and states. |
| 99 | +- Let names and small functions carry the meaning instead of comments. Do not add decorative section dividers |
| 100 | + (`// ---- Title ----`). |
| 101 | +- |
| 102 | +### Design |
| 103 | + |
| 104 | +- Follow Material Design 3 and the |
| 105 | + [Nextcloud wording guidelines](https://docs.nextcloud.com/server/latest/developer_manual/design/foundations.html#wording). |
| 106 | +- Make sure the change works in light and dark theme, and with different server primary colors by using the |
| 107 | + `viewThemeUtils` color theme instead of fixed colors. |
| 108 | +- Use material 3 design icons. |
| 109 | + |
| 110 | +### License headers |
| 111 | + |
| 112 | +The repository is [REUSE](https://reuse.software) compliant and CI enforces it. Every new file needs an SPDX header |
| 113 | +whose year is the year the file was created: |
| 114 | + |
| 115 | +```kotlin |
| 116 | +/* |
| 117 | + * Nextcloud Notes - Android Client |
| 118 | + * |
| 119 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 120 | + * SPDX-License-Identifier: GPL-3.0-or-later |
| 121 | + */ |
| 122 | +``` |
| 123 | + |
| 124 | +```xml |
| 125 | +<!-- |
| 126 | + ~ Nextcloud Notes - Android Client |
| 127 | + ~ |
| 128 | + ~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 129 | + ~ SPDX-License-Identifier: GPL-3.0-or-later |
| 130 | +--> |
| 131 | +``` |
| 132 | + |
| 133 | +Use the comment syntax of the respective file type for other kinds of files. |
| 134 | + |
| 135 | +## Testing |
| 136 | + |
| 137 | +- Unit tests live in `app/src/test/` and use JUnit 4, Mockito and Robolectric (with `includeAndroidResources`). |
| 138 | +- Instrumented tests live in `app/src/androidTest/` and use Espresso; they need a running device or emulator. |
| 139 | +- Coverage is collected with JaCoCo for debug builds, e.g. |
| 140 | + `./gradlew createFdroidDebugUnitTestCoverageReport`. |
| 141 | + |
| 142 | +Add tests for your change, or state in the pull request why they are not needed. |
| 143 | + |
| 144 | +## Translations |
| 145 | + |
| 146 | +Translations are managed through [Transifex](https://explore.transifex.com/nextcloud/nextcloud/) and synced into the |
| 147 | +repository automatically. Only ever edit `app/src/main/res/values/strings.xml`; never touch the translated |
| 148 | +`values-*/strings.xml` files. |
| 149 | + |
| 150 | +If you need to change an existing translation, do not edit it. Create a new one and delete the old one. |
| 151 | + |
| 152 | +## Commits and pull requests |
| 153 | + |
| 154 | +### Commits |
| 155 | + |
| 156 | +- Sign off every commit (`git commit -s`) to certify the |
| 157 | + [Developer Certificate of Origin](https://developercertificate.org/). Only you as a human contributor can do this. |
| 158 | +- Follow [Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/#specification), for example |
| 159 | + `feat(editor): add checkbox toggling` or `fix(sync): handle expired SSO token`. |
| 160 | +- Every commit that contains AI-assisted content needs a trailer identifying the agent and model, which the |
| 161 | + [AI Policy workflow](.github/workflows/ai-policy.yml) checks for: |
| 162 | + |
| 163 | + ``` |
| 164 | + AI-assistant: Claude Code 2.1.80 (Claude Sonnet 4.6) |
| 165 | + ``` |
| 166 | + |
| 167 | + With distinct roles: `AI-assistant: OpenCode v1.0.203 (plan: Claude Opus 4.5, edit: Claude Sonnet 4.5)`. |
| 168 | + A coding agent must never appear in `Signed-off-by` or `Co-Authored-By`. |
| 169 | + |
| 170 | +### Pull requests |
| 171 | + |
| 172 | +Pull requests target **`main`**. Backports are requested by commenting `/backport to stable-xx.x` on the merged pull |
| 173 | +request. |
| 174 | + |
| 175 | +The [pull request template](.github/pull_request_template.md) asks you to confirm that tests are included or not |
| 176 | +needed, that backports and the milestone are set, that the title is meaningful, and — if applicable — that the content |
| 177 | +was partly or fully generated using AI. Please disclose AI use there; it is required by the Nextcloud |
| 178 | +[AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md). |
| 179 | + |
| 180 | +Beyond that: |
| 181 | + |
| 182 | +- Describe what changed and why, and reference the issue it addresses (`Closes #123`). |
| 183 | +- Add before/after screenshots for user-visible changes. |
| 184 | +- Keep each pull request focused on one concern. No unrelated files, no incidental refactors. If it grows towards |
| 185 | + several thousand changed lines, split it. |
| 186 | +- Before you push, run `./gradlew lintDevDebug` and `./gradlew test`, and fix every finding in the files you changed. |
| 187 | + CI runs lint, unit tests, a debug APK build, the new-Java-file check and the REUSE check. |
| 188 | +- Review your own diff first and remove dead code, unused parameters, unreachable defensive branches, leftover |
| 189 | + scaffolding and superfluous comments. |
| 190 | + |
| 191 | +Contributions must comply with the Nextcloud |
| 192 | +[Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md) and, where AI tools were |
| 193 | +involved, the [AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md). |
46 | 194 |
|
47 | | -If you want to contribute on the code, you can fork the project, commit your changes and make a pull request. For bigger features/changes, it's better to first [open an issue](https://github.com/stefan-niedermann/OwnCloud-Notes/issues/new) and ask if this feature is needed or wanted – it would be very disappointing if you add a new cool feature and your pull request will be rejected by some reasons you didn't thought about. |
| 195 | +If you use an AI coding agent on this repository, see [AGENTS.md](AGENTS.md) — it holds the rules the agent is expected |
| 196 | +to follow, with detailed guides in `.claude/skills/`. |
0 commit comments