diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt index 36133c94c..8d890b218 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt @@ -365,10 +365,6 @@ constructor( throw NoAudioPermissionException() } - // TODO: Parallelize this even more aggressively. I can hypothetically connect all - // finalization steps (library, cache, playlists) into a single pipeline would need - // to change how I indicate progress however - // Start initializing the extractors. Use an indeterminate state, as there is no ETA on // how long a media database query will take. emitLoading(IndexingProgress.Indeterminate) diff --git a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt index 530f35530..e3ce99928 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt @@ -248,8 +248,7 @@ class AlbumImpl( update(rawAlbum.rawArtists.map { it.name }) } override val name = Name.Known.from(rawAlbum.name, rawAlbum.sortName, musicSettings) - - override val dates = Date.Range.from(songs.mapNotNull { it.date }) + override val dates: Date.Range? override val releaseType = rawAlbum.releaseType ?: ReleaseType.Album(null) override val coverUri = rawAlbum.mediaStoreId.toCoverUri() override val durationMs: Long @@ -263,17 +262,35 @@ class AlbumImpl( init { var totalDuration: Long = 0 + var minDate: Date? = null + var maxDate: Date? = null var earliestDateAdded: Long = Long.MAX_VALUE // Do linking and value generation in the same loop for efficiency. for (song in songs) { song.link(this) + + if (song.date != null) { + val min = minDate + if (min == null || song.date < min) { + minDate = song.date + } + + val max = maxDate + if (max == null || song.date > max) { + maxDate = song.date + } + } + if (song.dateAdded < earliestDateAdded) { earliestDateAdded = song.dateAdded } totalDuration += song.durationMs } + val min = minDate + val max = maxDate + dates = if (min != null && max != null) Date.Range(min, max) else null durationMs = totalDuration dateAdded = earliestDateAdded diff --git a/app/src/main/java/org/oxycblt/auxio/music/info/Date.kt b/app/src/main/java/org/oxycblt/auxio/music/info/Date.kt index b47f580db..860b3e315 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/info/Date.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/info/Date.kt @@ -116,13 +116,15 @@ class Date private constructor(private val tokens: List) : Comparable * * @author Alexander Capehart */ - class Range - private constructor( + class Range( /** The earliest [Date] in the range. */ val min: Date, /** the latest [Date] in the range. May be the same as [min]. ] */ val max: Date ) : Comparable { + init { + check(min <= max) { "Min date must be <= max date" } + } /** * Resolve this instance into a human-readable date range. @@ -145,35 +147,6 @@ class Date private constructor(private val tokens: List) : Comparable override fun hashCode() = 31 * max.hashCode() + min.hashCode() override fun compareTo(other: Range) = min.compareTo(other.min) - - companion object { - /** - * Create a [Range] from the given list of [Date]s. - * - * @param dates The [Date]s to use. - * @return A [Range] based on the minimum and maximum [Date]s. If there are no [Date]s, - * null is returned. - */ - fun from(dates: List): Range? { - if (dates.isEmpty()) { - // Nothing to do. - return null - } - // Simultaneously find the minimum and maximum values in the given range. - // If this list has only one item, then that one date is the minimum and maximum. - var min = dates.first() - var max = min - for (i in 1..dates.lastIndex) { - if (dates[i] < min) { - min = dates[i] - } - if (dates[i] > max) { - max = dates[i] - } - } - return Range(min, max) - } - } } companion object { diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/NotificationComponent.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/NotificationComponent.kt index ecbbce122..7b9868072 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/NotificationComponent.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/NotificationComponent.kt @@ -20,7 +20,6 @@ package org.oxycblt.auxio.playback.system import android.annotation.SuppressLint import android.content.Context -import android.os.Build import android.support.v4.media.MediaMetadataCompat import android.support.v4.media.session.MediaSessionCompat import androidx.annotation.DrawableRes @@ -78,17 +77,7 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes setLargeIcon(metadata.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART)) setContentTitle(metadata.getString(MediaMetadataCompat.METADATA_KEY_TITLE)) setContentText(metadata.getText(MediaMetadataCompat.METADATA_KEY_ARTIST)) - - // Starting in API 24, the subtext field changed semantics from being below the - // content text to being above the title. Use an appropriate field for both. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - // Display description -> Parent in which playback is occurring - logD("API 24+, showing parent information") - setSubText(metadata.getText(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION)) - } else { - logD("API 24 or lower, showing album information") - setSubText(metadata.getText(MediaMetadataCompat.METADATA_KEY_ALBUM)) - } + setSubText(metadata.getText(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION)) } /** diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 9b0ef6424..1e1db4996 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -218,7 +218,6 @@ אומן אחד שני אומנים %d אומנים - לכלול רענון מוזיקה @@ -230,13 +229,11 @@ שיר אחד שני שירים %d שירים - אלבום אחד שני אלבומים %d אלבומים - שונה שם לרשימת השמעה רשימת השמעה נמחקה