ADFA-3900 | Fix password inputType parsing from sketch annotations#1284
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis pull request modularizes fuzzy attribute parsing into a new parser package with explicit attribute models and value cleaners, adds stricter tag extraction, rewrites margin block resolution, refactors nearby-text matching helpers, updates grammar validators, and adjusts widget input-type inference and related imports. ChangesAttribute Parsing Architecture Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (6)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt (3)
3-3: 💤 Low valueUnused
android.util.Logimport.
Logis not referenced anywhere in this file. Likely a leftover from the move out ofdomain/.-import android.util.Log import com.itsaky.androidide.fuzzysearch.FuzzySearch🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt` at line 3, Remove the unused import of android.util.Log from FuzzyAttributeParser.kt; open the FuzzyAttributeParser file (class/object FuzzyAttributeParser) and delete the line "import android.util.Log" since Log is not referenced anywhere in that file to avoid unused-import warnings.
38-49: 💤 Low valueHardcoded OCR fix-ups in
tokenizeAnnotationwill not scale.The
backgroundired/backgroundred/horizontal gravity: center layoutsubstitutions look like patches added to satisfy specific failing samples. As more OCR oddities appear, this list will grow unbounded inside the tokenizer. Consider isolating these into a dedicatedOcrSanitizer(data-driven list of(pattern, replacement)pairs) so the list can be extended/tested independently of the tokenization pipeline.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt` around lines 38 - 49, tokenizeAnnotation currently contains hardcoded OCR workaround replace calls (e.g., "backgroundired", "backgroundred", "horizontal gravity: center layout") which don't scale; extract these substitutions into a dedicated OcrSanitizer (a data-driven list of (pattern, replacement) pairs) and call it from tokenizeAnnotation so the sanitizer can be extended and tested independently. Implement an OcrSanitizer class/object that exposes a sanitize(String):String method (used by tokenizeAnnotation) backed by a configurable list of Regex->replacement entries, ensure tokenizeAnnotation uses PIPE_DELIMITER and the same split logic after calling OcrSanitizer.sanitize, and update tests to exercise sanitizer rules separately.
97-97: 💤 Low valueThreshold carve-out for length==6 is hard to reason about.
length <= 3 → 65, length == 6 → 75, else → 80leaves length 4–5 and 7+ at 80 while singling out 6. This pattern reads as ad-hoc test fitting and will be brittle to extend. If this is intentional to capture a specific OCR class (e.g., 6-char garbled aliases likewldth-style), please add an inline comment with an example so the carve-out is grep-able later; otherwise, smoothing to a monotonic ladder (e.g.,≤3 → 65, ≤6 → 75, else → 80) would be more defensible.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt` at line 97, The threshold calculation in FuzzyAttributeParser (the line computing threshold from normalizedKey.length) special-cases length == 6 which is unclear and brittle; either make the rule monotonic by changing the condition to "≤3 → 65, ≤6 → 75, else → 80" (i.e., replace the length==6 branch with length <= 6) or, if the carve-out for length==6 is intentional, add a concise inline comment on that same line referencing a concrete example (e.g., an OCR mis-parse like "wldth") and why 75 was chosen so future readers can grep for it; update the code in FuzzyAttributeParser.kt accordingly and keep the variable normalizedKey as the referenced symbol.cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt (1)
284-303: 💤 Low valuePassword inference logic LGTM.
Precedence is right: an explicit
android:inputTypefromparsedAttrswins, falling back to hint inference, then to"text". The two-pattern check ("password"and"pass word") handles both joined and OCR-split tokens, andlowercase()normalizes capitalization. One minor consideration for a follow-up: the heuristic is English-only — non-English hints (e.g.,"Contraseña","Mot de passe") won't be detected. Acceptable for now given the OCR pipeline's English bias, but worth tracking if i18n hints are expected.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt` around lines 284 - 303, Password inference is currently English-only; update inferInputTypeFromHint to support common non-English password tokens by replacing the hardcoded contains checks with a configurable keyword list (e.g., LOCAL_PASSWORD_KEYWORDS) and matching against normalizedHint, so specificAttributes still prefers parsedAttrs[AttributeKey.INPUT_TYPE.xmlName] but falls back to inferInputTypeFromHint(normalizedHint) which now checks multiple localized tokens (reference functions inferInputTypeFromHint and specificAttributes, and keys AttributeKey.HINT.xmlName / AttributeKey.INPUT_TYPE.xmlName); consider making the keyword list injectable or a companion object constant so it can be extended without changing logic.cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt (2)
57-60: 💤 Low value
DimensionCleanersilently drops decimal precision for values like"16.5dp".
NumberCleaneronly matches[-\doOlIzZsSbB]+(no decimal point), so the integer-only regex truncates the fractional part."16.5dp"would normalize to"16dp".If sub-pixel dimension values are not expected from OCR (which is common), this is acceptable — but it's worth an explicit comment. If they are expected, the numeric extraction path should delegate to
FloatCleaner(or use its regex) instead.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt` around lines 57 - 60, DimensionCleaner is dropping fractional parts because it uses NumberCleaner (integer-only) when extracting numericPart from fixedUnit; update the extraction to preserve decimals by delegating to FloatCleaner (or using FloatCleaner’s regex) instead of NumberCleaner, then reconstruct the unit as "${numericPart}dp" (or, if fractional values are not expected, add an explicit comment in DimensionCleaner explaining the choice and leave NumberCleaner but document behavior); refer to DimensionCleaner, NumberCleaner, FloatCleaner, numericPart, fixedUnit, and rawValue when making the change.
46-46: 💤 Low value
"wrapcan"inwrapKeywordslooks like a stale OCR-artifact token.
"wrapcan"is not a recognizable dimension keyword. If it was meant to catch OCR-misread"wrap_content", it's already covered by the"wrap"and"content"entries. If it's intentional (e.g., a specific OCR output you observed), a short inline comment would clarify its purpose.♻️ Proposed cleanup
- private val wrapKeywords = setOf("wrap", "content", "wrapcan") + private val wrapKeywords = setOf("wrap", "content")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt` at line 46, The set wrapKeywords in ValueCleanersImpl.kt contains a stale OCR-like token "wrapcan"; remove "wrapcan" from the set (leaving "wrap" and "content") or, if you intentionally want to handle a specific OCR artifact, replace it with a short inline comment explaining the rationale; update the declaration of wrapKeywords to reflect the removal/comment so the intent is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt`:
- Line 79: The InputType validation currently uses CategoricalValidator with
fuzzy matching which fails on pipe-combined flags and a too-small
InputTypeValueSet; update validation so AttributeKey.INPUT_TYPE.xmlName is
validated by splitting the raw attribute value on '|' and validating each token
against an expanded InputTypeValueSet (add textVisiblePassword, textPersonName,
textCapSentences, textCapWords, textMultiLine, date, time, datetime, etc.), and
switch to exact (case-insensitive) token matching instead of fuzzy matching (or
implement a dedicated InputTypeValidator that performs this
split-and-exact-match logic) so combined flags are preserved rather than
dropped.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt`:
- Around line 121-164: The extractBlocks function currently promotes any
tag-shaped text to explicit when validPrefixes is empty and overwrites duplicate
entries; change the explicit-detection logic in extractBlocks so an extraction
only becomes explicit when validPrefixes is non-empty and the extracted prefix
is in validPrefixes (e.g., require validPrefixes.isNotEmpty() &&
extraction.first.substringBefore('-') in validPrefixes), and modify the
save/update of blocks.explicitAnnotations (in GroupedBlocks handling inside
extractBlocks) to merge duplicates instead of overwriting — if a key already
exists concatenate the new text (with a separating space) or otherwise
append/log the collision so content isn’t silently dropped; reference
WidgetTagParser.extractTag, explicitAnnotations, ParsedBlock, and validPrefixes
when making these edits.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.kt`:
- Line 71: The TEXT_STYLE enum/constant in AttributeModels.kt currently lists
"style" as an alias which collides with the STYLE entry and makes STYLE
unreachable; remove the "style" alias from TEXT_STYLE's alias list (leave
aliases like "textstyle" and "text_style"), so that AttributeKey.findByAlias /
fuzzyMatchKey will resolve "style" to the STYLE entry (xmlName = "style") and
resolveXmlAttribute will route style values through the correct cleaner instead
of TextStyleCleaner; verify no other entries duplicate the "style" alias.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`:
- Around line 133-134: The DrawableCleaner logic in ValueCleanersImpl.kt
currently strips all non [a-z0-9_] characters which removes spaces and can yield
an empty name; update the cleaning pipeline for the code that computes `cleaned`
from `rawValue` (the block using `rawValue.lowercase()` and the two
`replace(Regex(...))` calls) to: 1) replace any whitespace and sequences of
non-alphanumeric characters with a single underscore, 2) collapse consecutive
underscores and trim leading/trailing underscores so names like " my image!! "
become "my_image", and 3) if the final cleaned result is empty, return a safe
fallback drawable reference (for example "@drawable/ic_placeholder" or another
project-standard default) instead of "@drawable/". Ensure you reference and
update the same symbol that returns `@drawable/$cleaned` in
ValueCleanersImpl.kt.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.kt`:
- Around line 32-34: The code in WidgetTagParser unconditionally strips a
leading prefix from tokenRaw (tokenRaw.uppercase().startsWith(prefix)), which
mangles valid tags like "B-BOX"; change the condition to only strip when the
prefix is duplicated (e.g., patterns like prefix+prefix or prefix + "-" +
prefix) so you only remove an accidental repeated prefix. Locate the occurrences
around the tokenRaw manipulation (the block using
tokenRaw.uppercase().startsWith(prefix) and the substring(...).trim('-') logic)
and replace the check with a test for duplicated-prefix patterns
(tokenRaw.uppercase().startsWith(prefix + prefix) or
tokenRaw.uppercase().startsWith(prefix + "-" + prefix)), then perform the
substring/trimming only in those cases; apply the same change to the second
occurrence noted (lines around 49-51).
---
Nitpick comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Line 3: Remove the unused import of android.util.Log from
FuzzyAttributeParser.kt; open the FuzzyAttributeParser file (class/object
FuzzyAttributeParser) and delete the line "import android.util.Log" since Log is
not referenced anywhere in that file to avoid unused-import warnings.
- Around line 38-49: tokenizeAnnotation currently contains hardcoded OCR
workaround replace calls (e.g., "backgroundired", "backgroundred", "horizontal
gravity: center layout") which don't scale; extract these substitutions into a
dedicated OcrSanitizer (a data-driven list of (pattern, replacement) pairs) and
call it from tokenizeAnnotation so the sanitizer can be extended and tested
independently. Implement an OcrSanitizer class/object that exposes a
sanitize(String):String method (used by tokenizeAnnotation) backed by a
configurable list of Regex->replacement entries, ensure tokenizeAnnotation uses
PIPE_DELIMITER and the same split logic after calling OcrSanitizer.sanitize, and
update tests to exercise sanitizer rules separately.
- Line 97: The threshold calculation in FuzzyAttributeParser (the line computing
threshold from normalizedKey.length) special-cases length == 6 which is unclear
and brittle; either make the rule monotonic by changing the condition to "≤3 →
65, ≤6 → 75, else → 80" (i.e., replace the length==6 branch with length <= 6)
or, if the carve-out for length==6 is intentional, add a concise inline comment
on that same line referencing a concrete example (e.g., an OCR mis-parse like
"wldth") and why 75 was chosen so future readers can grep for it; update the
code in FuzzyAttributeParser.kt accordingly and keep the variable normalizedKey
as the referenced symbol.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`:
- Around line 57-60: DimensionCleaner is dropping fractional parts because it
uses NumberCleaner (integer-only) when extracting numericPart from fixedUnit;
update the extraction to preserve decimals by delegating to FloatCleaner (or
using FloatCleaner’s regex) instead of NumberCleaner, then reconstruct the unit
as "${numericPart}dp" (or, if fractional values are not expected, add an
explicit comment in DimensionCleaner explaining the choice and leave
NumberCleaner but document behavior); refer to DimensionCleaner, NumberCleaner,
FloatCleaner, numericPart, fixedUnit, and rawValue when making the change.
- Line 46: The set wrapKeywords in ValueCleanersImpl.kt contains a stale
OCR-like token "wrapcan"; remove "wrapcan" from the set (leaving "wrap" and
"content") or, if you intentionally want to handle a specific OCR artifact,
replace it with a short inline comment explaining the rationale; update the
declaration of wrapKeywords to reflect the removal/comment so the intent is
clear.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt`:
- Around line 284-303: Password inference is currently English-only; update
inferInputTypeFromHint to support common non-English password tokens by
replacing the hardcoded contains checks with a configurable keyword list (e.g.,
LOCAL_PASSWORD_KEYWORDS) and matching against normalizedHint, so
specificAttributes still prefers parsedAttrs[AttributeKey.INPUT_TYPE.xmlName]
but falls back to inferInputTypeFromHint(normalizedHint) which now checks
multiple localized tokens (reference functions inferInputTypeFromHint and
specificAttributes, and keys AttributeKey.HINT.xmlName /
AttributeKey.INPUT_TYPE.xmlName); consider making the keyword list injectable or
a companion object constant so it can be extended without changing logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dd5586b6-f561-4e2b-80bb-b5c1ca15f782
📒 Files selected for processing (13)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/LayoutGeometryProcessor.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetAnnotationMatcher.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleaner.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/WidgetFactory.ktcv-image-to-xml/src/test/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParserTest.kt
💤 Files with no reviewable changes (2)
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetAnnotationMatcher.kt
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt
|
Wait, the title of this PR does not match what I expected |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt (2)
13-24: ⚡ Quick winDe-duplicate the identity
ValueCleaner.
ValueCleaner { it }is allocated both as the value forValueType.RAW(Line 23) and as the fallback insideflushAttribute(Line 84). Hoisting it into a singleprivate val(or a named object) avoids the duplication, ensures both call sites stay in sync if the identity behavior ever changes, and saves a small allocation perflushAttributeinvocation when avalueTypehas no registered cleaner.♻️ Proposed refactor
+ private val identityCleaner = ValueCleaner { it } + private val cleaners = mapOf( ValueType.TEXT_CONTENT to TextContentCleaner, ValueType.DIMENSION to DimensionCleaner, ValueType.SP_DIMENSION to SpDimensionCleaner, ValueType.COLOR to ColorCleaner, ValueType.ID to IdCleaner, ValueType.DRAWABLE to DrawableCleaner, ValueType.INTEGER to NumberCleaner, ValueType.FLOAT to FloatCleaner, ValueType.TEXT_STYLE to TextStyleCleaner, - ValueType.RAW to ValueCleaner { it } + ValueType.RAW to identityCleaner ) @@ - val cleaner = cleaners[key.valueType] ?: ValueCleaner { it } + val cleaner = cleaners[key.valueType] ?: identityCleanerAlso applies to: 81-91
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt` around lines 13 - 24, The map 'cleaners' currently instantiates an identity ValueCleaner twice (as ValueType.RAW and again inside flushAttribute fallback); create a single private val (e.g., identityCleaner or IdentityValueCleaner) and replace both occurrences so both the 'cleaners' entry for ValueType.RAW and the fallback in flushAttribute reference that single instance, eliminating duplication and extra allocations while keeping behavior identical.
112-116: 💤 Low valueUse
AndroidWidgetTags.BUTTONinstead of hardcoded"Button"string.Line 113 uses
tag == "Button"as a hardcoded literal, butAndroidWidgetTags.BUTTONconstant is already defined in the codebase. ImportAndroidWidgetTagsand replace the hardcoded string to maintain consistency with the project's centralized widget tag constants.if (key == AttributeKey.BACKGROUND && tag == AndroidWidgetTags.BUTTON) return "app:backgroundTint" to value🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt` around lines 112 - 116, In resolveXmlAttribute, replace the hardcoded tag comparison "Button" with the centralized constant AndroidWidgetTags.BUTTON: update the conditional that checks AttributeKey.BACKGROUND to use AndroidWidgetTags.BUTTON (ensure AndroidWidgetTags is imported) so the line inside the resolveXmlAttribute function uses AndroidWidgetTags.BUTTON instead of the literal string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Line 106: The threshold branch in FuzzyAttributeParser (variable normalizedKey
-> threshold) treats keys of length == 6 specially which is likely accidental;
either (A) if the intent is to target keys up to 6 characters, change the
condition from "== 6" to "<= 6", or (B) if the special-case for exactly 6 chars
is intentional, add a one-line comment above the threshold assignment
documenting why 6 is privileged (with examples of keys or rationale) so future
readers/tests understand the magic numbers.
---
Nitpick comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Around line 13-24: The map 'cleaners' currently instantiates an identity
ValueCleaner twice (as ValueType.RAW and again inside flushAttribute fallback);
create a single private val (e.g., identityCleaner or IdentityValueCleaner) and
replace both occurrences so both the 'cleaners' entry for ValueType.RAW and the
fallback in flushAttribute reference that single instance, eliminating
duplication and extra allocations while keeping behavior identical.
- Around line 112-116: In resolveXmlAttribute, replace the hardcoded tag
comparison "Button" with the centralized constant AndroidWidgetTags.BUTTON:
update the conditional that checks AttributeKey.BACKGROUND to use
AndroidWidgetTags.BUTTON (ensure AndroidWidgetTags is imported) so the line
inside the resolveXmlAttribute function uses AndroidWidgetTags.BUTTON instead of
the literal string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e2a5f006-db5e-4d90-97d0-d000a841a878
📒 Files selected for processing (4)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/ui/viewmodel/ComputerVisionViewModel.kt
✅ Files skipped from review due to trivial changes (1)
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/ui/viewmodel/ComputerVisionViewModel.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
207e958 to
167eb3d
Compare
76cf0f7 to
3606e17
Compare
3606e17 to
cde11fd
Compare
Resolves the issue by defaulting to textPassword when hint indicates a password field.
Preserve explicit margin tags and stop inferring EditText inputType from hint text
cde11fd to
c204d68
Compare
Description
Updates the sketch-to-UI computer vision logic to properly assign the
textPasswordinputType toEditTextwidgets when the hint indicates a password field. This ensures the generated Android XML correctly hides input characters instead of rendering a standard visible text entry box. Additionally, this PR introduces a structural refactor to the attribute parsing logic by breaking down the monolithicFuzzyAttributeParserinto modular, domain-specific cleaner components.Details
AndroidWidget.ktto handle password hints appropriately.FuzzyAttributeParser.ktinto modular components (AttributeModels.kt,ValueCleaner.kt,ValueCleanersImpl.kt).MarginAnnotationParser.kt.LayoutGeometryProcessor.kt.WidgetGrammardefinitions with structured attribute value sets.Screen.Recording.2026-05-07.at.12.59.49.PM.mov
Ticket
ADFA-3900
Observation
Note: This PR also includes a structural refactor of
FuzzyAttributeParserinto a dedicatedparserpackage (separating outAttributeModels,ValueCleaner, andValueCleanersImpl) to improve maintainability and cleanliness of the parsing domain.