diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/EpisodeBottomSheetFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/EpisodeBottomSheetFragment.kt index 403fb7e3..6426beba 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/EpisodeBottomSheetFragment.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/EpisodeBottomSheetFragment.kt @@ -8,7 +8,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog -import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle @@ -34,8 +33,7 @@ import dev.jdtech.jellyfin.models.PlayerItem import dev.jdtech.jellyfin.models.UiText import dev.jdtech.jellyfin.models.isDownloaded import dev.jdtech.jellyfin.models.isDownloading -import dev.jdtech.jellyfin.utils.setTintColor -import dev.jdtech.jellyfin.utils.setTintColorAttribute +import dev.jdtech.jellyfin.utils.setIconTintColorAttribute import dev.jdtech.jellyfin.viewmodels.EpisodeBottomSheetViewModel import dev.jdtech.jellyfin.viewmodels.PlayerViewModel import java.text.DateFormat @@ -64,8 +62,9 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { binding = EpisodeBottomSheetBinding.inflate(inflater, container, false) binding.itemActions.playButton.setOnClickListener { - binding.itemActions.playButton.setImageResource(AndroidR.color.transparent) - binding.itemActions.progressCircular.isVisible = true + binding.itemActions.playButton.isEnabled = false + binding.itemActions.playButton.setIconResource(AndroidR.color.transparent) + binding.itemActions.progressPlay.isVisible = true playerViewModel.loadPlayerItems(viewModel.item) } @@ -89,12 +88,13 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { downloadPreparingDialog.dismiss() } DownloadManager.STATUS_PENDING -> { - binding.itemActions.downloadButton.setImageResource(AndroidR.color.transparent) + binding.itemActions.downloadButton.setIconResource(AndroidR.color.transparent) binding.itemActions.progressDownload.isIndeterminate = true binding.itemActions.progressDownload.isVisible = true } + DownloadManager.STATUS_RUNNING -> { - binding.itemActions.downloadButton.setImageResource(AndroidR.color.transparent) + binding.itemActions.downloadButton.setIconResource(AndroidR.color.transparent) binding.itemActions.progressDownload.isVisible = true if (progress < 5) { binding.itemActions.progressDownload.isIndeterminate = true @@ -104,12 +104,12 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { } } DownloadManager.STATUS_SUCCESSFUL -> { - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_trash) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_trash) binding.itemActions.progressDownload.isVisible = false } else -> { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } } } @@ -153,11 +153,11 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { binding.itemActions.downloadButton.setOnClickListener { if (viewModel.item.isDownloaded()) { viewModel.deleteEpisode() - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } else if (viewModel.item.isDownloading()) { createCancelDialog() } else { - binding.itemActions.downloadButton.setImageResource(android.R.color.transparent) + binding.itemActions.downloadButton.setIconResource(AndroidR.color.transparent) binding.itemActions.progressDownload.isIndeterminate = true binding.itemActions.progressDownload.isVisible = true if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) { @@ -174,7 +174,7 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) dialog.show() @@ -185,7 +185,7 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) storageDialog.show() @@ -201,7 +201,7 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) dialog.show() @@ -242,16 +242,16 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { binding.progressBar.isVisible = true } - val canPlay = episode.canPlay && episode.sources.isNotEmpty() - binding.itemActions.playButton.isEnabled = canPlay - binding.itemActions.playButton.alpha = if (!canPlay) 0.5F else 1.0F + binding.itemActions.playButton.isEnabled = episode.canPlay && episode.sources.isNotEmpty() + binding.itemActions.checkButton.isEnabled = true + binding.itemActions.favoriteButton.isEnabled = true bindCheckButtonState(episode.played) bindFavoriteButtonState(episode.favorite) if (episode.isDownloaded()) { - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_trash) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_trash) } when (canDownload || canDelete) { @@ -300,19 +300,17 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { private fun bindPlayerItems(items: PlayerViewModel.PlayerItems) { navigateToPlayerActivity(items.items.toTypedArray()) - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE } private fun bindCheckButtonState(played: Boolean) { when (played) { - true -> binding.itemActions.checkButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.checkButton.setTintColorAttribute( + true -> binding.itemActions.checkButton.setIconTintResource( + CoreR.color.red + ) + + false -> binding.itemActions.checkButton.setIconTintColorAttribute( MaterialR.attr.colorOnSecondaryContainer, requireActivity().theme ) @@ -324,10 +322,13 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { true -> CoreR.drawable.ic_heart_filled false -> CoreR.drawable.ic_heart } - binding.itemActions.favoriteButton.setImageResource(favoriteDrawable) + binding.itemActions.favoriteButton.setIconResource(favoriteDrawable) when (favorite) { - true -> binding.itemActions.favoriteButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.favoriteButton.setTintColorAttribute( + true -> binding.itemActions.favoriteButton.setIconTintResource( + CoreR.color.red + ) + + false -> binding.itemActions.favoriteButton.setIconTintColorAttribute( MaterialR.attr.colorOnSecondaryContainer, requireActivity().theme ) @@ -336,20 +337,19 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { private fun bindPlayerItemsError(error: PlayerViewModel.PlayerItemError) { Timber.e(error.error.message) - binding.playerItemsError.isVisible = true - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + playButtonNormal() binding.playerItemsErrorDetails.setOnClickListener { ErrorDialogFragment.newInstance(error.error).show(parentFragmentManager, ErrorDialogFragment.TAG) } } + private fun playButtonNormal() { + binding.itemActions.playButton.isEnabled = true + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE + } + private fun createErrorDialog(uiText: UiText) { val builder = MaterialAlertDialogBuilder(requireContext()) builder @@ -359,7 +359,7 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() { } builder.show() binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } private fun createDownloadPreparingDialog() { diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MovieFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MovieFragment.kt index ffba617e..351920c1 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MovieFragment.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MovieFragment.kt @@ -10,7 +10,6 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.appcompat.app.AlertDialog -import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels @@ -19,7 +18,6 @@ import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs -import com.google.android.material.R as MaterialR import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import dev.jdtech.jellyfin.AppPreferences @@ -39,8 +37,7 @@ import dev.jdtech.jellyfin.models.UiText import dev.jdtech.jellyfin.models.isDownloaded import dev.jdtech.jellyfin.models.isDownloading import dev.jdtech.jellyfin.utils.checkIfLoginRequired -import dev.jdtech.jellyfin.utils.setTintColor -import dev.jdtech.jellyfin.utils.setTintColorAttribute +import dev.jdtech.jellyfin.utils.setIconTintColorAttribute import dev.jdtech.jellyfin.viewmodels.MovieViewModel import dev.jdtech.jellyfin.viewmodels.PlayerViewModel import java.util.UUID @@ -94,12 +91,12 @@ class MovieFragment : Fragment() { downloadPreparingDialog.dismiss() } DownloadManager.STATUS_PENDING -> { - binding.itemActions.downloadButton.setImageResource(android.R.color.transparent) + binding.itemActions.downloadButton.setIconResource(android.R.color.transparent) binding.itemActions.progressDownload.isIndeterminate = true binding.itemActions.progressDownload.isVisible = true } DownloadManager.STATUS_RUNNING -> { - binding.itemActions.downloadButton.setImageResource(android.R.color.transparent) + binding.itemActions.downloadButton.setIconResource(android.R.color.transparent) binding.itemActions.progressDownload.isVisible = true if (progress < 5) { binding.itemActions.progressDownload.isIndeterminate = true @@ -109,12 +106,12 @@ class MovieFragment : Fragment() { } } DownloadManager.STATUS_SUCCESSFUL -> { - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_trash) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_trash) binding.itemActions.progressDownload.isVisible = false } else -> { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } } } @@ -151,8 +148,8 @@ class MovieFragment : Fragment() { binding.itemActions.playButton.setOnClickListener { binding.itemActions.playButton.isEnabled = false - binding.itemActions.playButton.setImageResource(android.R.color.transparent) - binding.itemActions.progressCircular.isVisible = true + binding.itemActions.playButton.setIconResource(android.R.color.transparent) + binding.itemActions.progressPlay.isVisible = true if (viewModel.item.sources.size > 1) { val dialog = getVideoVersionDialog( requireContext(), viewModel.item, @@ -196,11 +193,11 @@ class MovieFragment : Fragment() { binding.itemActions.downloadButton.setOnClickListener { if (viewModel.item.isDownloaded()) { viewModel.deleteItem() - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } else if (viewModel.item.isDownloading()) { createCancelDialog() } else { - binding.itemActions.downloadButton.setImageResource(android.R.color.transparent) + binding.itemActions.downloadButton.setIconResource(android.R.color.transparent) binding.itemActions.progressDownload.isIndeterminate = true binding.itemActions.progressDownload.isVisible = true if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) { @@ -217,7 +214,7 @@ class MovieFragment : Fragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) dialog.show() @@ -228,7 +225,7 @@ class MovieFragment : Fragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) storageDialog.show() @@ -244,7 +241,7 @@ class MovieFragment : Fragment() { }, onCancel = { binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } ) dialog.show() @@ -282,16 +279,16 @@ class MovieFragment : Fragment() { binding.communityRating.isVisible = item.communityRating != null binding.actors.isVisible = actors.isNotEmpty() - val canPlay = item.canPlay && item.sources.isNotEmpty() - binding.itemActions.playButton.isEnabled = canPlay - binding.itemActions.playButton.alpha = if (!canPlay) 0.5F else 1.0F + binding.itemActions.playButton.isEnabled = item.canPlay && item.sources.isNotEmpty() + binding.itemActions.checkButton.isEnabled = true + binding.itemActions.favoriteButton.isEnabled = true bindCheckButtonState(item.played) bindFavoriteButtonState(item.favorite) if (item.isDownloaded()) { - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_trash) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_trash) } when (canDownload || canDelete) { @@ -411,9 +408,9 @@ class MovieFragment : Fragment() { private fun bindCheckButtonState(played: Boolean) { when (played) { - true -> binding.itemActions.checkButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.checkButton.setTintColorAttribute( - MaterialR.attr.colorOnSecondaryContainer, + true -> binding.itemActions.checkButton.setIconTintResource(CoreR.color.red) + false -> binding.itemActions.checkButton.setIconTintColorAttribute( + com.google.android.material.R.attr.colorOnSecondaryContainer, requireActivity().theme ) } @@ -424,11 +421,11 @@ class MovieFragment : Fragment() { true -> CoreR.drawable.ic_heart_filled false -> CoreR.drawable.ic_heart } - binding.itemActions.favoriteButton.setImageResource(favoriteDrawable) + binding.itemActions.favoriteButton.setIconResource(favoriteDrawable) when (favorite) { - true -> binding.itemActions.favoriteButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.favoriteButton.setTintColorAttribute( - MaterialR.attr.colorOnSecondaryContainer, + true -> binding.itemActions.favoriteButton.setIconTintResource(CoreR.color.red) + false -> binding.itemActions.favoriteButton.setIconTintColorAttribute( + com.google.android.material.R.attr.colorOnSecondaryContainer, requireActivity().theme ) } @@ -436,13 +433,8 @@ class MovieFragment : Fragment() { private fun bindPlayerItems(items: PlayerViewModel.PlayerItems) { navigateToPlayerActivity(items.items.toTypedArray()) - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE } private fun bindPlayerItemsError(error: PlayerViewModel.PlayerItemError) { @@ -457,13 +449,8 @@ class MovieFragment : Fragment() { private fun playButtonNormal() { binding.itemActions.playButton.isEnabled = true - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE } private fun createErrorDialog(uiText: UiText) { @@ -475,7 +462,7 @@ class MovieFragment : Fragment() { } builder.show() binding.itemActions.progressDownload.isVisible = false - binding.itemActions.downloadButton.setImageResource(CoreR.drawable.ic_download) + binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download) } private fun createDownloadPreparingDialog() { diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/ShowFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/ShowFragment.kt index b6d3aacd..ca442a63 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/ShowFragment.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/ShowFragment.kt @@ -7,7 +7,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels @@ -16,7 +15,7 @@ import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs -import com.google.android.material.R as MaterialR +import com.google.android.material.R import dagger.hilt.android.AndroidEntryPoint import dev.jdtech.jellyfin.AppPreferences import dev.jdtech.jellyfin.adapters.PersonListAdapter @@ -32,8 +31,7 @@ import dev.jdtech.jellyfin.models.FindroidSourceType import dev.jdtech.jellyfin.models.PlayerItem import dev.jdtech.jellyfin.models.isDownloaded import dev.jdtech.jellyfin.utils.checkIfLoginRequired -import dev.jdtech.jellyfin.utils.setTintColor -import dev.jdtech.jellyfin.utils.setTintColorAttribute +import dev.jdtech.jellyfin.utils.setIconTintColorAttribute import dev.jdtech.jellyfin.viewmodels.PlayerViewModel import dev.jdtech.jellyfin.viewmodels.ShowViewModel import java.util.UUID @@ -132,8 +130,9 @@ class ShowFragment : Fragment() { } binding.itemActions.playButton.setOnClickListener { - binding.itemActions.playButton.setImageResource(android.R.color.transparent) - binding.itemActions.progressCircular.isVisible = true + binding.itemActions.playButton.isEnabled = false + binding.itemActions.playButton.setIconResource(android.R.color.transparent) + binding.itemActions.progressPlay.isVisible = true playerViewModel.loadPlayerItems(viewModel.item) } @@ -170,9 +169,10 @@ class ShowFragment : Fragment() { binding.communityRating.isVisible = item.communityRating != null binding.actors.isVisible = actors.isNotEmpty() - val canPlay = item.canPlay /*&& item.sources.isNotEmpty()*/ // TODO currently the sources of a show is always empty, we need a way to check if sources are available - binding.itemActions.playButton.isEnabled = canPlay - binding.itemActions.playButton.alpha = if (!canPlay) 0.5F else 1.0F + // TODO currently the sources of a show is always empty, we need a way to check if sources are available + binding.itemActions.playButton.isEnabled = item.canPlay + binding.itemActions.checkButton.isEnabled = true + binding.itemActions.favoriteButton.isEnabled = true bindCheckButtonState(item.played) @@ -183,9 +183,8 @@ class ShowFragment : Fragment() { binding.itemActions.downloadButton.isVisible = true binding.itemActions.downloadButton.isEnabled = !downloaded - if (downloaded) binding.itemActions.downloadButton.setTintColor( - CoreR.color.red, - requireActivity().theme + if (downloaded) binding.itemActions.downloadButton.setIconTintResource( + CoreR.color.red ) } @@ -263,9 +262,9 @@ class ShowFragment : Fragment() { private fun bindCheckButtonState(played: Boolean) { when (played) { - true -> binding.itemActions.checkButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.checkButton.setTintColorAttribute( - MaterialR.attr.colorOnSecondaryContainer, + true -> binding.itemActions.checkButton.setIconTintResource(CoreR.color.red) + false -> binding.itemActions.checkButton.setIconTintColorAttribute( + R.attr.colorOnSecondaryContainer, requireActivity().theme ) } @@ -276,11 +275,11 @@ class ShowFragment : Fragment() { true -> CoreR.drawable.ic_heart_filled false -> CoreR.drawable.ic_heart } - binding.itemActions.favoriteButton.setImageResource(favoriteDrawable) + binding.itemActions.favoriteButton.setIconResource(favoriteDrawable) when (favorite) { - true -> binding.itemActions.favoriteButton.setTintColor(CoreR.color.red, requireActivity().theme) - false -> binding.itemActions.favoriteButton.setTintColorAttribute( - MaterialR.attr.colorOnSecondaryContainer, + true -> binding.itemActions.favoriteButton.setIconTintResource(CoreR.color.red) + false -> binding.itemActions.favoriteButton.setIconTintColorAttribute( + R.attr.colorOnSecondaryContainer, requireActivity().theme ) } @@ -288,31 +287,26 @@ class ShowFragment : Fragment() { private fun bindPlayerItems(items: PlayerViewModel.PlayerItems) { navigateToPlayerActivity(items.items.toTypedArray()) - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE } private fun bindPlayerItemsError(error: PlayerViewModel.PlayerItemError) { Timber.e(error.error.message) binding.playerItemsError.visibility = View.VISIBLE - binding.itemActions.playButton.setImageDrawable( - ContextCompat.getDrawable( - requireActivity(), - CoreR.drawable.ic_play - ) - ) - binding.itemActions.progressCircular.visibility = View.INVISIBLE + playButtonNormal() binding.playerItemsErrorDetails.setOnClickListener { ErrorDialogFragment.newInstance(error.error) .show(parentFragmentManager, ErrorDialogFragment.TAG) } } + private fun playButtonNormal() { + binding.itemActions.playButton.isEnabled = true + binding.itemActions.playButton.setIconResource(CoreR.drawable.ic_play) + binding.itemActions.progressPlay.visibility = View.INVISIBLE + } + private fun navigateToEpisodeBottomSheetFragment(episode: FindroidItem) { findNavController().navigate( ShowFragmentDirections.actionShowFragmentToEpisodeBottomSheetFragment( diff --git a/app/phone/src/main/res/layout-w600dp/fragment_show.xml b/app/phone/src/main/res/layout-w600dp/fragment_show.xml index 4b84d2e1..826b7bdf 100644 --- a/app/phone/src/main/res/layout-w600dp/fragment_show.xml +++ b/app/phone/src/main/res/layout-w600dp/fragment_show.xml @@ -132,14 +132,13 @@ layout="@layout/item_actions" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="24dp" /> + android:layout_marginHorizontal="20dp" /> diff --git a/app/phone/src/main/res/layout/episode_bottom_sheet.xml b/app/phone/src/main/res/layout/episode_bottom_sheet.xml index 87613d33..7876d911 100644 --- a/app/phone/src/main/res/layout/episode_bottom_sheet.xml +++ b/app/phone/src/main/res/layout/episode_bottom_sheet.xml @@ -166,8 +166,8 @@ layout="@layout/item_actions" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="24dp" - android:layout_marginTop="12dp" + android:layout_marginHorizontal="20dp" + android:layout_marginTop="8dp" android:layout_marginBottom="24dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -179,7 +179,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="24dp" - android:layout_marginTop="12dp" android:layout_marginBottom="12dp" android:orientation="vertical" android:visibility="gone" @@ -211,7 +210,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="24dp" - android:layout_marginTop="12dp" + android:layout_marginTop="8dp" android:textAppearance="@style/TextAppearance.Material3.BodyMedium" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/phone/src/main/res/layout/fragment_movie.xml b/app/phone/src/main/res/layout/fragment_movie.xml index 6d66782d..97b5b662 100644 --- a/app/phone/src/main/res/layout/fragment_movie.xml +++ b/app/phone/src/main/res/layout/fragment_movie.xml @@ -126,7 +126,7 @@ android:layout_height="wrap_content" android:layout_gravity="start" android:layout_marginTop="10dp" - android:layout_marginBottom="16dp" + android:layout_marginBottom="12dp" app:singleLine="true"> + android:layout_marginHorizontal="20dp" /> diff --git a/app/phone/src/main/res/layout/fragment_show.xml b/app/phone/src/main/res/layout/fragment_show.xml index 15eabf1c..201a2e48 100644 --- a/app/phone/src/main/res/layout/fragment_show.xml +++ b/app/phone/src/main/res/layout/fragment_show.xml @@ -72,7 +72,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="24dp" - android:layout_marginBottom="12dp"> + android:layout_marginBottom="8dp"> + android:layout_marginHorizontal="20dp" /> diff --git a/app/phone/src/main/res/layout/item_actions.xml b/app/phone/src/main/res/layout/item_actions.xml index 4f508da1..34452e8a 100644 --- a/app/phone/src/main/res/layout/item_actions.xml +++ b/app/phone/src/main/res/layout/item_actions.xml @@ -3,88 +3,78 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginHorizontal="24dp" - android:layout_marginBottom="24dp"> + android:layout_height="wrap_content"> + android:layout_height="wrap_content"> - + app:icon="@drawable/ic_play" + tools:enabled="true" /> - + android:indeterminate="true" + android:visibility="invisible" + app:indicatorSize="24dp" + app:trackCornerRadius="2dp" /> - + app:icon="@drawable/ic_film" + tools:visibility="visible" /> - + android:enabled="false" + app:icon="@drawable/ic_check" + tools:enabled="true" /> - + android:enabled="false" + app:icon="@drawable/ic_heart" + tools:enabled="true" /> + android:layout_height="wrap_content"> - diff --git a/app/phone/src/main/res/layout/item_info.xml b/app/phone/src/main/res/layout/item_info.xml index 56289b6f..7d62c9e3 100644 --- a/app/phone/src/main/res/layout/item_info.xml +++ b/app/phone/src/main/res/layout/item_info.xml @@ -12,7 +12,7 @@ android:id="@+id/size_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="12dp" + android:layout_marginTop="8dp" android:text="@string/size" android:textAppearance="@style/TextAppearance.Material3.BodyMedium" android:visibility="gone" @@ -108,7 +108,7 @@ android:id="@+id/description" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="12dp" android:textAppearance="@style/TextAppearance.Material3.BodyMedium" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -119,7 +119,7 @@ android:id="@+id/genres_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="12dp" android:text="@string/genres" android:textAppearance="@style/TextAppearance.Material3.BodyMedium" app:layout_constraintStart_toStartOf="parent" diff --git a/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt b/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt index c8d3063e..8a9f805d 100644 --- a/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt +++ b/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt @@ -7,9 +7,8 @@ import android.content.res.Resources import android.os.Build import android.os.Bundle import android.util.TypedValue -import android.widget.ImageButton import androidx.annotation.AttrRes -import androidx.annotation.ColorRes +import com.google.android.material.button.MaterialButton import dev.jdtech.jellyfin.models.View import java.io.Serializable import org.jellyfin.sdk.model.api.BaseItemDto @@ -24,19 +23,10 @@ fun BaseItemDto.toView(): View { fun Resources.dip(px: Int) = (px * displayMetrics.density).toInt() -fun ImageButton.setTintColor(@ColorRes colorId: Int, theme: Resources.Theme) { - this.imageTintList = ColorStateList.valueOf( - resources.getColor( - colorId, - theme - ) - ) -} - -fun ImageButton.setTintColorAttribute(@AttrRes attributeId: Int, theme: Resources.Theme) { +fun MaterialButton.setIconTintColorAttribute(@AttrRes attributeId: Int, theme: Resources.Theme) { val typedValue = TypedValue() theme.resolveAttribute(attributeId, typedValue, true) - this.imageTintList = ColorStateList.valueOf( + this.iconTint = ColorStateList.valueOf( resources.getColor( typedValue.resourceId, theme