Skip to content
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 #4206 Create New HtmlParser Factory Method #5277

Merged
merged 25 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3936364
Resolve the test build error
XichengSpencer Jul 4, 2023
ed714a6
Change 1 concatenate string to 3 seperate text view
XichengSpencer Sep 12, 2023
f1c1bac
format code
XichengSpencer Sep 12, 2023
31b6f53
Merge branch 'oppia:develop' into #3843
XichengSpencer Sep 13, 2023
24050dc
Change the corresponding test.
XichengSpencer Sep 14, 2023
3406c78
Merge branch 'develop' into #3843
adhiamboperes Sep 19, 2023
b1bfe10
Merge remote-tracking branch 'origin/#3843' into #3843
XichengSpencer Sep 19, 2023
9c56e24
Remove TODO
XichengSpencer Sep 20, 2023
8d9cf96
Merge branch 'develop' into #3843
XichengSpencer Sep 22, 2023
6fe9746
remove testAddProfileActivity_inputPin_configChange_downloadAccessSwi…
XichengSpencer Nov 15, 2023
1cbe96d
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Nov 15, 2023
582f69d
Merge branch 'develop' into #3843
adhiamboperes Dec 4, 2023
40c44df
Add comment to explain the negating logic
XichengSpencer Dec 7, 2023
6824346
Merge remote-tracking branch 'origin/#3843' into #3843
XichengSpencer Dec 7, 2023
ebe5a28
Merge branch 'develop' into #3843
adhiamboperes Dec 7, 2023
b4b5f10
Add new HtmlParser create method that use less variables
XichengSpencer Dec 19, 2023
4802202
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Dec 19, 2023
e40a900
Merge remote-tracking branch 'origin/#3843' into #3843
XichengSpencer Dec 19, 2023
c362a55
Merge branch 'oppia:develop' into #3843
XichengSpencer Jan 2, 2024
015b502
Remove customOppiaTagActionListener as input arg in HtmlParser.kt cre…
XichengSpencer Jan 8, 2024
698a0d1
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Jan 8, 2024
783432a
Merge remote-tracking branch 'origin/#3843' into #3843
XichengSpencer Jan 8, 2024
74b599c
Remove TODO list and updated unnamed variable in both create function
XichengSpencer Jan 16, 2024
2fc2da8
Fix all unnamed variables
XichengSpencer Jan 17, 2024
a489412
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
XichengSpencer Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class MathExpressionParserViewModel @Inject constructor(
private val htmlParser by lazy {
// TODO(#4206): Replace this with the variant that doesn't require GCS properties.
htmlParserFactory.create(
gcsResourceName = "",
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
entityType = "",
entityId = "",
imageCenterAlign = false,
displayLocale = appLanguageResourceHandler.getDisplayLocale()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class HtmlParser private constructor(
supportsLinks: Boolean = false,
supportsConceptCards: Boolean = false
): Spannable {

var htmlContent = rawString

// Canvas does not support RTL, it always starts from left to right in RTL due to which compound drawables are
Expand Down Expand Up @@ -124,11 +123,17 @@ class HtmlParser private constructor(
}

val imageGetter = urlImageParserFactory?.create(
htmlContentTextView, gcsResourceName, entityType, entityId, imageCenterAlign
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
htmlContentTextView,
gcsResourceName,
entityType,
entityId,
imageCenterAlign
)

val htmlSpannable = CustomHtmlContentHandler.fromHtml(
htmlContent, imageGetter, computeCustomTagHandlers(supportsConceptCards, htmlContentTextView)
htmlContent,
imageGetter,
computeCustomTagHandlers(supportsConceptCards, htmlContentTextView)
)

val urlPattern = Patterns.WEB_URL
Expand Down Expand Up @@ -240,6 +245,29 @@ class HtmlParser private constructor(
)
}

/**
* Returns a new [HtmlParser] with the empty entity type and ID for loading images,
* doesn't require GCS properties and imageCenterAlign set to false
* optionally specified [CustomOppiaTagActionListener] for handling custom Oppia tag events.
*/
fun create(
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
displayLocale: OppiaLocale.DisplayLocale
): HtmlParser {
return HtmlParser(
context,
urlImageParserFactory,
gcsResourceName = "",
entityType = "",
entityId = "",
imageCenterAlign = false,
consoleLogger,
cacheLatexRendering = enableCacheLatexRendering.value,
customOppiaTagActionListener = null,
null,
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
displayLocale
)
}

/**
* Returns a new [HtmlParser] with an optionally specified [CustomOppiaTagActionListener] and
* [PolicyOppiaTagActionListener] for handling custom Oppia tag events. Note that Oppia image
Expand Down
Loading