-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Layouts:
- Activity ->
activity_ - Fragment ->
fragment_ - View ->
view_ - Dialog ->
dialog_
Task
- Layouts are stored in: https://github.com/ankidroid/Anki-Android/blob/0c1f02992ba45518b80ad7540b9f5ef1ff163a04/AnkiDroid/src/main/res/layout
- and a few
layout*subfolders of/res/
- and a few
- A layout which is associated with an activity should have an
activity_prefix- ❌
res/layout/deck_picker.xml - ✅
res/layout/activity_deck_picker.xml
- ❌
This should be implemented in the following order:
- A lint rule should be created, for a constraint
- The lint breakages should be fixed in the same commit
- Repeat, for each of the 4 categories.
The implementation of the lint rules is the main complexity, I suspect that this should be partially implemented as an initial PR, and improved in a follow up PR
The easiest method of determining whether a layout is associated with an activity or Fragment is when it's passed into the constructor (see: vbpd)
Anki-Android/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateBrowserAppearanceEditor.kt
Line 44 in c312818
| class CardTemplateBrowserAppearanceEditor : AnkiActivity(R.layout.card_browser_appearance) { |
This will handle a subset of activities and Fragments. Not all activities pass the layout into the constructor.
The more correct method is to use the name of the Binding class:
Anki-Android/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateBrowserAppearanceEditor.kt
Line 45 in c312818
| private val binding by viewBinding(CardBrowserAppearanceBinding::bind) |
- match the binding with the layout
- determine the type of class that the binding is in
Prefer to be conservative: only raise a lint error if certain