Fix compat issues

Fix some issues on older versions.
This commit is contained in:
OxygenCobalt 2020-12-19 15:43:07 -07:00
parent a443ccd508
commit d4d40c97ad
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
14 changed files with 48 additions and 32 deletions

View file

@ -38,16 +38,17 @@ Its meant to be consistent and reliable, while still being customizable and exte
- Reliable, [ExoPlayer](https://exoplayer.dev/) based playback
- Customizable UI & Behavior
- Extensive Genres/Artists/Albums/Songs support
- Powerful queue system
- Genres/Artists/Albums/Songs support
- Extensive queue system
- Full playback persistence system
- Edge-to-edge (Oreo+ Only)
- Embedded covers support
- Search Functionality
- Audio Focus / Headset Management
- No internet connectivity whatsoever
- Kotlin from the ground-up
- Modular, feature-based architecture
- No rounded corners (The way god intended)
- No rounded corners
## To Come in the future:

View file

@ -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"

View file

@ -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 {

View file

@ -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)
fun getBitmap(context: Context, song: Song, onDone: (Bitmap?) -> Unit) {
val request = ImageRequest.Builder(context)
.data(song.album.coverUri)
.error(R.drawable.ic_song)
.target { onDone(it.toBitmap()) }
.target(onError = { onDone(null) }, onSuccess = { onDone(it.toBitmap()) })
.build()
)
Coil.imageLoader(context).enqueue(request)
}
// --- BINDING ADAPTERS ---

View file

@ -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.

View file

@ -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")
}

View file

@ -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)
}
when (indicator) {
is FastScrollItemIndicator.Text -> {

View file

@ -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 ->

View file

@ -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">
android:viewportHeight="24"
android:tint="?attr/colorPrimary">
<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:pathData="M6,21h12L18,7L6,7v14zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4h-3.5z"/>
</vector>

View file

@ -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>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="height_compact_progress">2dp</dimen>
</resources>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content/>

View file

@ -1,6 +1,6 @@
#Mon Oct 12 13:43:13 MDT 2020
#Sat Dec 19 15:35:00 MST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

View file

@ -8,7 +8,7 @@ All guidelines from the [Contribution Guidelines](../.github/CONTRIBUTING.md) st
## Bug Fixes, Optimizations, Library Updates, Formatting, etc.
These will likely be accepted/add as long as they do not cause too much harm to the app's architecture or UX.
These will likely be accepted/added as long as they do not cause too much harm to the app's architecture or UX.
## New Options/Customizations