Fix played and favorite button changing color
This commit is contained in:
parent
e965dd3bff
commit
d36ec1eb62
4 changed files with 163 additions and 31 deletions
|
@ -84,11 +84,23 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
||||||
when (viewModel.played) {
|
when (viewModel.played) {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.markAsUnplayed(episodeId)
|
viewModel.markAsUnplayed(episodeId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check)
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsPlayed(episodeId)
|
viewModel.markAsPlayed(episodeId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check_filled)
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,10 +110,24 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.unmarkAsFavorite(episodeId)
|
viewModel.unmarkAsFavorite(episodeId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsFavorite(episodeId)
|
viewModel.markAsFavorite(episodeId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,11 +186,26 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
||||||
binding.playButton.alpha = if (!available) 0.5F else 1.0F
|
binding.playButton.alpha = if (!available) 0.5F else 1.0F
|
||||||
|
|
||||||
// Check icon
|
// Check icon
|
||||||
val checkDrawable = when (played) {
|
when (played) {
|
||||||
true -> R.drawable.ic_check_filled
|
true -> {
|
||||||
false -> R.drawable.ic_check
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
false -> {
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.checkButton.setImageResource(checkDrawable)
|
|
||||||
|
|
||||||
// Favorite icon
|
// Favorite icon
|
||||||
val favoriteDrawable = when (favorite) {
|
val favoriteDrawable = when (favorite) {
|
||||||
|
@ -172,6 +213,12 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
||||||
false -> R.drawable.ic_heart
|
false -> R.drawable.ic_heart
|
||||||
}
|
}
|
||||||
binding.favoriteButton.setImageResource(favoriteDrawable)
|
binding.favoriteButton.setImageResource(favoriteDrawable)
|
||||||
|
if (favorite) binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
when (canDownload) {
|
when (canDownload) {
|
||||||
true -> {
|
true -> {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -147,11 +148,23 @@ class MediaInfoFragment : Fragment() {
|
||||||
when (viewModel.played) {
|
when (viewModel.played) {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.markAsUnplayed(args.itemId)
|
viewModel.markAsUnplayed(args.itemId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check)
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsPlayed(args.itemId)
|
viewModel.markAsPlayed(args.itemId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check_filled)
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,10 +174,24 @@ class MediaInfoFragment : Fragment() {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.unmarkAsFavorite(args.itemId)
|
viewModel.unmarkAsFavorite(args.itemId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsFavorite(args.itemId)
|
viewModel.markAsFavorite(args.itemId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,11 +233,27 @@ class MediaInfoFragment : Fragment() {
|
||||||
binding.playButton.alpha = if (!available) 0.5F else 1.0F
|
binding.playButton.alpha = if (!available) 0.5F else 1.0F
|
||||||
|
|
||||||
// Check icon
|
// Check icon
|
||||||
val checkDrawable = when (played) {
|
when (played) {
|
||||||
true -> R.drawable.ic_check_filled
|
true -> {
|
||||||
false -> R.drawable.ic_check
|
if (played) binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
false -> {
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.checkButton.setImageResource(checkDrawable)
|
|
||||||
|
|
||||||
// Favorite icon
|
// Favorite icon
|
||||||
val favoriteDrawable = when (favorite) {
|
val favoriteDrawable = when (favorite) {
|
||||||
|
@ -218,6 +261,12 @@ class MediaInfoFragment : Fragment() {
|
||||||
false -> R.drawable.ic_heart
|
false -> R.drawable.ic_heart
|
||||||
}
|
}
|
||||||
binding.favoriteButton.setImageResource(favoriteDrawable)
|
binding.favoriteButton.setImageResource(favoriteDrawable)
|
||||||
|
if (favorite) binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
binding.downloadButton.isEnabled = !downloaded
|
binding.downloadButton.isEnabled = !downloaded
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package dev.jdtech.jellyfin.tv.ui
|
package dev.jdtech.jellyfin.tv.ui
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -119,11 +121,23 @@ internal class MediaDetailFragment : Fragment() {
|
||||||
when (viewModel.played) {
|
when (viewModel.played) {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.markAsUnplayed(args.itemId)
|
viewModel.markAsUnplayed(args.itemId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check)
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsPlayed(args.itemId)
|
viewModel.markAsPlayed(args.itemId)
|
||||||
binding.checkButton.setImageResource(R.drawable.ic_check_filled)
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,10 +147,24 @@ internal class MediaDetailFragment : Fragment() {
|
||||||
true -> {
|
true -> {
|
||||||
viewModel.unmarkAsFavorite(args.itemId)
|
viewModel.unmarkAsFavorite(args.itemId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart)
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
viewModel.markAsFavorite(args.itemId)
|
viewModel.markAsFavorite(args.itemId)
|
||||||
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
binding.favoriteButton.setImageResource(R.drawable.ic_heart_filled)
|
||||||
|
binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,11 +182,26 @@ internal class MediaDetailFragment : Fragment() {
|
||||||
actorsAdapter.submitList(actors)
|
actorsAdapter.submitList(actors)
|
||||||
|
|
||||||
// Check icon
|
// Check icon
|
||||||
val checkDrawable = when (played) {
|
when (played) {
|
||||||
true -> R.drawable.ic_check_filled
|
true -> {
|
||||||
false -> R.drawable.ic_check
|
if (played) binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
false -> {
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
requireActivity().theme.resolveAttribute(R.attr.colorOnSecondaryContainer, typedValue, true)
|
||||||
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
typedValue.resourceId,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
binding.checkButton.setImageResource(checkDrawable)
|
|
||||||
|
|
||||||
// Favorite icon
|
// Favorite icon
|
||||||
val favoriteDrawable = when (favorite) {
|
val favoriteDrawable = when (favorite) {
|
||||||
|
@ -166,6 +209,12 @@ internal class MediaDetailFragment : Fragment() {
|
||||||
false -> R.drawable.ic_heart
|
false -> R.drawable.ic_heart
|
||||||
}
|
}
|
||||||
binding.favoriteButton.setImageResource(favoriteDrawable)
|
binding.favoriteButton.setImageResource(favoriteDrawable)
|
||||||
|
if (favorite) binding.favoriteButton.imageTintList = ColorStateList.valueOf(
|
||||||
|
resources.getColor(
|
||||||
|
R.color.red,
|
||||||
|
requireActivity().theme
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
binding.title.text = item.name
|
binding.title.text = item.name
|
||||||
binding.subtitle.text = item.seriesName
|
binding.subtitle.text = item.seriesName
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:pathData="M20,6l-11,11l-5,-5"
|
|
||||||
android:strokeLineJoin="round"
|
|
||||||
android:strokeWidth="2"
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeColor="@color/red"
|
|
||||||
android:strokeLineCap="round"/>
|
|
||||||
</vector>
|
|
Loading…
Reference in a new issue