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

Commit 20b153bf authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by Android Git Automerger
Browse files

am 5fd26775: Merge change 9390 into donut

Merge commit '5fd26775'

* commit '5fd26775':
  Name unknown albums after the folder they're in, similar to how songs
parents 7865fe38 5fd26775
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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);