Skip to content

Commit

Permalink
feat: Added artwork editing
Browse files Browse the repository at this point in the history
This commit introduces the ability to edit artwork for audio files.

- Added functionality to save artwork along with other metadata.
-
 Updated the UI to allow users to select and save new artwork.

Signed-off-by: Gabriel Fontán <[email protected]>
  • Loading branch information
BobbyESP committed Jul 31, 2024
1 parent 51b943d commit 76909ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ fun MetadataEditorPage(
}
TextButton(
onClick = {
onEvent(MetadataEditorVM.Event.SaveProperties(receivedAudio.localPath))
onEvent(
MetadataEditorVM.Event.SaveAll(
receivedAudio.localPath,
listOf(newArtworkAddress ?: receivedAudio.artworkPath ?: Uri.EMPTY)
)
)
}
) {
Text(text = stringResource(id = R.string.save))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,20 @@ class MetadataEditorVM @Inject constructor(
}

is Event.SaveAll -> {
val propertiesSaved = savePropertyMap(audioPath = event.path, intentPassthrough = {
emitUiEvent(UiEvent.RequestPermission(it))
})
val propertiesSaved = savePropertyMap(
audioPath = event.path,
intentPassthrough = {
emitUiEvent(UiEvent.RequestPermission(it))
}
)

val succeededPictures = savePictures(
audioPath = event.path,
imagesUri = emptyList(),
imagesUri = event.imagesUri,
intentPassthrough = {
emitUiEvent(UiEvent.RequestPermission(it))
})
}
)

if (propertiesSaved || succeededPictures) {
emitUiEvent(
Expand All @@ -369,10 +373,6 @@ class MetadataEditorVM @Inject constructor(
}

is Event.UpdateProperty -> {
Log.i(
"MetadataEditorVM",
"Received property ${event.key} with value ${event.value}"
)
updateMapProperty(event.key, event.value)
}
}
Expand All @@ -381,7 +381,7 @@ class MetadataEditorVM @Inject constructor(

interface Event {
data class LoadMetadata(val path: String) : Event
data class SaveAll(val path: String) : Event
data class SaveAll(val path: String, val imagesUri: List<Uri>) : Event
data class SaveProperties(val path: String) : Event
data class SavePictures(val path: String, val imagesUri: List<Uri>) : Event
data class UpdateProperty(val key: String, val value: String) : Event
Expand All @@ -391,6 +391,7 @@ class MetadataEditorVM @Inject constructor(
data class RequestPermission(val intent: PendingIntent) : UiEvent
data class SaveSuccess(val pictures: Boolean? = null, val properties: Boolean? = null) :
UiEvent

data object SaveFailed : UiEvent
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#General, lifecycle and core
agp = "8.7.0-alpha02"
firebaseCrashlyticsGradle = "2.9.0"
gradle = "8.7.0-alpha02"
kotlin = "2.0.0"
appcompat = "1.7.0"
core-ktx = "1.13.1"
Expand Down Expand Up @@ -79,6 +78,7 @@ androidx-baselineprofile = "1.2.4"
profileinstaller = "1.3.1"
media3DatasourceOkhttp = "1.4.0"
scrollbar = "2.2.0"
material = "1.12.0"

[libraries]
#Core libraries
Expand Down

0 comments on commit 76909ff

Please sign in to comment.