Skip to content

Commit 3c78e65

Browse files
committed
refactor: create constants for image mime types
1 parent 17e9a29 commit 3c78e65

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ import com.owncloud.android.R
4747
import com.owncloud.android.databinding.FileOptionsBottomSheetFragmentBinding
4848
import com.owncloud.android.databinding.SpacesListFragmentBinding
4949
import com.owncloud.android.domain.files.model.FileListOption
50+
import com.owncloud.android.domain.files.model.MIME_BMP
51+
import com.owncloud.android.domain.files.model.MIME_GIF
52+
import com.owncloud.android.domain.files.model.MIME_JPEG
53+
import com.owncloud.android.domain.files.model.MIME_PNG
54+
import com.owncloud.android.domain.files.model.MIME_PREFIX_IMAGE
55+
import com.owncloud.android.domain.files.model.MIME_X_MS_BMP
5056
import com.owncloud.android.domain.spaces.model.OCSpace
5157
import com.owncloud.android.domain.spaces.model.SpaceMenuOption
5258
import com.owncloud.android.domain.transfers.model.TransferStatus
@@ -237,7 +243,7 @@ class SpacesListFragment :
237243
showSpaceMenuOptionsDialog(menuOptions)
238244
}
239245

240-
collectLatestLifecycleFlow(transfersViewModel.transfersWithSpaceStateFlow) { transfersWithSpace->
246+
collectLatestLifecycleFlow(transfersViewModel.transfersWithSpaceStateFlow) { transfersWithSpace ->
241247
val remotePath = SPACE_CONFIG_DIR + selectedImageName
242248
val matchedTransfer = transfersWithSpace.map { it.first }.find { it.remotePath == remotePath }
243249

@@ -423,8 +429,8 @@ class SpacesListFragment :
423429
SpaceMenuOption.EDIT_IMAGE -> {
424430
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
425431
addCategory(Intent.CATEGORY_OPENABLE)
426-
type = "image/*"
427-
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/jpeg", "image/png", "image/bmp", "image/x-ms-bmp", "image/gif"))
432+
type = MIME_PREFIX_IMAGE
433+
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf(MIME_JPEG, MIME_PNG, MIME_BMP, MIME_X_MS_BMP, MIME_GIF))
428434
}
429435
editSpaceImageLauncher.launch(action)
430436
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* ownCloud Android client application
33
*
44
* @author Abel García de Prada
5-
* Copyright (C) 2020 ownCloud GmbH.
5+
* @author Jorge Aguado Recio
6+
*
7+
* Copyright (C) 2025 ownCloud GmbH.
68
*
79
* This program is free software: you can redistribute it and/or modify
810
* it under the terms of the GNU General Public License version 2,
@@ -29,4 +31,9 @@ const val MIME_PREFIX_IMAGE = "image/"
2931
const val MIME_PREFIX_TEXT = "text/"
3032

3133
const val MIME_SVG = "image/svg+xml"
34+
const val MIME_JPEG = "image/jpeg"
35+
const val MIME_PNG = "image/png"
36+
const val MIME_BMP = "image/bmp"
37+
const val MIME_X_MS_BMP = "image/x-ms-bmp"
38+
const val MIME_GIF = "image/gif"
3239

0 commit comments

Comments
 (0)