Fix compat issues
Fix some issues on older versions.
This commit is contained in:
@@ -9,14 +9,14 @@
|
||||
|
||||
<queries />
|
||||
|
||||
<!-- TODO: Backup -->
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/Theme.Base"
|
||||
tools:ignore="AllowBackup">
|
||||
android:fullBackupContent="@xml/backup_descriptor">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleInstance"
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.oxycblt.auxio.ui.setupSongActions
|
||||
* search functionality.
|
||||
* TODO: Move search to separate tab?
|
||||
* FIXME: Leak when navving from search
|
||||
* FIXME: Leak on older versions
|
||||
*/
|
||||
class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
|
||||
|
||||
@@ -19,16 +19,15 @@ import org.oxycblt.auxio.music.Song
|
||||
* **Do not use this on the UI elements, instead use the Binding Adapters.**
|
||||
* @param context [Context] required
|
||||
* @param song Song to load the cover for
|
||||
* @param onDone What to do with the bitmap when the loading is finished.
|
||||
* @param onDone What to do with the bitmap when the loading is finished. Bitmap will be null if loading failed.
|
||||
*/
|
||||
fun getBitmap(context: Context, song: Song, onDone: (Bitmap) -> Unit) {
|
||||
Coil.enqueue(
|
||||
ImageRequest.Builder(context)
|
||||
.data(song.album.coverUri)
|
||||
.error(R.drawable.ic_song)
|
||||
.target { onDone(it.toBitmap()) }
|
||||
.build()
|
||||
)
|
||||
fun getBitmap(context: Context, song: Song, onDone: (Bitmap?) -> Unit) {
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(song.album.coverUri)
|
||||
.target(onError = { onDone(null) }, onSuccess = { onDone(it.toBitmap()) })
|
||||
.build()
|
||||
|
||||
Coil.imageLoader(context).enqueue(request)
|
||||
}
|
||||
|
||||
// --- BINDING ADAPTERS ---
|
||||
|
||||
@@ -97,9 +97,9 @@ fun NotificationCompat.Builder.setMetadata(
|
||||
song.album.artist.name,
|
||||
)
|
||||
|
||||
// On older versions of android [API <26], show the song's album on the subtext instead of
|
||||
// On older versions of android [API <24], show the song's album on the subtext instead of
|
||||
// the current mode, as that makes more sense for the old style of media notifications.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
setSubText(song.album.name)
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ fun NotificationCompat.Builder.updateExtraAction(context: Context, useAltAction:
|
||||
* @param context The context required to get the strings required to show certain modes
|
||||
*/
|
||||
fun NotificationCompat.Builder.updateMode(context: Context) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val playbackManager = PlaybackStateManager.getInstance()
|
||||
|
||||
// If playing from all songs, set the subtext as that, otherwise the currently played parent.
|
||||
|
||||
@@ -237,7 +237,7 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
|
||||
|
||||
uploadMetadataToSession(it)
|
||||
|
||||
notification.setMetadata(this, playbackManager.song!!, settingsManager.colorizeNotif) {
|
||||
notification.setMetadata(this, it, settingsManager.colorizeNotif) {
|
||||
startForegroundOrNotify("Song")
|
||||
}
|
||||
|
||||
|
||||
@@ -152,12 +152,7 @@ class NoLeakThumbView @JvmOverloads constructor(
|
||||
) {
|
||||
val thumbTargetY = indicatorCenterY.toFloat() - (thumbView.measuredHeight / 2)
|
||||
|
||||
// Don't animate if the view is invisible.
|
||||
if (!isActivated || !isVisible) {
|
||||
y = thumbTargetY
|
||||
} else {
|
||||
thumbAnimation.animateToFinalPosition(thumbTargetY)
|
||||
}
|
||||
thumbAnimation.animateToFinalPosition(thumbTargetY)
|
||||
|
||||
when (indicator) {
|
||||
is FastScrollItemIndicator.Text -> {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.oxycblt.auxio.songs
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
@@ -18,8 +20,10 @@ import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.music.MusicStore
|
||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||
import org.oxycblt.auxio.settings.SettingsManager
|
||||
import org.oxycblt.auxio.ui.accent
|
||||
import org.oxycblt.auxio.ui.isLandscape
|
||||
import org.oxycblt.auxio.ui.setupSongActions
|
||||
import org.oxycblt.auxio.ui.toColor
|
||||
import kotlin.math.ceil
|
||||
|
||||
/**
|
||||
@@ -105,6 +109,11 @@ class SongsFragment : Fragment() {
|
||||
binding.songFastScroll.apply {
|
||||
var concatInterval = -1
|
||||
|
||||
// API 22 and below don't support the state color, so just use the accent.
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
|
||||
textColor = ColorStateList.valueOf(accent.first.toColor(requireContext()))
|
||||
}
|
||||
|
||||
setupWithRecyclerView(
|
||||
binding.songRecycler,
|
||||
{ pos ->
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorPrimary"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z" />
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorPrimary">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6,21h12L18,7L6,7v14zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4h-3.5z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- FIXME: Use custom drawable for < API 23 -->
|
||||
<dimen name="height_compact_progress">6dp</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="height_compact_progress">2dp</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<full-backup-content/>
|
||||
Reference in New Issue
Block a user