diff --git a/Code-style.md b/Code-style.md index 79d0115..14dd4a3 100644 --- a/Code-style.md +++ b/Code-style.md @@ -10,4 +10,14 @@ For the Java code, AntennaPod uses a style similar to [Google's Java style](http ### Resource ID naming -Please use lowerCamelCase for naming `@+id` resources. For `TextViews` and `ImageViews`, just describing the element is enough (`title`, `background`). For `ViewGroups` like `LinearLayouts`, describing is usually enough, too: `playbackControls`. Buttons should always have the suffix `Button` (`viewDetailsButton`, `playButton`) and floating action buttons (fab) the suffix `Fab` (`addFeedFab`). In rare cases where it is really clear what the id is referring to, it may also be named after the type of the element (`recyclerView`). \ No newline at end of file +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`). \ No newline at end of file