diff --git a/app/src/main/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserViewModel.kt b/app/src/main/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserViewModel.kt index e808c6fdb68..95fb16f7a05 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserViewModel.kt @@ -31,12 +31,7 @@ class MathExpressionParserViewModel @Inject constructor( private val htmlParserFactory: HtmlParser.Factory ) : ObservableViewModel() { private val htmlParser by lazy { - // TODO(#4206): Replace this with the variant that doesn't require GCS properties. htmlParserFactory.create( - gcsResourceName = "", - entityType = "", - entityId = "", - imageCenterAlign = false, displayLocale = appLanguageResourceHandler.getDisplayLocale() ) } diff --git a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt index 97db2dce9db..f08fcfe807a 100755 --- a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt @@ -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 @@ -124,11 +123,17 @@ class HtmlParser private constructor( } val imageGetter = urlImageParserFactory?.create( - htmlContentTextView, gcsResourceName, entityType, entityId, imageCenterAlign + htmlContentTextView, + gcsResourceName, + entityType, + entityId, + imageCenterAlign ) val htmlSpannable = CustomHtmlContentHandler.fromHtml( - htmlContent, imageGetter, computeCustomTagHandlers(supportsConceptCards, htmlContentTextView) + htmlContent, + imageGetter, + computeCustomTagHandlers(supportsConceptCards, htmlContentTextView) ) val urlPattern = Patterns.WEB_URL @@ -226,17 +231,40 @@ class HtmlParser private constructor( displayLocale: OppiaLocale.DisplayLocale ): HtmlParser { return HtmlParser( - context, - urlImageParserFactory, - gcsResourceName, - entityType, - entityId, - imageCenterAlign, - consoleLogger, + context = context, + urlImageParserFactory = urlImageParserFactory, + gcsResourceName = gcsResourceName, + entityType = entityType, + entityId = entityId, + imageCenterAlign = imageCenterAlign, + consoleLogger = consoleLogger, cacheLatexRendering = enableCacheLatexRendering.value, - customOppiaTagActionListener, - null, - displayLocale + customOppiaTagActionListener = customOppiaTagActionListener, + policyOppiaTagActionListener = null, + displayLocale = displayLocale + ) + } + + /** + * 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( + displayLocale: OppiaLocale.DisplayLocale + ): HtmlParser { + return HtmlParser( + context = context, + urlImageParserFactory = urlImageParserFactory, + gcsResourceName = "", + entityType = "", + entityId = "", + imageCenterAlign = false, + consoleLogger = consoleLogger, + cacheLatexRendering = enableCacheLatexRendering.value, + customOppiaTagActionListener = null, + policyOppiaTagActionListener = null, + displayLocale = displayLocale ) }