@@ -37,6 +37,7 @@ import dev.secam.simpletag.data.MusicData
3737import dev.secam.simpletag.data.SimpleTagField
3838import dev.secam.simpletag.data.preferences.PreferencesRepo
3939import dev.secam.simpletag.data.preferences.UserPreferences
40+ import dev.secam.simpletag.util.setArtworkField
4041import kotlinx.coroutines.CoroutineExceptionHandler
4142import kotlinx.coroutines.Deferred
4243import kotlinx.coroutines.Dispatchers
@@ -91,10 +92,10 @@ class EditorViewModel @Inject constructor(
9192 }!!
9293 }
9394
94- fun isCompatible (ext : String ): Boolean {
95- val types = listOf (" mp3" , " wav" , " wave" , " dsf" , " aiff" , " aif" , " aifc" , " wma" , " ogg" , " mp4" , " m4a" , " m4p" , " flac" )
96- return types.contains(ext)
97- }
95+ // fun isCompatible(ext: String): Boolean {
96+ // val types = listOf("mp3", "wav", "wave", "dsf", "aiff", "aif", "aifc", "wma", "ogg", "mp4", "m4a", "m4p", "flac")
97+ // return types.contains(ext)
98+ // }
9899 fun getArtworkFromUri (contentResolver : ContentResolver , uri : Uri ): Artwork ? {
99100 var path: String? = null
100101 val projection = arrayOf(
@@ -127,7 +128,13 @@ class EditorViewModel @Inject constructor(
127128 }
128129 val tag = file.tag
129130 tag.deleteArtworkField()
130- if (artwork != null ) tag.setField(artwork)
131+ if (artwork != null ) {
132+ if (tag.javaClass == FlacTag ().javaClass) {
133+ (tag as FlacTag ).setArtworkField(artwork)
134+ }
135+ else tag.setField(artwork)
136+
137+ }
131138
132139 for (field in fields) {
133140 tag.setField(field.key.fieldKey, field.value.text as String )
@@ -252,6 +259,7 @@ class EditorViewModel @Inject constructor(
252259 _uiState .update { it.copy(artworkChanged = artworkChanged) }
253260 }
254261
262+
255263}
256264
257265data class EditorUiState (
@@ -263,4 +271,5 @@ data class EditorUiState(
263271 val showBackDialog : Boolean = false ,
264272 val showSaveDialog : Boolean = false ,
265273 val savedFields : List <String > = listOf()
266- )
274+ )
275+
0 commit comments