am 5fd26775: Merge change 9390 into donut

Merge commit '5fd26775bdd14b15058521c82e34b562e0c1e327'

* commit '5fd26775bdd14b15058521c82e34b562e0c1e327':
  Name unknown albums after the folder they're in, similar to how songs
This commit is contained in:
Android (Google) Code Review
2009-08-03 11:54:18 -07:00
committed by Android Git Automerger

View File

@@ -681,6 +681,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);