Fix highlight color

This commit is contained in:
tzugen 2023-06-09 09:56:42 +02:00
parent a9494626bb
commit 240e7fd8fb
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
2 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,5 @@
package org.moire.ultrasonic.adapters package org.moire.ultrasonic.adapters
import android.graphics.PorterDuff
import android.view.View import android.view.View
import android.widget.Checkable import android.widget.Checkable
import android.widget.CheckedTextView import android.widget.CheckedTextView
@ -14,6 +13,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.media3.common.HeartRating import androidx.media3.common.HeartRating
import androidx.media3.common.StarRating import androidx.media3.common.StarRating
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.color.MaterialColors
import com.google.android.material.progressindicator.CircularProgressIndicator import com.google.android.material.progressindicator.CircularProgressIndicator
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -44,6 +44,11 @@ class TrackViewHolder(val view: View) :
KoinComponent, KoinComponent,
CoroutineScope by CoroutineScope(Dispatchers.IO) { CoroutineScope by CoroutineScope(Dispatchers.IO) {
companion object {
val COLOR_NORMAL = com.google.android.material.R.attr.colorSurface
val COLOR_HIGHLIGHT = com.google.android.material.R.attr.colorSecondaryContainer
}
var entry: Track? = null var entry: Track? = null
private set private set
var songLayout: LinearLayout = view.findViewById(R.id.song_layout) var songLayout: LinearLayout = view.findViewById(R.id.song_layout)
@ -173,14 +178,16 @@ class TrackViewHolder(val view: View) :
title.setCompoundDrawablesWithIntrinsicBounds( title.setCompoundDrawablesWithIntrinsicBounds(
playingIcon, null, null, null playingIcon, null, null, null
) )
songLayout.backgroundTintMode = PorterDuff.Mode.MULTIPLY val color = MaterialColors.getColor(view, COLOR_HIGHLIGHT)
songLayout.setBackgroundColor(color)
songLayout.elevation = 3F songLayout.elevation = 3F
} else if (!isPlaying && isPlayingCached) { } else if (!isPlaying && isPlayingCached) {
isPlayingCached = false isPlayingCached = false
title.setCompoundDrawablesWithIntrinsicBounds( title.setCompoundDrawablesWithIntrinsicBounds(
0, 0, 0, 0 0, 0, 0, 0
) )
songLayout.backgroundTintMode = PorterDuff.Mode.ADD val color = MaterialColors.getColor(view, COLOR_NORMAL)
songLayout.setBackgroundColor(color)
songLayout.elevation = 0F songLayout.elevation = 0F
} }
} }

View File

@ -6,8 +6,6 @@
a:layout_width="fill_parent" a:layout_width="fill_parent"
a:layout_height="?android:attr/listPreferredItemHeight" a:layout_height="?android:attr/listPreferredItemHeight"
a:background="?attr/colorSurface" a:background="?attr/colorSurface"
a:backgroundTint="?attr/colorPrimaryContainer"
a:backgroundTintMode="add"
a:minHeight="?android:attr/listPreferredItemHeight" a:minHeight="?android:attr/listPreferredItemHeight"
a:orientation="horizontal"> a:orientation="horizontal">