diff --git a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt index 89a819763b6..50d6f88c352 100644 --- a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt @@ -54,7 +54,9 @@ class UrlImageParser private constructor( val imageUrl = "$gcsPrefix/$gcsResourceName/$imagePath" val proxyDrawable = ProxyDrawable() // TODO(#1039): Introduce custom type OppiaImage for rendering Bitmap and Svg. - val isSvg = machineLocale.run { imageUrl.endsWithIgnoreCase("svg") } + val isSvg = machineLocale.run { + imageUrl.endsWithIgnoreCase("svg") || imageUrl.endsWithIgnoreCase("svgz") + } val adjustedType = if (type == INLINE_TEXT_IMAGE && !isSvg) { // Treat non-svg in-line images as block, instead, since only SVG is supported. consoleLogger.w("UrlImageParser", "Forcing image $filename to block image") diff --git a/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt b/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt index 8d78cc635d3..d1480089590 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/image/UrlImageParserTest.kt @@ -79,6 +79,15 @@ class UrlImageParserTest { assertThat(loadedBitmaps.first()).contains("test_image.svg") } + @Test + fun testGetDrawable_svgz_loadsSvgzBlockImage() { + urlImageParser.getDrawable("test_image.svgz") + + val loadedBitmaps = testGlideImageLoader.getLoadedBlockSvgs() + assertThat(loadedBitmaps).hasSize(1) + assertThat(loadedBitmaps.first()).contains("test_image.svgz") + } + @Test fun testLoadDrawable_bitmap_blockType_loadsBitmapImage() { urlImageParser.loadDrawable("test_image.png", BLOCK_IMAGE) @@ -109,6 +118,15 @@ class UrlImageParserTest { assertThat(loadedBitmaps.first()).contains("test_image.svg") } + @Test + fun testLoadDrawable_svgz_blockType_loadsSvgzBlockImage() { + urlImageParser.loadDrawable("test_image.svgz", BLOCK_IMAGE) + + val loadedBitmaps = testGlideImageLoader.getLoadedBlockSvgs() + assertThat(loadedBitmaps).hasSize(1) + assertThat(loadedBitmaps.first()).contains("test_image.svgz") + } + @Test fun testLoadDrawable_svg_inlineType_loadsSvgTextImage() { urlImageParser.loadDrawable("test_image.svg", INLINE_TEXT_IMAGE) @@ -119,6 +137,16 @@ class UrlImageParserTest { assertThat(loadedBitmaps.first()).contains("test_image.svg") } + @Test + fun testLoadDrawable_svgz_inlineType_loadsSvgzTextImage() { + urlImageParser.loadDrawable("test_image.svgz", INLINE_TEXT_IMAGE) + + // The request to load the bitmap inline is ignored since inline bitmaps aren't supported. + val loadedBitmaps = testGlideImageLoader.getLoadedTextSvgs() + assertThat(loadedBitmaps).hasSize(1) + assertThat(loadedBitmaps.first()).contains("test_image.svgz") + } + @Test fun testLoadDrawable_latex_inlineType_loadsInlineLatexImage() { urlImageParser.loadMathDrawable(