Skip to content
ByteHamster edited this page Jan 1, 2024 · 4 revisions

This wiki contains the developer documentation for AntennaPod. If you are a user and you are looking for help, have a look at our website!


Code style

For the Java code, AntennaPod uses a style similar to Google's Java style. Checkstyle is run automatically when creating a pull request. The gradle checkstyle task only checks more relaxed rules (config/checkstyle/checkstyle.xml) for the whole code base. On CI, the more strict rules (config/checkstyle/checkstyle-new-code.xml) are used for new code. In Android Studio, you can set the checkstyle version to 8.18 and select the config/checkstyle/checkstyle-new-code.xml config file. Please only reformat lines that you actually modify, not the whole file. This makes it easier to read the version history.

For Android layout XML files, we use indention with 4 spaces. The id, layout_width and layout_height attributes come first. To easily format the files, you can use the same tool as our CI server: https://github.com/ByteHamster/android-xml-formatter

Resource ID naming

Please use lowerCamelCase for naming @+id resources. For some types listed in the table below, please add a suffix noting the type.

View type Examples Naming
Clickable items where only the action is important Button that opens Settings, ImageView that triggers play/pause Add suffix Button, even if it is not a Button view. Here, the action is more important than the view type.
ViewGroup like LinearLayout, FrameLayout LinearLayout that shows player controls, FrameLayout that allows to hide the whole screen content while loading Add suffix Container. In most cases, the Java code does not care what specific ViewGroup is used. It just cares that it can hide a group of other items. Cases where the actual type is especially important, such as suggestionsGrid, can be named differently.
Images whose main purpose is to show an image (as opposed to mainly being a button) ImageView that serves as a background, SquareImageView that shows the cover Add suffix Image
Text content TextView that shows the position Add suffix Label
Everything else Spinner that allows to select options, ProgressBar that shows the position Suffix with shortened view type. This ensures that a reader of the code knows what a view can be used for without looking at the layout files

In cases where adding a name would be redundant, it may also be named only after the type of the element (for example recyclerView, progressBar).