@@ -27,6 +27,7 @@ package com.owncloud.android.ui.preview
2727
2828import android.accounts.Account
2929import android.graphics.Bitmap
30+ import android.graphics.Color
3031import android.graphics.drawable.Drawable
3132import android.os.Bundle
3233import android.view.LayoutInflater
@@ -120,6 +121,8 @@ class PreviewImageFragment : FileFragment() {
120121 override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
121122 super .onViewCreated(view, savedInstanceState)
122123
124+ binding.top.setBackgroundColor(getBackgroundColor(file))
125+
123126 binding.photoView.isVisible = false
124127 binding.photoView.setOnClickListener {
125128 (requireActivity() as PreviewImageActivity ).toggleFullScreen()
@@ -325,18 +328,26 @@ class PreviewImageFragment : FileFragment() {
325328 return false
326329 }
327330
328- override fun onResourceReady (
329- resource : Drawable ? , model : Any , target : Target <Drawable ?>,
330- dataSource : DataSource , isFirstResource : Boolean
331- ): Boolean {
332- Timber .d(" Loading image %s" , file.fileName)
333- return false
334- }
335- })
336- .into(binding.photoView)
331+ override fun onResourceReady (
332+ resource : Drawable ? , model : Any , target : Target <Drawable ?>,
333+ dataSource : DataSource , isFirstResource : Boolean
334+ ): Boolean {
335+ Timber .d(" Loading image %s" , file.fileName)
336+ binding.progressWheel.isVisible = false
337+ return false
338+ }
339+ })
340+ .into(binding.photoView)
341+
337342 binding.photoView.isVisible = true
338343 }
339344
345+ private fun isSVGFile (file : OCFile ): Boolean = file.mimetype == SVG_MIMETYPE
346+
347+ private fun getBackgroundColor (file : OCFile ): Int {
348+ return if (isSVGFile(file)) Color .WHITE else Color .BLACK
349+ }
350+
340351 /* *
341352 * Finishes the preview
342353 */
@@ -348,6 +359,7 @@ class PreviewImageFragment : FileFragment() {
348359 private const val ARG_FILE = " FILE"
349360 private const val ARG_ACCOUNT = " ACCOUNT"
350361 private const val ARG_IGNORE_FIRST = " IGNORE_FIRST"
362+ private const val SVG_MIMETYPE = " image/svg+xml"
351363
352364 /* *
353365 * Public factory method to create a new fragment that previews an image.
0 commit comments