Skip to content

Commit

Permalink
Accord: Bump dependencies, Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsummer233 committed Feb 8, 2025
1 parent 9b655eb commit 1b1d0ed
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 85 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
namespace = "org.akanework.gramophone"
compileSdk = 35
buildToolsVersion = "35.0.1"
ndkVersion = "28.0.12916984-rc3"
ndkVersion = "28.0.13004108"

androidResources {
generateLocaleConfig = true
Expand Down Expand Up @@ -166,7 +166,7 @@ configurations.configureEach {
}

dependencies {
val media3Version = "1.5.1"
val media3Version = "1.6.0-alpha03"
val roomVersion = "2.7.0-alpha13"

ksp("androidx.room:room-compiler:$roomVersion")
Expand All @@ -188,7 +188,7 @@ dependencies {
implementation("com.google.android.material:material:1.13.0-alpha10")
implementation("com.google.android.flexbox:flexbox:3.0.0")
implementation("me.zhanghai.android.fastscroll:library:1.3.0")
implementation("io.coil-kt.coil3:coil:3.0.4")
implementation("io.coil-kt.coil3:coil:3.1.0")
implementation(files("../libs/lib-decoder-ffmpeg-release.aar"))
implementation(projects.recyclerview)
// --- below does not apply to release builds ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.drawable.Drawable
import android.text.style.ImageSpan
import androidx.core.graphics.withTranslation

class CenteredImageSpan(private val drawable: Drawable) : ImageSpan(drawable) {

Expand All @@ -21,9 +22,8 @@ class CenteredImageSpan(private val drawable: Drawable) : ImageSpan(drawable) {
val drawable = drawable
val fontMetrics = paint.fontMetricsInt
val transY = (y + fontMetrics.ascent + y + fontMetrics.descent) / 2 - drawable.bounds.bottom / 2
canvas.save()
canvas.translate(x, transY.toFloat())
drawable.draw(canvas)
canvas.restore()
canvas.withTranslation(x, transY.toFloat()) {
drawable.draw(this)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider
import me.zhanghai.android.fastscroll.Predicate
import kotlin.math.max
import kotlin.math.min
import androidx.core.view.isEmpty

// Changes:
// - Kotlin
Expand Down Expand Up @@ -169,7 +170,7 @@ internal class RecyclerViewHelper(
}
private val itemHeight: Int
get() {
if (mView.childCount == 0) {
if (mView.isEmpty()) {
return 0
}
val itemView = mView.getChildAt(0)
Expand All @@ -188,7 +189,7 @@ internal class RecyclerViewHelper(
}
private val firstItemAdapterPosition: Int
get() {
if (mView.childCount == 0) {
if (mView.isEmpty()) {
return RecyclerView.NO_POSITION
}
val itemView = mView.getChildAt(0)
Expand All @@ -198,7 +199,7 @@ internal class RecyclerViewHelper(
}
private val firstItemOffset: Int
get() {
if (mView.childCount == 0) {
if (mView.isEmpty()) {
return RecyclerView.NO_POSITION
}
val itemView = mView.getChildAt(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.akanework.gramophone.ui.adapters.DateAdapter
import org.akanework.gramophone.ui.adapters.GenreAdapter
import org.akanework.gramophone.ui.adapters.PlaylistAdapter
import org.akanework.gramophone.ui.adapters.SongAdapter
import androidx.core.content.edit

object FileOpUtils {
fun getAdapterType(adapter: BaseAdapter<*>) =
Expand Down Expand Up @@ -65,6 +66,6 @@ object FileOpUtils {
for (entry in hashMap.entries) {
stringSet.add("${entry.key}:${entry.value}")
}
sharedPreferences.edit().putStringSet(key, stringSet).apply()
sharedPreferences.edit { putStringSet(key, stringSet) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.akanework.gramophone.BuildConfig
import org.akanework.gramophone.logic.use
import org.akanework.gramophone.logic.utils.exoplayer.EndedWorkaroundPlayer
import java.nio.charset.StandardCharsets
import androidx.core.net.toUri

@OptIn(UnstableApi::class)
class LastPlayedManager(context: Context,
Expand Down Expand Up @@ -328,7 +329,7 @@ private class SafeDelimitedStringDecat(delimiter: String, str: String) {
fun readInt(): Int? = read()?.toInt()
fun readLong(): Long? = read()?.toLong()
fun readBool(): Boolean? = read()?.toBooleanStrict()
fun readUri(): Uri? = Uri.parse(readStringSafe())
fun readUri(): Uri? = readStringSafe()?.toUri()
}

private object PrefsListUtils {
Expand Down
33 changes: 16 additions & 17 deletions app/src/main/java/org/akanework/gramophone/logic/utils/LrcUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ object LrcUtils {
}

private fun parseSpeakerLabel(lyricContent: String): SpeakerLabel {
val lyricLabel = lyricContent.substring(0, lyricContent.length.coerceAtMost(4))
val lyricLabel = lyricContent.substring(0, lyricContent.length.coerceAtMost(3))
return when {
lyricLabel.startsWith("v1: ") -> SpeakerLabel.Voice1
lyricLabel.startsWith("v2: ") -> SpeakerLabel.Voice2
lyricLabel.startsWith("bg: ") -> SpeakerLabel.Background
lyricLabel.startsWith("F: ") -> SpeakerLabel.Female
lyricLabel.startsWith("M: ") -> SpeakerLabel.Male
lyricLabel.startsWith("D: ") -> SpeakerLabel.Duet
lyricLabel.startsWith("v1:") -> SpeakerLabel.Voice1
lyricLabel.startsWith("v2:") -> SpeakerLabel.Voice2
lyricLabel.startsWith("bg:") -> SpeakerLabel.Background
lyricLabel.startsWith("F:") -> SpeakerLabel.Female
lyricLabel.startsWith("M:") -> SpeakerLabel.Male
lyricLabel.startsWith("D:") -> SpeakerLabel.Duet
else -> SpeakerLabel.None
}
}
Expand Down Expand Up @@ -302,9 +302,9 @@ private class UsltFrameDecoder {
val charset = getCharsetName(encoding)

val lang = ByteArray(3)
id3Data.readBytes(lang, 0, 3) // language
id3Data.readBytes(lang, 0, lang.size) // language
val rest = ByteArray(id3Data.limit() - 4)
id3Data.readBytes(rest, 0, id3Data.limit() - 4)
id3Data.readBytes(rest, 0, rest.size)

val descriptionEndIndex = indexOfEos(rest, 0, encoding)
val textStartIndex = descriptionEndIndex + delimiterLength(encoding)
Expand All @@ -313,14 +313,13 @@ private class UsltFrameDecoder {
}

private fun getCharsetName(encodingByte: Int): Charset {
val name = when (encodingByte) {
ID3_TEXT_ENCODING_UTF_16 -> "UTF-16"
ID3_TEXT_ENCODING_UTF_16BE -> "UTF-16BE"
ID3_TEXT_ENCODING_UTF_8 -> "UTF-8"
ID3_TEXT_ENCODING_ISO_8859_1 -> "ISO-8859-1"
else -> "ISO-8859-1"
return when (encodingByte) {
ID3_TEXT_ENCODING_UTF_16 -> Charsets.UTF_16
ID3_TEXT_ENCODING_UTF_16BE -> Charsets.UTF_16BE
ID3_TEXT_ENCODING_UTF_8 -> Charsets.UTF_8
ID3_TEXT_ENCODING_ISO_8859_1 -> Charsets.ISO_8859_1
else -> Charsets.ISO_8859_1
}
return Charset.forName(name)
}

private fun indexOfEos(data: ByteArray, fromIndex: Int, encoding: Int): Int {
Expand Down Expand Up @@ -369,4 +368,4 @@ private class UsltFrameDecoder {
} else String(data, from, to - from, charset)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ object MediaStoreUtils {
)
val haveImgPerm = if (hasScopedStorageWithMediaTypes()) context.hasImagePermission() else
prefs.getBoolean("album_covers", false)
val coverUri = Uri.parse("content://media/external/audio/albumart")
val coverUri = "content://media/external/audio/albumart".toUri()
val folderFilter = prefs.getStringSet("folderFilter", setOf()) ?: setOf()

// Initialize list and maps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class EndedWorkaroundPlayer(player: ExoPlayer)

override fun getPlaybackState(): Int {
if (isEnded) return STATE_ENDED
@Suppress("UsePropertyAccessSyntax")
return super.getPlaybackState()
return super.getPlaybackState()
}

fun setShuffleOrder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,18 @@ class GramophoneMediaSourceFactory(
mediaItem: MediaItem,
mediaSource: MediaSource
): MediaSource {
return (if ((mediaItem.clippingConfiguration.startPositionUs == 0L) && (mediaItem.clippingConfiguration.endPositionUs == Long.MIN_VALUE) && !mediaItem.clippingConfiguration.relativeToDefaultPosition) mediaSource else ClippingMediaSource(
mediaSource,
mediaItem.clippingConfiguration.startPositionUs,
mediaItem.clippingConfiguration.endPositionUs,
!mediaItem.clippingConfiguration.startsAtKeyFrame,
mediaItem.clippingConfiguration.relativeToLiveWindow,
mediaItem.clippingConfiguration.relativeToDefaultPosition
))
return (
if ((mediaItem.clippingConfiguration.startPositionUs == 0L) && (mediaItem.clippingConfiguration.endPositionUs == Long.MIN_VALUE) && !mediaItem.clippingConfiguration.relativeToDefaultPosition)
mediaSource
else
ClippingMediaSource.Builder(mediaSource)
.setStartPositionUs(mediaItem.clippingConfiguration.startPositionUs)
.setEndPositionUs(mediaItem.clippingConfiguration.endPositionUs)
.setEnableInitialDiscontinuity(!mediaItem.clippingConfiguration.startsAtKeyFrame)
.setAllowDynamicClippingUpdates(mediaItem.clippingConfiguration.relativeToLiveWindow)
.setRelativeToDefaultPosition(mediaItem.clippingConfiguration.relativeToDefaultPosition)
.build()
)
}

private fun newInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.akanework.gramophone.logic.findBaseWrapperFragment
import org.akanework.gramophone.logic.getBooleanStrict
import org.akanework.gramophone.logic.utils.MediaStoreUtils
import org.akanework.gramophone.ui.fragments.ArtistSubFragment
import androidx.core.content.edit

/**
* [ArtistAdapter] is an adapter for displaying artists.
Expand Down Expand Up @@ -109,7 +110,7 @@ class ArtistAdapter(

private fun setAlbumArtist(albumArtist: Boolean) {
isAlbumArtist = albumArtist
prefs.edit().putBoolean("isDisplayingAlbumArtist", isAlbumArtist).apply()
prefs.edit { putBoolean("isDisplayingAlbumArtist", isAlbumArtist) }
if (recyclerView != null)
liveData?.removeObserver(this)
liveData = if (isAlbumArtist) albumArtists else artistList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.akanework.gramophone.logic.ui.ItemHeightHelper
import org.akanework.gramophone.logic.ui.MyRecyclerView
import org.akanework.gramophone.logic.utils.FileOpUtils
import kotlin.random.Random
import androidx.core.content.edit

open class BaseDecorAdapter<T : BaseAdapter<*>>(
protected val adapter: T,
Expand Down Expand Up @@ -130,12 +131,12 @@ open class BaseDecorAdapter<T : BaseAdapter<*>>(
adapter.sort(buttonMap[menuItem.itemId]!!)
menuItem.isChecked = true
if (!isSubFragment) {
prefs.edit()
.putString(
prefs.edit {
putString(
"S" + FileOpUtils.getAdapterType(adapter).toString(),
buttonMap[menuItem.itemId].toString()
)
.apply()
}
}
}
true
Expand All @@ -146,12 +147,12 @@ open class BaseDecorAdapter<T : BaseAdapter<*>>(
adapter.layoutType = layoutMap[menuItem.itemId]!!
menuItem.isChecked = true
if (!isSubFragment) {
prefs.edit()
.putString(
prefs.edit {
putString(
"L" + FileOpUtils.getAdapterType(adapter).toString(),
layoutMap[menuItem.itemId].toString()
)
.apply()
}
}
}
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.google.android.material.checkbox.MaterialCheckBox
import org.akanework.gramophone.R
import org.akanework.gramophone.logic.getStringSetStrict
import org.akanework.gramophone.logic.ui.MyRecyclerView
import androidx.core.content.edit

class BlacklistFolderAdapter(
private val fragment: Fragment,
Expand Down Expand Up @@ -39,15 +40,16 @@ class BlacklistFolderAdapter(
holder.checkBox.isChecked = folderFilter.contains(folderArray[position])
holder.folderLocation.text = folderArray[position]
holder.checkBox.setOnClickListener {
prefs.edit()
.putStringSet("folderFilter",
prefs.edit {
putStringSet(
"folderFilter",
folderFilter.also {
if (holder.checkBox.isChecked)
it.add(folderArray[position])
else
it.remove(folderArray[position])
})
.apply()
}
}
holder.itemView.setOnClickListener {
holder.checkBox.isChecked = !holder.checkBox.isChecked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.akanework.gramophone.R
import java.io.FileNotFoundException
import java.io.InputStream
import kotlin.math.ceil
import androidx.core.graphics.createBitmap

class BlendView @JvmOverloads constructor(
context: Context,
Expand Down Expand Up @@ -232,7 +233,7 @@ class BlendView @JvmOverloads constructor(
val width = bitmap.width
val height = bitmap.height

val enhancedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val enhancedBitmap = createBitmap(width, height)
enhancedBitmap.density = bitmap.density

val enhancePaint = Paint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.widget.FrameLayout
import androidx.core.view.doOnLayout
import org.akanework.gramophone.R
import kotlin.math.min
import androidx.core.content.withStyledAttributes

class FadingVerticalEdgeLayout @JvmOverloads constructor(
context: Context,
Expand Down Expand Up @@ -60,25 +61,25 @@ class FadingVerticalEdgeLayout @JvmOverloads constructor(
resources.displayMetrics
).toInt()
if (attrs != null) {
val arr = context.obtainStyledAttributes(
context.withStyledAttributes(
attrs, R.styleable.FadingVerticalEdgeLayout, 0, 0
)
val flags = arr.getInt(R.styleable.FadingVerticalEdgeLayout_fel_edge, 0)
fadeTop = flags and FADE_EDGE_TOP == FADE_EDGE_TOP
fadeBottom = flags and FADE_EDGE_BOTTOM == FADE_EDGE_BOTTOM
gradientSizeTop = arr.getDimensionPixelSize(
R.styleable.FadingVerticalEdgeLayout_fel_size_top, defaultSize
)
gradientSizeBottom = arr.getDimensionPixelSize(
R.styleable.FadingVerticalEdgeLayout_fel_size_bottom, defaultSize
)
if (fadeTop && gradientSizeTop > 0) {
gradientDirtyFlags = gradientDirtyFlags or DIRTY_FLAG_TOP
) {
val flags = getInt(R.styleable.FadingVerticalEdgeLayout_fel_edge, 0)
fadeTop = flags and FADE_EDGE_TOP == FADE_EDGE_TOP
fadeBottom = flags and FADE_EDGE_BOTTOM == FADE_EDGE_BOTTOM
gradientSizeTop = getDimensionPixelSize(
R.styleable.FadingVerticalEdgeLayout_fel_size_top, defaultSize
)
gradientSizeBottom = getDimensionPixelSize(
R.styleable.FadingVerticalEdgeLayout_fel_size_bottom, defaultSize
)
if (fadeTop && gradientSizeTop > 0) {
gradientDirtyFlags = gradientDirtyFlags or DIRTY_FLAG_TOP
}
if (fadeBottom && gradientSizeBottom > 0) {
gradientDirtyFlags = gradientDirtyFlags or DIRTY_FLAG_BOTTOM
}
}
if (fadeBottom && gradientSizeBottom > 0) {
gradientDirtyFlags = gradientDirtyFlags or DIRTY_FLAG_BOTTOM
}
arr.recycle()
} else {
gradientSizeBottom = defaultSize
gradientSizeTop = gradientSizeBottom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.akanework.gramophone.R
import org.akanework.gramophone.logic.allowDiskAccessInStrictMode
import org.akanework.gramophone.logic.dpToPx
import org.akanework.gramophone.logic.enableEdgeToEdgePaddingListener
import androidx.core.graphics.drawable.toDrawable

/**
* BasePreferenceFragment:
Expand Down Expand Up @@ -60,7 +61,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(),
}

override fun setDivider(divider: Drawable?) {
super.setDivider(ColorDrawable(Color.TRANSPARENT))
super.setDivider(Color.TRANSPARENT.toDrawable())
}

override fun setDividerHeight(height: Int) {
Expand Down
Loading

0 comments on commit 1b1d0ed

Please sign in to comment.