Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fd26775 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 9390 into donut

* changes:
  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"
parents b8802b21 c3c08ba5
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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);