Lint: enforce naming standards for some layouts
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)
https://github.com/ankidroid/Anki-Android/blob/c31281882b09e64b812bb89b8230b395e9531422/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateBrowserAppearanceEditor.kt#L44
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:
https://github.com/ankidroid/Anki-Android/blob/c31281882b09e64b812bb89b8230b395e9531422/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateBrowserAppearanceEditor.kt#L45
- 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
@david-allison I would like to work on this task. May I be assigned to it?
Sure! Thanks!
Hi, @sonalyadav1 are you still working on this issue?
It's been 12 hours, it'd be best to find a better issue. See here for our guidance:
https://github.com/ankidroid/Anki-Android/blob/main/CONTRIBUTING.md#selecting-an-issue-github-search
Please let me know if you need any more info, the CONTINUING page is new, and may need tweaking
Hi, I’d like to work on this issue. Please let me know if it’s okay or if someone is already actively working on it.
Someone is already assigned, it's only been 3 days.
Heyy, I would like to work on this issue if its not fixed yet
@sonalyadav1, how're things going?
@Osaidcodes feel free, if there's no reply within 48 hours
@david-allison I'm working on the issue and will raise a PR soon.
@david-allison should I work on this issue or is it fixed?
@Osaidcodes A PR has been submitted, no point in duplicated effort here.
- #19992