6.5.10 commit

This commit is contained in:
Xilin Jia 2024-09-10 23:04:06 +01:00
parent 8f1fd25d01
commit ddc0f94d89
10 changed files with 46 additions and 28 deletions

View File

@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 3020243
versionName "6.5.9"
versionCode 3020244
versionName "6.5.10"
applicationId "ac.mdiq.podcini.R"
def commit = ""

View File

@ -54,7 +54,6 @@ import ac.mdiq.podcini.storage.model.FeedPreferences.AutoDeleteAction
import ac.mdiq.podcini.storage.utils.ChapterUtils
import ac.mdiq.podcini.storage.utils.EpisodeUtil
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.ui.activity.VideoplayerActivity.Companion.videoMode
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.activity.starter.VideoPlayerActivityStarter
import ac.mdiq.podcini.ui.utils.NotificationUtils
@ -1033,10 +1032,6 @@ class PlaybackService : MediaLibraryService() {
// if (curMedia is EpisodeMedia && episode != null) addToQueue(true, episode)
}
fun clearCurTempSpeed() {
curState = upsertBlk(curState) { it.curTempSpeed = FeedPreferences.SPEED_USE_GLOBAL }
}
private var eventSink: Job? = null
private fun cancelFlowEvents() {
eventSink?.cancel()
@ -2549,6 +2544,10 @@ class PlaybackService : MediaLibraryService() {
return playbackService?.taskManager?.isSleepTimerActive ?: false
}
fun clearCurTempSpeed() {
curState = upsertBlk(curState) { it.curTempSpeed = FeedPreferences.SPEED_USE_GLOBAL }
}
fun playPause() {
when (MediaPlayerBase.status) {
PlayerStatus.FALLBACK -> toggleFallbackSpeed(1.0f)

View File

@ -34,14 +34,8 @@ abstract class EpisodeActionButton internal constructor(@JvmField var item: Epis
icon.setImageResource(getDrawable())
}
protected fun playVideoIfNeeded(context: Context, media: Playable) {
if (item.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY
&& videoPlayMode != VideoMode.AUDIO_ONLY.code && videoMode != VideoMode.AUDIO_ONLY
&& media.getMediaType() == MediaType.VIDEO)
context.startActivity(getPlayerActivityIntent(context, MediaType.VIDEO))
}
@UnstableApi companion object {
fun forItem(episode: Episode): EpisodeActionButton {
val media = episode.media ?: return TTSActionButton(episode)
val isDownloadingMedia = when (media.downloadUrl) {
@ -60,5 +54,13 @@ abstract class EpisodeActionButton internal constructor(@JvmField var item: Epis
else -> DownloadActionButton(episode)
}
}
fun playVideoIfNeeded(context: Context, media: Playable) {
val item = (media as? EpisodeMedia)?.episode
if (item?.feed?.preferences?.videoModePolicy != VideoMode.AUDIO_ONLY
&& videoPlayMode != VideoMode.AUDIO_ONLY.code && videoMode != VideoMode.AUDIO_ONLY
&& media.getMediaType() == MediaType.VIDEO)
context.startActivity(getPlayerActivityIntent(context, MediaType.VIDEO))
}
}
}

View File

@ -3,6 +3,7 @@ package ac.mdiq.podcini.ui.actions.actionbutton
import ac.mdiq.podcini.R
import ac.mdiq.podcini.playback.PlaybackServiceStarter
import ac.mdiq.podcini.playback.base.InTheatre
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.clearCurTempSpeed
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.playbackService
import ac.mdiq.podcini.storage.database.RealmDB.realm
import ac.mdiq.podcini.storage.database.RealmDB.upsertBlk
@ -42,6 +43,7 @@ class PlayActionButton(item: Episode) : EpisodeActionButton(item) {
playbackService?.mPlayer?.resume()
playbackService?.taskManager?.restartSleepTimer()
} else {
clearCurTempSpeed()
PlaybackServiceStarter(context, media).callEvenIfRunning(true).start()
EventFlow.postEvent(FlowEvent.PlayEvent(item))
}

View File

@ -3,6 +3,7 @@ package ac.mdiq.podcini.ui.actions.actionbutton
import ac.mdiq.podcini.R
import ac.mdiq.podcini.playback.PlaybackServiceStarter
import ac.mdiq.podcini.playback.base.InTheatre
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.clearCurTempSpeed
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.getPlayerActivityIntent
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.playbackService
import ac.mdiq.podcini.storage.model.Episode
@ -33,6 +34,7 @@ class PlayLocalActionButton(item: Episode) : EpisodeActionButton(item) {
playbackService?.mPlayer?.resume()
playbackService?.taskManager?.restartSleepTimer()
} else {
clearCurTempSpeed()
PlaybackServiceStarter(context, media).callEvenIfRunning(true).start()
EventFlow.postEvent(FlowEvent.PlayEvent(item))
}

View File

@ -4,9 +4,12 @@ import ac.mdiq.podcini.R
import ac.mdiq.podcini.net.utils.NetworkUtils.isAllowMobileStreaming
import ac.mdiq.podcini.net.utils.NetworkUtils.isStreamingAllowed
import ac.mdiq.podcini.playback.PlaybackServiceStarter
import ac.mdiq.podcini.playback.base.InTheatre
import ac.mdiq.podcini.playback.service.PlaybackService.Companion.clearCurTempSpeed
import ac.mdiq.podcini.preferences.UsageStatistics
import ac.mdiq.podcini.preferences.UsageStatistics.logAction
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.model.RemoteMedia
import ac.mdiq.podcini.util.EventFlow
@ -34,10 +37,7 @@ class StreamActionButton(item: Episode) : EpisodeActionButton(item) {
StreamingConfirmationDialog(context, media).show()
return
}
PlaybackServiceStarter(context, media).shouldStreamThisTime(true).callEvenIfRunning(true).start()
EventFlow.postEvent(FlowEvent.PlayEvent(item))
playVideoIfNeeded(context, media)
stream(context, media)
}
class StreamingConfirmationDialog(private val context: Context, private val playable: Playable) {
@ -46,17 +46,23 @@ class StreamActionButton(item: Episode) : EpisodeActionButton(item) {
MaterialAlertDialogBuilder(context)
.setTitle(R.string.stream_label)
.setMessage(R.string.confirm_mobile_streaming_notification_message)
.setPositiveButton(R.string.confirm_mobile_streaming_button_once) { _: DialogInterface?, _: Int -> stream() }
.setPositiveButton(R.string.confirm_mobile_streaming_button_once) { _: DialogInterface?, _: Int -> stream(context, playable) }
.setNegativeButton(R.string.confirm_mobile_streaming_button_always) { _: DialogInterface?, _: Int ->
isAllowMobileStreaming = true
stream()
stream(context, playable)
}
.setNeutralButton(R.string.cancel_label, null)
.show()
}
@UnstableApi
private fun stream() {
PlaybackServiceStarter(context, playable).callEvenIfRunning(true).shouldStreamThisTime(true).start()
}
companion object {
fun stream(context: Context, media: Playable) {
if (media !is EpisodeMedia || !InTheatre.isCurMedia(media)) clearCurTempSpeed()
PlaybackServiceStarter(context, media).shouldStreamThisTime(true).callEvenIfRunning(true).start()
if (media is EpisodeMedia && media.episode != null) EventFlow.postEvent(FlowEvent.PlayEvent(media.episode!!))
playVideoIfNeeded(context, media)
}
}
}

View File

@ -241,7 +241,6 @@ open class VariableSpeedDialog : BottomSheetDialogFragment() {
private fun setPlaybackSpeed(speed: Float, codeArray: BooleanArray? = null) {
if (playbackService != null) {
// playbackService!!.setSpeed(speed, codeArray)
playbackService!!.isSpeedForward = false
playbackService!!.isFallbackSpeed = false

View File

@ -105,6 +105,7 @@ import kotlin.math.max
private lateinit var spinnerTexts: MutableList<String>
private lateinit var queueSpinner: Spinner
private lateinit var spinnerAdaptor: ArrayAdapter<String>
private lateinit var queues: List<PlayQueue>
private var displayUpArrow = false
private var queueItems: MutableList<Episode> = mutableListOf()
@ -136,7 +137,7 @@ import kotlin.math.max
displayUpArrow = parentFragmentManager.backStackEntryCount != 0
if (savedInstanceState != null) displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW)
val queues = realm.query(PlayQueue::class).find()
queues = realm.query(PlayQueue::class).find()
queueNames = queues.map { it.name }.toTypedArray()
spinnerTexts = queues.map { "${it.name} : ${it.episodeIds.size}" }.toMutableList()
spinnerLayout = inflater.inflate(R.layout.queue_title_spinner, toolbar, false)
@ -588,11 +589,9 @@ import kotlin.math.max
newQueue.id = queueNames.size.toLong()
newQueue.name = newName
upsertBlk(newQueue) {}
val queues = realm.query(PlayQueue::class).find()
queues = realm.query(PlayQueue::class).find()
queueNames = queues.map { it.name }.toTypedArray()
spinnerTexts.addAll(queues.map { "${it.name} : ${it.episodeIds.size}" })
// spinnerAdaptor = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, spinnerTexts)
// spinnerAdaptor.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinnerAdaptor.notifyDataSetChanged()
queueSpinner.adapter = spinnerAdaptor
queueSpinner.setSelection(spinnerAdaptor.getPosition(curQueue.name))

View File

@ -1,3 +1,8 @@
# 6.5.10
* fixed crash when switching to a newly created queue in Queues view
* reset temp speed when manually playing a new episode to ensure preset speed is used
# 6.5.9
* partially fixed an issue seen on Samsung Android 14 device where after playing the user-started episode, subsequent episode in the queue is not played in foreground service and there is not notification panel and can get stopped by the system.

View File

@ -0,0 +1,4 @@
Version 6.5.10 brings several changes:
* fixed crash when switching to a newly created queue in Queues view
* reset temp speed when manually playing a new episode to ensure preset speed is used