Skip to content

Commit c99c947

Browse files
authored
Merge pull request #3639 from owncloud/feature/preview_svg
Previewing SVG files works
2 parents 8c46e6d + 49ed79b commit c99c947

6 files changed

Lines changed: 29 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Summary
2525
* Enhancement - New option to show or not hidden files: [#2578](https://github.com/owncloud/android/issues/2578)
2626
* Enhancement - Option to allow screenshots or not in Android Enterprise: [#3625](https://github.com/owncloud/android/issues/3625)
2727
* Enhancement - Full name is shown in shares: [#1106](https://github.com/owncloud/android/issues/1106)
28+
* Enhancement - Support for SVG files added: [#1033](https://github.com/owncloud/android/issues/1033)
2829
* Enhancement - Improved copy/move dialog: [#1414](https://github.com/owncloud/android/issues/1414)
2930
* Enhancement - Thumbnail click action in file detail: [#3653](https://github.com/owncloud/android/pull/3653)
3031

@@ -163,6 +164,13 @@ Details
163164
https://github.com/owncloud/android/issues/1106
164165
https://github.com/owncloud/android/pull/3636
165166

167+
* Enhancement - Support for SVG files added: [#1033](https://github.com/owncloud/android/issues/1033)
168+
169+
SVG files are supported and can be downloaded and viewed.
170+
171+
https://github.com/owncloud/android/issues/1033
172+
https://github.com/owncloud/android/pull/3639
173+
166174
* Enhancement - Improved copy/move dialog: [#1414](https://github.com/owncloud/android/issues/1414)
167175

168176
Previously,they appeared exactly the same and there was no way of knowing which was which. Now

changelog/unreleased/3639

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Enhancement: Support for SVG files added
2+
3+
SVG files are supported and can be downloaded and viewed.
4+
5+
https://github.com/owncloud/android/issues/1033
6+
https://github.com/owncloud/android/pull/3639

owncloudApp/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626

2727
// Image loading
2828
implementation 'com.github.bumptech.glide:glide:4.12.0'
29+
implementation 'com.github.corouteam:GlideToVectorYou:v2.0.0'
2930

3031
// CustomTabs required for OAuth2 and OIDC.
3132
implementation "androidx.browser:browser:1.4.0"

owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ package com.owncloud.android.ui.preview
2727

2828
import android.accounts.Account
2929
import android.graphics.Bitmap
30+
import android.graphics.Color
3031
import android.graphics.drawable.Drawable
3132
import android.os.Bundle
3233
import android.view.LayoutInflater
@@ -47,6 +48,7 @@ import com.owncloud.android.R
4748
import com.owncloud.android.databinding.PreviewImageFragmentBinding
4849
import com.owncloud.android.databinding.TopProgressBarBinding
4950
import com.owncloud.android.datamodel.OCFile
51+
import com.owncloud.android.domain.files.MIME_SVG
5052
import com.owncloud.android.files.FileMenuFilter
5153
import com.owncloud.android.ui.controller.TransferProgressController
5254
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment
@@ -120,6 +122,8 @@ class PreviewImageFragment : FileFragment() {
120122
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
121123
super.onViewCreated(view, savedInstanceState)
122124

125+
binding.top.setBackgroundColor(getBackgroundColor(file))
126+
123127
binding.photoView.isVisible = false
124128
binding.photoView.setOnClickListener {
125129
(requireActivity() as PreviewImageActivity).toggleFullScreen()
@@ -330,13 +334,21 @@ class PreviewImageFragment : FileFragment() {
330334
dataSource: DataSource, isFirstResource: Boolean
331335
): Boolean {
332336
Timber.d("Loading image %s", file.fileName)
337+
binding.progressWheel.isVisible = false
333338
return false
334339
}
335340
})
336341
.into(binding.photoView)
342+
337343
binding.photoView.isVisible = true
338344
}
339345

346+
private fun isSVGFile(file: OCFile): Boolean = file.mimetype == MIME_SVG
347+
348+
private fun getBackgroundColor(file: OCFile): Int {
349+
return if (isSVGFile(file)) Color.WHITE else Color.BLACK
350+
}
351+
340352
/**
341353
* Finishes the preview
342354
*/

owncloudApp/src/main/res/layout/preview_image_fragment.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
android:id="@+id/top"
2323
android:layout_width="match_parent"
2424
android:layout_height="match_parent"
25-
android:background="#000000"
2625
android:filterTouchesWhenObscured="true"
2726
tools:context=".ui.preview.PreviewImageFragment">
2827

@@ -46,7 +45,7 @@
4645
app:layout_constraintLeft_toLeftOf="parent"
4746
app:layout_constraintRight_toRightOf="parent"
4847
app:layout_constraintTop_toTopOf="parent"
49-
app:layout_constraintBottom_toBottomOf="parent"/>
48+
app:layout_constraintBottom_toBottomOf="parent" />
5049

5150
<TextView
5251
android:id="@+id/errorText"

owncloudDomain/src/main/java/com/owncloud/android/domain/files/MimeTypeConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ package com.owncloud.android.domain.files
2121

2222
const val MIME_DIR = "DIR"
2323
const val MIME_DIR_UNIX = "httpd/unix-directory"
24+
const val MIME_SVG = "image/svg+xml"
2425
val LIST_MIME_DIR = listOf(MIME_DIR, MIME_DIR_UNIX)

0 commit comments

Comments
 (0)