image: fix error on api 21

Fix an API 21-specific bug that could result in covers not loading when
quality covers was enabled.

This stemmed from a use of `use` on MediaMetadataRetriever, which
relied on an interface not present on the class on API 21.
This commit is contained in:
OxygenCobalt 2022-06-12 17:31:22 -06:00
parent 9b13b4c94e
commit ad87c72cd6
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
5 changed files with 8 additions and 12 deletions

View file

@ -39,8 +39,8 @@ import org.oxycblt.auxio.util.logD
/**
* The single [AppCompatActivity] for Auxio.
*
* TODO: Add crash reporting and error screens. This likely has to be an external activity, so it is
* blocked by eliminating exitProcess from the app.
* TODO: Add error screens. This likely has to be an external activity, so it is blocked by
* eliminating exitProcess from the app.
*
* TODO: Custom language support
*

View file

@ -114,18 +114,15 @@ abstract class BaseFetcher : Fetcher {
}
private fun fetchAospMetadataCovers(context: Context, album: Album): InputStream? {
// FIXME: Do not use use here, as Lollipop devices apparently do not have
// MediaMetadataRetriever implemented as AutoClosable.
MediaMetadataRetriever().use { ext ->
MediaMetadataRetriever().apply {
// This call is time-consuming but it also doesn't seem to hold up the main thread,
// so it's probably fine not to wrap it.
ext.setDataSource(context, album.songs[0].uri)
setDataSource(context, album.songs[0].uri)
// Get the embedded picture from MediaMetadataRetriever, which will return a full
// ByteArray of the cover without any compression artifacts.
// If its null [i.e there is no embedded cover], than just ignore it and move on
return ext.embeddedPicture?.let { coverBytes -> ByteArrayInputStream(coverBytes) }
return embeddedPicture?.let { ByteArrayInputStream(it) }.also { release() }
}
}

View file

@ -42,8 +42,6 @@ import org.oxycblt.auxio.util.newMainPendingIntent
* Loading music is actually somewhat time-consuming, to the point where it's likely better suited
* to a service that is less likely to be
*
* TODO: Rename all instances of loading in-app with indexing
*
* @author OxygenCobalt
*/
class IndexerService : Service(), Indexer.Callback {

View file

@ -40,7 +40,6 @@ import org.oxycblt.auxio.music.queryCursor
import org.oxycblt.auxio.music.useQuery
import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.util.contentResolverSafe
import org.oxycblt.auxio.util.logW
/*
* This file acts as the base for most the black magic required to get a remotely sensible music

View file

@ -2,7 +2,9 @@
<resources>
<integer name="detail_app_bar_title_anim_duration">150</integer>
<!-- FIXME: Unify this with the integer table object by simply defining a class for each setting. -->
<!--
FIXME: Unify SettingsManager into this by making it context-dependent again (requires a bunch
of technical reworks) -->
<!-- Preference values -->
<string-array name="entries_theme">
<item>@string/set_theme_auto</item>