-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #4848: Ensure Complete Content Descriptions for Custom HTML Tags in CustomHtmlContentHandler #5614
Conversation
Coverage ReportResultsNumber of files assessed: 4 Passing coverageFiles with passing code coverage
|
APK & AAB differences analysisNote that this is a summarized snapshot. See the CI artifacts for detailed differences. DevExpand to see flavor specificsUniversal APKAPK file size: 19 MiB (old), 19 MiB (new), 1692 bytes (Added) APK download size (estimated): 17 MiB (old), 17 MiB (new), 954 bytes (Added) Method count: 260196 (old), 260209 (new), 13 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6818 (old), 6818 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 18 MiB (old), 18 MiB (new), 1696 bytes (Added) Configuration hdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 49 KiB (old), 49 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 86 KiB (old), 86 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 57 KiB (old), 57 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) AlphaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 328 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 10 bytes (Removed) Method count: 116267 (old), 116271 (new), 4 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 328 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) BetaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 164 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 3778 bytes (Added) Method count: 116273 (old), 116277 (new), 4 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 164 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) GaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 336 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 2652 bytes (Added) Method count: 116273 (old), 116277 (new), 4 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 336 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) |
@manas-yu, please assign to a reviewer if ready for a pass. |
Hey @adhiamboperes PTAL, the PR is now ready for review. I've made the necessary code changes and would appreciate your feedback on the approach. Let me know if you have any suggestions or if any improvements are needed. Thanks! |
Coverage ReportResultsNumber of files assessed: 6 Passing coverageFiles with passing code coverage
|
APK & AAB differences analysisNote that this is a summarized snapshot. See the CI artifacts for detailed differences. DevExpand to see flavor specificsUniversal APKAPK file size: 19 MiB (old), 19 MiB (new), 3372 bytes (Added) APK download size (estimated): 17 MiB (old), 17 MiB (new), 4542 bytes (Added) Method count: 260202 (old), 260219 (new), 17 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6818 (old), 6818 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 18 MiB (old), 18 MiB (new), 3372 bytes (Added) Configuration hdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 49 KiB (old), 49 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 86 KiB (old), 86 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 57 KiB (old), 57 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) AlphaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 276 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 194 bytes (Added) Method count: 116280 (old), 116286 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 280 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) BetaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 272 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 1818 bytes (Added) Method count: 116286 (old), 116292 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 272 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) GaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 220 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 853 bytes (Added) Method count: 116286 (old), 116292 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 228 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @manas-yu! PTAL at some suggestions that I have left.
utility/src/main/java/org/oppia/android/util/parser/html/ImageTagHandler.kt
Outdated
Show resolved
Hide resolved
utility/src/main/java/org/oppia/android/util/parser/html/ImageTagHandler.kt
Outdated
Show resolved
Hide resolved
utility/src/main/java/org/oppia/android/util/parser/html/ImageTagHandler.kt
Outdated
Show resolved
Hide resolved
utility/src/test/java/org/oppia/android/util/parser/html/ConceptCardTagHandlerTest.kt
Show resolved
Hide resolved
utility/src/test/java/org/oppia/android/util/parser/html/CustomHtmlContentHandlerTest.kt
Show resolved
Hide resolved
utility/src/test/java/org/oppia/android/util/parser/html/PolicyPageTagHandlerTest.kt
Show resolved
Hide resolved
utility/src/main/java/org/oppia/android/util/parser/html/PolicyPageTagHandler.kt
Outdated
Show resolved
Hide resolved
Coverage ReportResultsNumber of files assessed: 6 Passing coverageFiles with passing code coverage
|
Hey @adhiamboperes, PTAL, I have made the requested changes. Let me know if there is anything else. |
Coverage ReportResultsNumber of files assessed: 6 Passing coverageFiles with passing code coverage
|
APK & AAB differences analysisNote that this is a summarized snapshot. See the CI artifacts for detailed differences. DevExpand to see flavor specificsUniversal APKAPK file size: 19 MiB (old), 19 MiB (new), 2972 bytes (Added) APK download size (estimated): 17 MiB (old), 17 MiB (new), 3626 bytes (Added) Method count: 260202 (old), 260219 (new), 17 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6818 (old), 6818 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 18 MiB (old), 18 MiB (new), 2976 bytes (Added) Configuration hdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 49 KiB (old), 49 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 86 KiB (old), 86 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 57 KiB (old), 57 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) AlphaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 376 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 35 bytes (Removed) Method count: 116281 (old), 116287 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 380 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) BetaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 200 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 252 bytes (Added) Method count: 116287 (old), 116293 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 196 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) GaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 208 bytes (Added) APK download size (estimated): 10 MiB (old), 10 MiB (new), 1950 bytes (Added) Method count: 116287 (old), 116293 (new), 6 (Added) Features: 2 (old), 2 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 5786 (old), 5786 (new), 0 (No change)
Lesson assets: 111 (old), 111 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 208 bytes (Added) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @manas-yu! This LGTM!
Unassigning @adhiamboperes since they have already approved the PR. |
Hi @manas-yu, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to ask someone to merge your PR once the CI checks pass and you're happy with it. Thanks! |
## Explanation Fixes #4097, Fix #4848 and Fix #4170 This PR resolves the TODOs left in #5627, #5614 and #5647. 1. **Integrating `getContentDescription` in `HintViewModel`:** - Replaced `fromHtml` with `getContentDescription` introduced in #4848. - Added `ConceptCardTagHandler` to `customTagHandlers` for handling `CUSTOM_CONCEPT_CARD_TAG`. - Injected `ConceptCardLinkClickListener` into the `HintsAndSolutionViewModel.Factory`. 2. **Resolving TODOs for #4097:** - Removed TODOs and text-file-exemptions(in scripts/assets) for `FractionSubject`, `MathExpressionSubject`, `RealSubject`, and `MathEquationSubject`. 3. **Resolving TODOs for #4170 :** - Removed TODO comment from `MathTagHandler`. ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). --------- Co-authored-by: Adhiambo Peres <[email protected]>
originalContentHandler?.endElement(uri, localName, qName) | ||
if (localName in blockTags) { | ||
isInListItem = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have been:
val tagName = qName ?: localName // Fallback to localName if qName is null
if (tagName in blockTags) {
isInListItem = false
}
qName (qualified name) is generally more reliable unless your parser enforces namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a post-merge review. I have some questions. PTAL @manas-yu.
contentDescriptionBuilder.append('\n') | ||
pendingNewline = false | ||
} | ||
ch?.let { contentDescriptionBuilder.append(String(it, start, length)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ch?.let { contentDescriptionBuilder.appendRange(it, start, start + length) }
private val contentDescriptionBuilder = StringBuilder() | ||
private val tagContentDescriptions = mutableMapOf<Int, String>() | ||
private var isInListItem = false | ||
private var pendingNewline = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what pending new line here means, maybe a rename or adding a comment might clear things up. I had a bit of trouble understanding how it is used in override fun characters
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It acts as a flag that indicates whether a newline character should be inserted before the next text content. It's used when dealing with block-level HTML elements
* Returns the content description for the HTML content, processing all custom tags that implement | ||
* [ContentDescriptionProvider]. | ||
*/ | ||
fun <T> getContentDescription( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that while this function was created, it was not used as required by the issue description. The only present usage is in HintViewModel
, which means descriptions will be geneerated for Hints only. I believe that other content viewmodels need to use this too, in order to correctly generate descriptions.
According to #4848, we should ensure descriptions are generated for answers, link cases, including anchors, or any case when text can appear between tags. This means this new function should be used with ContentViewModel
and SelectionInteractionContentViewModel
.
HtmlCompat.fromHtml( | ||
"<init-custom-handler/>$html", | ||
HtmlCompat.FROM_HTML_MODE_LEGACY, | ||
imageRetriever, | ||
handler | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code appears unused, what does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is not unused, It triggers the HTML parsing process, allowing CustomHtmlContentHandler
to intercept tags, extract content, and populate contentDescriptionBuilder
to generate the final content description.
This approach leverages Android’s built-in HTML parsing system, ensuring compatibility with the framework’s expectations, and allows the reuse of the same parsing logic for both content description and display purposes.
I'll add comments explaining this and the pendingNewline
in the PR to resolve:
This means this new function should be used with ContentViewModel and SelectionInteractionContentViewModel.
@@ -23,7 +24,7 @@ const val CUSTOM_LIST_OL_TAG = "oppia-ol" | |||
class LiTagHandler( | |||
private val context: Context, | |||
private val displayLocale: OppiaLocale.DisplayLocale | |||
) : CustomHtmlContentHandler.CustomTagHandler { | |||
) : CustomHtmlContentHandler.CustomTagHandler, CustomHtmlContentHandler.ContentDescriptionProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since getContentDescription
doesn't do anything here, I don't think
CustomHtmlContentHandler.ContentDescriptionProvider
should be implemented here.
Explanation
Fix #4848: This PR resolves the issue with incomplete content descriptions being generated for custom HTML tags. The existing implementation stripped out spans and custom tag content, leading to incomplete descriptions.
The updated implementation introduces a custom generation pipeline for content descriptions in
CustomHtmlContentHandler
. It ensures that all custom tag content is correctly processed and appended, resulting in complete and accurate descriptions.Key Changes:
StringBuilder
to accumulate content descriptions and aMutableMap
to handle custom tag descriptions.getContentDescription()
to combine default text with custom tag content descriptions, ensuring seamless integration.ContentDescriptionProvider
interface for handling custom tags.ImageTagHandler
,ConceptCardTagHandler
,LiTagHandler
,PolicyPageTagHandler
andMathTagHandler
) to implement the new interface.Essential Checklist