Skip to content

Commit

Permalink
5.5.1 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Jun 18, 2024
1 parent 2c23d9f commit a78d108
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ android {
// Version code schema (not used):
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 3020150
versionName "5.5.0"
versionCode 3020151
versionName "5.5.1"

def commit = ""
try {
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/ac/mdiq/podcini/net/sync/model/EpisodeAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ class EpisodeAction private constructor(builder: Builder) {
*/
val total: Int

val playState: Int

init {
this.guid = builder.guid
this.action = builder.action
this.timestamp = builder.timestamp
this.started = builder.started
this.position = builder.position
this.playState = builder.playState
this.total = builder.total
}

Expand All @@ -54,7 +57,7 @@ class EpisodeAction private constructor(builder: Builder) {
if (o !is EpisodeAction) return false

val that = o
return started == that.started && position == that.position && total == that.total && action != that.action && podcast == that.podcast && episode == that.episode && timestamp == that.timestamp && guid == that.guid
return started == that.started && position == that.position && total == that.total && playState == that.playState && action != that.action && podcast == that.podcast && episode == that.episode && timestamp == that.timestamp && guid == that.guid
}

override fun hashCode(): Int {
Expand All @@ -65,6 +68,7 @@ class EpisodeAction private constructor(builder: Builder) {
result = 31 * result + (timestamp?.hashCode() ?: 0)
result = 31 * result + started
result = 31 * result + position
result = 31 * result + playState
result = 31 * result + total
return result
}
Expand All @@ -87,6 +91,7 @@ class EpisodeAction private constructor(builder: Builder) {
if (this.action == Action.PLAY) {
obj.put("started", this.started)
obj.put("position", this.position)
obj.put("playState", this.playState)
obj.put("total", this.total)
}
} catch (e: JSONException) {
Expand All @@ -97,7 +102,7 @@ class EpisodeAction private constructor(builder: Builder) {
}

override fun toString(): String {
return ("EpisodeAction{podcast='$podcast', episode='$episode', guid='$guid', action=$action, timestamp=$timestamp, started=$started, position=$position, total=$total}")
return ("EpisodeAction{podcast='$podcast', episode='$episode', guid='$guid', action=$action, timestamp=$timestamp, started=$started, position=$position, total=$total playState=$playState}")
}

enum class Action {
Expand All @@ -111,6 +116,7 @@ class EpisodeAction private constructor(builder: Builder) {
var started: Int = -1
var position: Int = -1
var total: Int = -1
var playState: Int = 0
var guid: String? = null

constructor(item: FeedItem, action: Action) : this(item.feed?.download_url, item.media?.download_url, action) {
Expand Down Expand Up @@ -146,6 +152,11 @@ class EpisodeAction private constructor(builder: Builder) {
return this
}

fun playState(playState: Int): Builder {
if (action == Action.PLAY) this.playState = playState
return this
}

fun build(): EpisodeAction {
return EpisodeAction(this)
}
Expand Down Expand Up @@ -197,6 +208,8 @@ class EpisodeAction private constructor(builder: Builder) {
val started = `object`.optInt("started", -1)
val position = `object`.optInt("position", -1)
val total = `object`.optInt("total", -1)
val playState = `object`.optInt("playState", 0)
builder.playState(playState)
if (started >= 0 && position > 0 && total > 0) builder.started(started).position(position).total(total)
}
return builder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ac.mdiq.podcini.storage.DBReader.getFeedItemByGuidOrEpisodeUrl
import ac.mdiq.podcini.storage.DBReader.getFeedMedia
import ac.mdiq.podcini.storage.DBWriter.persistFeedMediaPlaybackInfo
import ac.mdiq.podcini.storage.model.feed.FeedItem
import ac.mdiq.podcini.storage.model.feed.FeedItem.Companion.PLAYED
import ac.mdiq.podcini.storage.model.feed.FeedItemFilter
import ac.mdiq.podcini.storage.model.feed.SortOrder
import ac.mdiq.podcini.util.FeedItemUtil.hasAlmostEnded
Expand Down Expand Up @@ -256,6 +257,7 @@ import kotlin.math.min
.started(media.getPosition() / 1000)
.position(media.getPosition() / 1000)
.total(media.getDuration() / 1000)
.playState(item.playState)
.build()
queuedEpisodeActions.add(played)
}
Expand Down Expand Up @@ -324,6 +326,7 @@ import kotlin.math.min
if (feedItem.media!!.getLastPlayedTime() < (action.timestamp?.time?:0L)) {
feedItem.media!!.setPosition(action.position * 1000)
feedItem.media!!.setLastPlayedTime(action.timestamp!!.time)
feedItem.setPlayed(action.playState == PLAYED)
if (hasAlmostEnded(feedItem.media!!)) {
Logd(TAG, "Marking as played")
feedItem.setPlayed(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ac.mdiq.podcini.storage.DBReader.getFeedItemByGuidOrEpisodeUrl
import ac.mdiq.podcini.storage.DBReader.loadAdditionalFeedItemListData
import ac.mdiq.podcini.storage.DBWriter.persistItemList
import ac.mdiq.podcini.storage.model.feed.FeedItem
import ac.mdiq.podcini.storage.model.feed.FeedItem.Companion.PLAYED
import ac.mdiq.podcini.util.FeedItemUtil.hasAlmostEnded
import ac.mdiq.podcini.util.Logd
import android.util.Log
Expand Down Expand Up @@ -58,6 +59,8 @@ object EpisodeProgressReader {
}
var idRemove = 0L
feedItem.media!!.setPosition(action.position * 1000)
feedItem.setPlayed(action.playState == PLAYED)
feedItem.media!!.setLastPlayedTime(action.timestamp!!.time)
if (hasAlmostEnded(feedItem.media!!)) {
Logd(SyncService.TAG, "Marking as played: $action")
feedItem.setPlayed(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class EpisodesProgressWriter : ExportWriter {
.started(media.getPosition() / 1000)
.position(media.getPosition() / 1000)
.total(media.getDuration() / 1000)
.playState(item.playState)
.build()
queuedEpisodeActions.add(played)
}
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 5.5.1

* a minor release for better migration to Podcini 6
* in wifi sync and episode progress export/import, included the info for episodes not played or not finished playing but marked as played

## 5.5.0

* likely fixed Nextcloud Gpoddersync fails
Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/3020151.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Version 5.5.1 brings several changes:

* a minor release for better migration to Podcini 6
* in wifi sync and episode progress export/import, included the info for episodes not played or not finished playing but marked as played

0 comments on commit a78d108

Please sign in to comment.