all: cleanup
Pre-release clean-up.
This commit is contained in:
parent
c59074a4fe
commit
d786cd16d7
5 changed files with 24 additions and 52 deletions
|
@ -365,10 +365,6 @@ constructor(
|
||||||
throw NoAudioPermissionException()
|
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
|
// Start initializing the extractors. Use an indeterminate state, as there is no ETA on
|
||||||
// how long a media database query will take.
|
// how long a media database query will take.
|
||||||
emitLoading(IndexingProgress.Indeterminate)
|
emitLoading(IndexingProgress.Indeterminate)
|
||||||
|
|
|
@ -248,8 +248,7 @@ class AlbumImpl(
|
||||||
update(rawAlbum.rawArtists.map { it.name })
|
update(rawAlbum.rawArtists.map { it.name })
|
||||||
}
|
}
|
||||||
override val name = Name.Known.from(rawAlbum.name, rawAlbum.sortName, musicSettings)
|
override val name = Name.Known.from(rawAlbum.name, rawAlbum.sortName, musicSettings)
|
||||||
|
override val dates: Date.Range?
|
||||||
override val dates = Date.Range.from(songs.mapNotNull { it.date })
|
|
||||||
override val releaseType = rawAlbum.releaseType ?: ReleaseType.Album(null)
|
override val releaseType = rawAlbum.releaseType ?: ReleaseType.Album(null)
|
||||||
override val coverUri = rawAlbum.mediaStoreId.toCoverUri()
|
override val coverUri = rawAlbum.mediaStoreId.toCoverUri()
|
||||||
override val durationMs: Long
|
override val durationMs: Long
|
||||||
|
@ -263,17 +262,35 @@ class AlbumImpl(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
var totalDuration: Long = 0
|
var totalDuration: Long = 0
|
||||||
|
var minDate: Date? = null
|
||||||
|
var maxDate: Date? = null
|
||||||
var earliestDateAdded: Long = Long.MAX_VALUE
|
var earliestDateAdded: Long = Long.MAX_VALUE
|
||||||
|
|
||||||
// Do linking and value generation in the same loop for efficiency.
|
// Do linking and value generation in the same loop for efficiency.
|
||||||
for (song in songs) {
|
for (song in songs) {
|
||||||
song.link(this)
|
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) {
|
if (song.dateAdded < earliestDateAdded) {
|
||||||
earliestDateAdded = song.dateAdded
|
earliestDateAdded = song.dateAdded
|
||||||
}
|
}
|
||||||
totalDuration += song.durationMs
|
totalDuration += song.durationMs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val min = minDate
|
||||||
|
val max = maxDate
|
||||||
|
dates = if (min != null && max != null) Date.Range(min, max) else null
|
||||||
durationMs = totalDuration
|
durationMs = totalDuration
|
||||||
dateAdded = earliestDateAdded
|
dateAdded = earliestDateAdded
|
||||||
|
|
||||||
|
|
|
@ -116,13 +116,15 @@ class Date private constructor(private val tokens: List<Int>) : Comparable<Date>
|
||||||
*
|
*
|
||||||
* @author Alexander Capehart
|
* @author Alexander Capehart
|
||||||
*/
|
*/
|
||||||
class Range
|
class Range(
|
||||||
private constructor(
|
|
||||||
/** The earliest [Date] in the range. */
|
/** The earliest [Date] in the range. */
|
||||||
val min: Date,
|
val min: Date,
|
||||||
/** the latest [Date] in the range. May be the same as [min]. ] */
|
/** the latest [Date] in the range. May be the same as [min]. ] */
|
||||||
val max: Date
|
val max: Date
|
||||||
) : Comparable<Range> {
|
) : Comparable<Range> {
|
||||||
|
init {
|
||||||
|
check(min <= max) { "Min date must be <= max date" }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve this instance into a human-readable date range.
|
* Resolve this instance into a human-readable date range.
|
||||||
|
@ -145,35 +147,6 @@ class Date private constructor(private val tokens: List<Int>) : Comparable<Date>
|
||||||
override fun hashCode() = 31 * max.hashCode() + min.hashCode()
|
override fun hashCode() = 31 * max.hashCode() + min.hashCode()
|
||||||
|
|
||||||
override fun compareTo(other: Range) = min.compareTo(other.min)
|
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<Date>): 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 {
|
companion object {
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.oxycblt.auxio.playback.system
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
|
||||||
import android.support.v4.media.MediaMetadataCompat
|
import android.support.v4.media.MediaMetadataCompat
|
||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
|
@ -78,17 +77,7 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
|
||||||
setLargeIcon(metadata.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART))
|
setLargeIcon(metadata.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART))
|
||||||
setContentTitle(metadata.getString(MediaMetadataCompat.METADATA_KEY_TITLE))
|
setContentTitle(metadata.getString(MediaMetadataCompat.METADATA_KEY_TITLE))
|
||||||
setContentText(metadata.getText(MediaMetadataCompat.METADATA_KEY_ARTIST))
|
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))
|
setSubText(metadata.getText(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION))
|
||||||
} else {
|
|
||||||
logD("API 24 or lower, showing album information")
|
|
||||||
setSubText(metadata.getText(MediaMetadataCompat.METADATA_KEY_ALBUM))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -218,7 +218,6 @@
|
||||||
<item quantity="one">אומן אחד</item>
|
<item quantity="one">אומן אחד</item>
|
||||||
<item quantity="two">שני אומנים</item>
|
<item quantity="two">שני אומנים</item>
|
||||||
<item quantity="many">%d אומנים</item>
|
<item quantity="many">%d אומנים</item>
|
||||||
<item quantity="other"></item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="set_dirs_mode_include">לכלול</string>
|
<string name="set_dirs_mode_include">לכלול</string>
|
||||||
<string name="set_reindex">רענון מוזיקה</string>
|
<string name="set_reindex">רענון מוזיקה</string>
|
||||||
|
@ -230,13 +229,11 @@
|
||||||
<item quantity="one">שיר אחד</item>
|
<item quantity="one">שיר אחד</item>
|
||||||
<item quantity="two">שני שירים</item>
|
<item quantity="two">שני שירים</item>
|
||||||
<item quantity="many">%d שירים</item>
|
<item quantity="many">%d שירים</item>
|
||||||
<item quantity="other"></item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<plurals name="fmt_album_count">
|
<plurals name="fmt_album_count">
|
||||||
<item quantity="one">אלבום אחד</item>
|
<item quantity="one">אלבום אחד</item>
|
||||||
<item quantity="two">שני אלבומים</item>
|
<item quantity="two">שני אלבומים</item>
|
||||||
<item quantity="many">%d אלבומים</item>
|
<item quantity="many">%d אלבומים</item>
|
||||||
<item quantity="other"></item>
|
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="lng_playlist_renamed">שונה שם לרשימת השמעה</string>
|
<string name="lng_playlist_renamed">שונה שם לרשימת השמעה</string>
|
||||||
<string name="lng_playlist_deleted">רשימת השמעה נמחקה</string>
|
<string name="lng_playlist_deleted">רשימת השמעה נמחקה</string>
|
||||||
|
|
Loading…
Reference in a new issue