Language policy
The codebase is being migrated from Java to Kotlin. New code should be written in Kotlin wherever possible. Large refactors should conform to the preferred tech stack: Kotlin, MVVM, data-binding, and coroutines.Java code style
Java code follows theProtonStyle.xml code scheme, located at the root of the repository. Import it into Android Studio to ensure your IDE formats code consistently with the rest of the project.
1
Open the Code Style settings
In Android Studio, go to File > Settings > Editor > Code Style (on macOS: Android Studio > Settings > Editor > Code Style).
2
Import the scheme
Click the gear icon next to the Scheme dropdown and select Import Scheme.
3
Select ProtonStyle.xml
Navigate to the root of the
android-app repository and select ProtonStyle.xml.4
Apply the scheme
Select the imported Project scheme from the dropdown and click Apply.
- Star imports are disabled (import threshold set to
Integer.MAX_VALUE) - XML attribute ordering follows Android conventions (
xmlns:androidfirst, then otherxmlns:*alphabetically, thenandroid:id,android:name, and so on) - Kotlin right margin set to 120 characters
- Continuation indent size of 4 for both XML and Kotlin
Kotlin code style
Kotlin code uses ktlint with its default ruleset, based on the official Kotlin coding conventions. No custom ruleset is applied — the default ktlint rules are sufficient. Detekt is also configured to catch common issues. The detekt ruleset is downloaded from the shared Proton Core configuration at build time.Running static analysis
Run these commands locally before opening a pull request to catch issues early.Tech stack conventions
New features and significant refactors should follow these architectural conventions:
Avoid introducing new Java classes. If you are modifying an existing Java file, consider converting it to Kotlin as part of your change.