Skip to content

Commit

Permalink
6.12.2 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Oct 23, 2024
1 parent 79c1bf4 commit d3ca132
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 217 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

versionCode 3020279
versionName "6.12.1"
versionCode 3020280
versionName "6.12.2"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class ServiceStatusHandler(private val activity: FragmentActivity) {
Logd(TAG, "statusUpdate onReceive doing updates")
MediaPlayerBase.status = info.playerStatus
prevStatus = MediaPlayerBase.status
curMedia = info.playable
// curMedia = info.playable
handleStatus()
}
} else {
Expand Down Expand Up @@ -177,7 +177,7 @@ abstract class ServiceStatusHandler(private val activity: FragmentActivity) {
Logd(TAG, "Querying service info")
if (playbackService != null && PlaybackService.mPlayerInfo != null) {
MediaPlayerBase.status = PlaybackService.mPlayerInfo!!.playerStatus
curMedia = PlaybackService.mPlayerInfo!!.playable
// curMedia = PlaybackService.mPlayerInfo!!.playable
// make sure that new media is loaded if it's available
mediaInfoLoaded = false
handleStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,13 @@ abstract class MediaPlayerBase protected constructor(protected val context: Cont
Log.d(TAG, "${this.javaClass.simpleName}: Setting player status to $newStatus")
this.oldStatus = status
status = newStatus
if (newMedia != null) setPlayable(newMedia)
if (newMedia != null && newStatus != PlayerStatus.INDETERMINATE) {
when {
oldStatus == PlayerStatus.PLAYING && newStatus != PlayerStatus.PLAYING -> callback.onPlaybackPause(newMedia, position)
oldStatus != PlayerStatus.PLAYING && newStatus == PlayerStatus.PLAYING -> callback.onPlaybackStart(newMedia, position)
if (newMedia != null) {
setPlayable(newMedia)
if (newStatus != PlayerStatus.INDETERMINATE) {
when {
oldStatus == PlayerStatus.PLAYING && newStatus != PlayerStatus.PLAYING -> callback.onPlaybackPause(newMedia, position)
oldStatus != PlayerStatus.PLAYING && newStatus == PlayerStatus.PLAYING -> callback.onPlaybackStart(newMedia, position)
}
}
}
callback.statusChanged(MediaPlayerInfo(oldStatus, status, curMedia))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,23 @@ class PlaybackService : MediaLibraryService() {
}
}
if (item != null) {
// fun shouldSkipKeepEpisode(): Boolean {
// return appPrefs.getBoolean(UserPreferences.Prefs.prefSkipKeepsEpisode.name, true)
// }
// fun shouldFavoriteKeepEpisode(): Boolean {
// return appPrefs.getBoolean(UserPreferences.Prefs.prefFavoriteKeepsEpisode.name, true)
// }
runOnIOScope {
if (ended || smartMarkAsPlayed || autoSkipped || (skipped && !shouldSkipKeepEpisode())) {
val shouldSkipKeepEpisode = appPrefs.getBoolean(UserPreferences.Prefs.prefSkipKeepsEpisode.name, true)
val shouldFavoriteKeepEpisode = appPrefs.getBoolean(UserPreferences.Prefs.prefFavoriteKeepsEpisode.name, true)
if (ended || smartMarkAsPlayed || autoSkipped || (skipped && !shouldSkipKeepEpisode)) {
Logd(TAG, "onPostPlayback ended: $ended smartMarkAsPlayed: $smartMarkAsPlayed autoSkipped: $autoSkipped skipped: $skipped")
// only mark the item as played if we're not keeping it anyways
item = setPlayStateSync(PlayState.PLAYED.code, ended || (skipped && smartMarkAsPlayed), item!!)
val action = item?.feed?.preferences?.autoDeleteAction
val shouldAutoDelete = (action == AutoDeleteAction.ALWAYS ||
(action == AutoDeleteAction.GLOBAL && item?.feed != null && shouldAutoDeleteItem(item!!.feed!!)))
if (playable is EpisodeMedia && shouldAutoDelete && (item?.isFavorite != true || !shouldFavoriteKeepEpisode())) {
if (playable is EpisodeMedia && shouldAutoDelete && (item?.isFavorite != true || !shouldFavoriteKeepEpisode)) {
item = deleteMediaSync(this@PlaybackService, item!!)
if (shouldDeleteRemoveFromQueue()) removeFromQueueSync(null, item!!)
}
Expand All @@ -407,14 +415,6 @@ class PlaybackService : MediaLibraryService() {
}
}

fun shouldSkipKeepEpisode(): Boolean {
return appPrefs.getBoolean(UserPreferences.Prefs.prefSkipKeepsEpisode.name, true)
}

fun shouldFavoriteKeepEpisode(): Boolean {
return appPrefs.getBoolean(UserPreferences.Prefs.prefFavoriteKeepsEpisode.name, true)
}

override fun onPlaybackStart(playable: Playable, position: Int) {
Logd(TAG, "onPlaybackStart position: $position")
taskManager.startWidgetUpdater()
Expand Down Expand Up @@ -747,12 +747,10 @@ class PlaybackService : MediaLibraryService() {

override fun onDestroy() {
Logd(TAG, "Service is about to be destroyed")

playbackService = null
isRunning = false
currentMediaType = MediaType.UNKNOWN
castStateListener.destroy()

currentitem = null

LocalMediaPlayer.cleanup()
Expand Down Expand Up @@ -1967,8 +1965,8 @@ class PlaybackService : MediaLibraryService() {
}
override fun onIsPlayingChanged(isPlaying: Boolean) {
// val stat = if (isPlaying) PlayerStatus.PLAYING else PlayerStatus.PAUSED
// TODO: test
val stat = if (isPlaying) PlayerStatus.PLAYING else PlayerStatus.INDETERMINATE
// TODO: test: changing PAUSED to STOPPED or INDETERMINATE makes resume not possible if interrupted
val stat = if (isPlaying) PlayerStatus.PLAYING else PlayerStatus.PAUSED
setPlayerStatus(stat, curMedia)
Logd(TAG, "onIsPlayingChanged $isPlaying")
}
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/model/EpisodeFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class EpisodeFilter(vararg properties: String) : Serializable {
val showNotAutoDownloadable: Boolean = hasProperty(States.not_auto_downloadable.name)
val showHasMedia: Boolean = hasProperty(States.has_media.name)
val showNoMedia: Boolean = hasProperty(States.no_media.name)
val showHasComments: Boolean = hasProperty(States.has_comments.name)
val showNoComments: Boolean = hasProperty(States.no_comments.name)
val showIsFavorite: Boolean = hasProperty(States.is_favorite.name)
val showNotFavorite: Boolean = hasProperty(States.not_favorite.name)

Expand Down Expand Up @@ -48,6 +50,8 @@ class EpisodeFilter(vararg properties: String) : Serializable {
showNotAutoDownloadable && item.isAutoDownloadEnabled -> return false
showHasMedia && item.media == null -> return false
showNoMedia && item.media != null -> return false
showHasComments && item.comment.isEmpty() -> return false
showNoComments && item.comment.isNotEmpty() -> return false
showIsFavorite && !item.isFavorite -> return false
showNotFavorite && item.isFavorite -> return false
showQueued && !inAnyQueue(item) -> return false
Expand All @@ -69,7 +73,7 @@ class EpisodeFilter(vararg properties: String) : Serializable {
val statements: MutableList<String> = ArrayList()
when {
showPlayed -> statements.add("playState >= ${PlayState.PLAYED.code}")
showUnplayed -> statements.add(" playState < ${PlayState.PLAYED.code}> ") // Match "New" items (read = -1) as well
showUnplayed -> statements.add(" playState < ${PlayState.PLAYED.code} ") // Match "New" items (read = -1) as well
showNew -> statements.add("playState == -1 ")
}
when {
Expand All @@ -93,8 +97,12 @@ class EpisodeFilter(vararg properties: String) : Serializable {
showNoMedia -> statements.add("media == nil ")
}
when {
showIsFavorite -> statements.add("isFavorite == true ")
showNotFavorite -> statements.add("isFavorite == false ")
showHasComments -> statements.add(" comment != '' ")
showNoComments -> statements.add(" comment == '' ")
}
when {
showIsFavorite -> statements.add("rating == ${Rating.FAVORITE.code} ")
showNotFavorite -> statements.add("rating != ${Rating.FAVORITE.code} ")
}

if (statements.isEmpty()) return "id > 0"
Expand All @@ -120,6 +128,8 @@ class EpisodeFilter(vararg properties: String) : Serializable {
not_favorite,
has_media,
no_media,
has_comments,
no_comments,
queued,
not_queued,
downloaded,
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/model/FeedFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class FeedFilter(vararg properties: String) : Serializable {
val showNotKeepUpdated: Boolean = hasProperty(States.not_keepUpdated.name)
val showGlobalPlaySpeed: Boolean = hasProperty(States.global_playSpeed.name)
val showCustomPlaySpeed: Boolean = hasProperty(States.custom_playSpeed.name)
val showHasComments: Boolean = hasProperty(States.has_comments.name)
val showNoComments: Boolean = hasProperty(States.no_comments.name)
val showHasSkips: Boolean = hasProperty(States.has_skips.name)
val showNoSkips: Boolean = hasProperty(States.no_skips.name)
val showAlwaysAutoDelete: Boolean = hasProperty(States.always_auto_delete.name)
Expand All @@ -36,6 +38,8 @@ class FeedFilter(vararg properties: String) : Serializable {
showNotKeepUpdated && feed.preferences?.keepUpdated != false -> return false
showGlobalPlaySpeed && feed.preferences?.playSpeed != SPEED_USE_GLOBAL -> return false
showCustomPlaySpeed && feed.preferences?.playSpeed == SPEED_USE_GLOBAL -> return false
showHasComments && feed.comment.isEmpty() -> return false
showNoComments && feed.comment.isEmpty() -> return false
showHasSkips && feed.preferences?.introSkip == 0 && feed.preferences?.endingSkip == 0 -> return false
showNoSkips && (feed.preferences?.introSkip != 0 || feed.preferences?.endingSkip != 0) -> return false
showAlwaysAutoDelete && feed.preferences?.autoDeleteAction != FeedPreferences.AutoDeleteAction.ALWAYS -> return false
Expand All @@ -60,6 +64,10 @@ class FeedFilter(vararg properties: String) : Serializable {
showHasSkips -> statements.add(" preferences.introSkip != 0 OR preferences.endingSkip != 0 ")
showNoSkips -> statements.add(" preferences.introSkip == 0 AND preferences.endingSkip == 0 ")
}
when {
showHasComments -> statements.add(" comment != '' ")
showNoComments -> statements.add(" comment == '' ")
}
when {
showAlwaysAutoDelete -> statements.add(" preferences.autoDelete == ${FeedPreferences.AutoDeleteAction.ALWAYS.code} ")
showNeverAutoDelete -> statements.add(" preferences.playSpeed == ${FeedPreferences.AutoDeleteAction.NEVER.code} ")
Expand Down Expand Up @@ -89,6 +97,8 @@ class FeedFilter(vararg properties: String) : Serializable {
custom_playSpeed,
has_skips,
no_skips,
has_comments,
no_comments,
// global_auto_delete,
always_auto_delete,
never_auto_delete,
Expand Down
Loading

0 comments on commit d3ca132

Please sign in to comment.