From 72ac444ceb7d336cdea5b784a04557eef09d8a1d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Oct 2016 23:44:46 +0200 Subject: [PATCH] add artist and album to audios and videos if available --- .../filemanager/dialogs/PropertiesDialog.kt | 9 ++++++++- .../simplemobiletools/filemanager/extensions/file.kt | 12 ++++++++++++ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-it/strings.xml | 2 ++ app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values-pt-rPT/strings.xml | 2 ++ app/src/main/res/values-sv/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 8 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt index ebe209ec..dc076deb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt @@ -41,9 +41,13 @@ class PropertiesDialog() { addProperty(R.string.resolution, file.getImageResolution()) } else if (file.isAudio()) { addProperty(R.string.duration, file.getDuration()) + addProperty(R.string.artist, file.getArtist()) + addProperty(R.string.album, file.getAlbum()) } else if (file.isVideo()) { addProperty(R.string.duration, file.getDuration()) addProperty(R.string.resolution, file.getVideoResolution()) + addProperty(R.string.artist, file.getArtist()) + addProperty(R.string.album, file.getAlbum()) } AlertDialog.Builder(context) @@ -76,7 +80,10 @@ class PropertiesDialog() { .show() } - private fun addProperty(labelId: Int, value: String) { + private fun addProperty(labelId: Int, value: String?) { + if (value == null) + return + val view = mInflater.inflate(R.layout.property_item, mPropertyView, false) view.property_label.text = mResources.getString(labelId) view.property_value.text = value diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/file.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/file.kt index 6a4dc428..f9b77e71 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/file.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/file.kt @@ -36,6 +36,18 @@ fun File.getDuration(): String { return getFormattedDuration((timeInMillisec / 1000).toInt()) } +fun File.getArtist(): String? { + val retriever = MediaMetadataRetriever() + retriever.setDataSource(path) + return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST) +} + +fun File.getAlbum(): String? { + val retriever = MediaMetadataRetriever() + retriever.setDataSource(path) + return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM) +} + fun File.getVideoResolution(): String { try { val retriever = MediaMetadataRetriever() diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index e0b56600..3c234d62 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 Datei/Ordner gelöscht diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index feb9aeac..cd5dc879 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 elemento eliminato diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index ae136818..8991c84e 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 アイテムを削除しました diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 6c3a01c2..0d8145d9 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 item eliminado diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b28f3f25..ff715b7f 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 objekt borttagen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 64b14270..fc74a9fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,6 +44,8 @@ Total files count Resolution Duration + Artist + Album 1 item deleted