diff options
author | Marco Nelissen <marcone@google.com> | 2009-07-31 15:02:25 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2009-07-31 15:02:25 -0700 |
commit | c3c08ba5d67d836274fabdf4c1bff6f1053d95a3 (patch) | |
tree | 16f09b993f714ad7534b4def936405aeef6361e8 /media | |
parent | 17c195c8da3470b2e69880e206342f0c2d85f938 (diff) | |
download | frameworks_base-c3c08ba5d67d836274fabdf4c1bff6f1053d95a3.zip frameworks_base-c3c08ba5d67d836274fabdf4c1bff6f1053d95a3.tar.gz frameworks_base-c3c08ba5d67d836274fabdf4c1bff6f1053d95a3.tar.bz2 |
Name unknown albums after the folder they're in, similar to how songs
with no title metadata are named after the file. Only files that are
in the root of the card will still belong to the "Unknown Album"
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaScanner.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 95f3680..8db874a 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -674,6 +674,26 @@ public class MediaScanner } values.put(MediaStore.MediaColumns.TITLE, title); } + String album = values.getAsString(Audio.Media.ALBUM); + if (MediaFile.UNKNOWN_STRING.equals(album)) { + album = values.getAsString(MediaStore.MediaColumns.DATA); + // extract last path segment before file name + int lastSlash = album.lastIndexOf('/'); + if (lastSlash >= 0) { + int previousSlash = 0; + while (true) { + int idx = album.indexOf('/', previousSlash + 1); + if (idx < 0 || idx >= lastSlash) { + break; + } + previousSlash = idx; + } + if (previousSlash != 0) { + album = album.substring(previousSlash + 1, lastSlash); + values.put(Audio.Media.ALBUM, album); + } + } + } if (isAudio) { values.put(Audio.Media.IS_RINGTONE, ringtones); values.put(Audio.Media.IS_NOTIFICATION, notifications); |