Skip to content
Open
Changes from all commits
Commits
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 @@ -64,8 +64,10 @@ import com.ichi2.utils.openInputStreamSafe
import com.ichi2.utils.positiveButton
import com.ichi2.utils.show
import dev.androidbroadcast.vbpd.viewBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.io.FileNotFoundException
Expand Down Expand Up @@ -551,14 +553,17 @@ class MultimediaImageFragment : MultimediaFragment(R.layout.fragment_multimedia_
* @param imageUri The URI of the SVG image.
*/
private fun WebView.loadSvgImage(imageUri: Uri) {
val svgData = loadSvgFromUri(imageUri)
if (svgData != null) {
Timber.i("Selected image is an SVG.")

loadDataWithBaseURL(null, svgData, SVG_IMAGE, "UTF-8", null)
} else {
Timber.w("Failed to load SVG from URI")
showErrorInWebView()
val webView = this
lifecycleScope.launch {
val svgData = withContext(Dispatchers.IO) { loadSvgFromUri(imageUri) }
if (svgData != null) {
Timber.i("Selected image is an SVG.")

webView.loadDataWithBaseURL(null, svgData, SVG_IMAGE, "UTF-8", null)
} else {
Timber.w("Failed to load SVG from URI")
showErrorInWebView()
}
}
}

Expand Down
Loading