File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 194194 </c : change >
195195 </c : changes >
196196 </c : release >
197- <c : release date =" 2025-01-13T20:49:03+00:00" is-open =" true" ticket-system =" org.lyrasis.jira" version =" 6.8.0" >
198- <c : changes />
197+ <c : release date =" 2025-08-18T11:42:05+00:00" is-open =" true" ticket-system =" org.lyrasis.jira" version =" 6.8.0" >
198+ <c : changes >
199+ <c : change date =" 2025-08-18T11:42:05+00:00" summary =" Add SVG support." >
200+ <c : tickets >
201+ <c : ticket id =" PP-2691" />
202+ </c : tickets >
203+ </c : change >
204+ </c : changes >
199205 </c : release >
200206 </c : releases >
201207 <c : ticket-systems >
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ import org.readium.r2.shared.util.ErrorException
5353import org.readium.r2.shared.util.Try
5454import org.readium.r2.shared.util.Url
5555import org.readium.r2.shared.util.asset.AssetRetriever
56+ import org.readium.r2.shared.util.asset.DefaultArchiveOpener
57+ import org.readium.r2.shared.util.asset.DefaultFormatSniffer
58+ import org.readium.r2.shared.util.asset.DefaultResourceFactory
5659import org.readium.r2.shared.util.data.asInputStream
5760import org.readium.r2.shared.util.getOrElse
5861import org.readium.r2.shared.util.http.DefaultHttpClient
@@ -120,7 +123,13 @@ internal class SR2Controller private constructor(
120123 val httpClient =
121124 DefaultHttpClient (userAgent = " ${BuildConfig .LIBRARY_PACKAGE_NAME } /${BuildConfig .R2_VERSION_NAME } " )
122125 val assetRetriever =
123- AssetRetriever (context.contentResolver, httpClient)
126+ AssetRetriever (
127+ DefaultResourceFactory (context.contentResolver, httpClient),
128+ DefaultArchiveOpener (),
129+ DefaultFormatSniffer (
130+ listOf (SVGSniffer ()),
131+ ),
132+ )
124133
125134 val publicationParser =
126135 DefaultPublicationParser (
Original file line number Diff line number Diff line change 1+ package org.librarysimplified.r2.vanilla.internal
2+
3+ import org.readium.r2.shared.util.FileExtension
4+ import org.readium.r2.shared.util.format.Format
5+ import org.readium.r2.shared.util.format.FormatHints
6+ import org.readium.r2.shared.util.format.FormatSniffer
7+ import org.readium.r2.shared.util.format.FormatSpecification
8+ import org.readium.r2.shared.util.format.Specification
9+ import org.readium.r2.shared.util.mediatype.MediaType
10+
11+ class SVGSniffer : FormatSniffer {
12+
13+ private object Svg : Specification
14+
15+ private val svgFormat = Format (
16+ specification = FormatSpecification (Svg ),
17+ fileExtension = FileExtension (" svg" ),
18+ mediaType = MediaType .SVG ,
19+ )
20+
21+ override fun sniffHints (
22+ hints : FormatHints ,
23+ ): Format ? {
24+ if (
25+ hints.hasFileExtension(" svg" ) ||
26+ hints.hasMediaType(MediaType .SVG .toString())
27+ ) {
28+ return this .svgFormat
29+ }
30+ return null
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments