Respect "Allow media playback"

Fix #228
This commit is contained in:
Jarne Demeulemeester 2023-01-15 18:07:01 +01:00
parent 31fd1e3fdc
commit 872457f3de
No known key found for this signature in database
GPG key ID: 65C6006F2032DD14
4 changed files with 16 additions and 6 deletions

View file

@ -160,11 +160,11 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
binding.progressBar.isVisible = true
}
val clickable = available || canRetry
val clickable = canPlay && (available || canRetry)
binding.playButton.isEnabled = clickable
binding.playButton.alpha = if (!clickable) 0.5F else 1.0F
binding.playButton.setImageResource(if (!canRetry) R.drawable.ic_play else R.drawable.ic_rotate_ccw)
if (!clickable) {
if (!(available || canRetry)) {
binding.playButton.setImageResource(android.R.color.transparent)
binding.progressCircular.isVisible = true
}

View file

@ -213,11 +213,11 @@ class MediaInfoFragment : Fragment() {
binding.communityRating.isVisible = item.communityRating != null
binding.actors.isVisible = actors.isNotEmpty()
val clickable = available || canRetry
val clickable = canPlay && (available || canRetry)
binding.playButton.isEnabled = clickable
binding.playButton.alpha = if (!clickable) 0.5F else 1.0F
binding.playButton.setImageResource(if (!canRetry) R.drawable.ic_play else R.drawable.ic_rotate_ccw)
if (!clickable) {
if (!(available || canRetry)) {
binding.playButton.setImageResource(android.R.color.transparent)
binding.progressCircular.isVisible = true
}
@ -236,8 +236,6 @@ class MediaInfoFragment : Fragment() {
binding.favoriteButton.setImageResource(favoriteDrawable)
if (favorite) binding.favoriteButton.setTintColor(R.color.red, requireActivity().theme)
binding.downloadButton.isEnabled = !downloaded
when (canDownload) {
true -> {
binding.downloadButton.isVisible = true

View file

@ -24,6 +24,7 @@ import kotlinx.coroutines.launch
import org.jellyfin.sdk.api.client.exception.ApiClientException
import org.jellyfin.sdk.model.DateTime
import org.jellyfin.sdk.model.api.BaseItemDto
import org.jellyfin.sdk.model.api.PlayAccess
import timber.log.Timber
@HiltViewModel
@ -44,6 +45,7 @@ constructor(
val dateString: String,
val played: Boolean,
val favorite: Boolean,
val canPlay: Boolean,
val canDownload: Boolean,
val downloaded: Boolean,
val available: Boolean,
@ -59,6 +61,7 @@ constructor(
private var dateString: String = ""
var played: Boolean = false
var favorite: Boolean = false
private var canPlay = true
private var canDownload = false
private var downloaded: Boolean = false
private var available: Boolean = true
@ -75,6 +78,7 @@ constructor(
dateString = getDateString(tempItem.premiereDate)
played = tempItem.userData?.played == true
favorite = tempItem.userData?.isFavorite == true
canPlay = tempItem.playAccess != PlayAccess.NONE
canDownload = tempItem.canDownload == true
downloaded = isItemDownloaded(downloadDatabase, episodeId)
_uiState.emit(
@ -84,6 +88,7 @@ constructor(
dateString,
played,
favorite,
canPlay,
canDownload,
downloaded,
available,
@ -110,6 +115,7 @@ constructor(
dateString,
played,
favorite,
canPlay,
canDownload,
downloaded,
available,

View file

@ -24,6 +24,7 @@ import org.jellyfin.sdk.api.client.exception.ApiClientException
import org.jellyfin.sdk.model.api.BaseItemDto
import org.jellyfin.sdk.model.api.BaseItemKind
import org.jellyfin.sdk.model.api.BaseItemPerson
import org.jellyfin.sdk.model.api.PlayAccess
import timber.log.Timber
@HiltViewModel
@ -51,6 +52,7 @@ constructor(
val seasons: List<BaseItemDto>,
val played: Boolean,
val favorite: Boolean,
val canPlay: Boolean,
val canDownload: Boolean,
val downloaded: Boolean,
var canRetry: Boolean = false,
@ -73,6 +75,7 @@ constructor(
var seasons: List<BaseItemDto> = emptyList()
var played: Boolean = false
var favorite: Boolean = false
private var canPlay: Boolean = true
private var canDownload: Boolean = false
private var downloaded: Boolean = false
var canRetry: Boolean = false
@ -95,6 +98,7 @@ constructor(
dateString = getDateString(tempItem)
played = tempItem.userData?.played ?: false
favorite = tempItem.userData?.isFavorite ?: false
canPlay = tempItem.playAccess != PlayAccess.NONE
canDownload = tempItem.canDownload == true
downloaded = isItemDownloaded(downloadDatabase, itemId)
if (itemType == BaseItemKind.SERIES) {
@ -115,6 +119,7 @@ constructor(
seasons,
played,
favorite,
canPlay,
canDownload,
downloaded,
canRetry,
@ -157,6 +162,7 @@ constructor(
seasons,
played,
favorite,
canPlay,
canDownload,
downloaded,
canRetry,