Skip to content

Commit

Permalink
5.5.2 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Jun 19, 2024
1 parent a78d108 commit 0f8d450
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 5 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 3020151
versionName "5.5.1"
versionCode 3020152
versionName "5.5.2"

def commit = ""
try {
Expand Down
17 changes: 14 additions & 3 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 @@ -38,13 +38,16 @@ class EpisodeAction private constructor(builder: Builder) {

val playState: Int

val isFavorite: Boolean

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.isFavorite = builder.isFavorite
this.total = builder.total
}

Expand All @@ -57,7 +60,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 && playState == that.playState && 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 && isFavorite == that.isFavorite && action != that.action && podcast == that.podcast && episode == that.episode && timestamp == that.timestamp && guid == that.guid
}

override fun hashCode(): Int {
Expand Down Expand Up @@ -93,6 +96,7 @@ class EpisodeAction private constructor(builder: Builder) {
obj.put("position", this.position)
obj.put("playState", this.playState)
obj.put("total", this.total)
obj.put("isFavorite", this.isFavorite)
}
} catch (e: JSONException) {
Log.e(TAG, "writeToJSONObject(): " + e.message)
Expand All @@ -102,7 +106,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 playState=$playState}")
return ("EpisodeAction{podcast='$podcast', episode='$episode', guid='$guid', action=$action, timestamp=$timestamp, started=$started, position=$position, total=$total playState=$playState isFavorite=$isFavorite}")
}

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

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

fun isFavorite(isFavorite: Boolean): Builder {
if (action == Action.PLAY) this.isFavorite = isFavorite
return this
}

fun build(): EpisodeAction {
return EpisodeAction(this)
}
Expand Down Expand Up @@ -209,7 +219,8 @@ class EpisodeAction private constructor(builder: Builder) {
val position = `object`.optInt("position", -1)
val total = `object`.optInt("total", -1)
val playState = `object`.optInt("playState", 0)
builder.playState(playState)
val isFavorite = `object`.optBoolean("isFavorite", false)
builder.playState(playState).isFavorite(isFavorite)
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 @@ -246,9 +246,11 @@ import kotlin.math.min
// only push downloaded items
val pausedItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.PAUSED), SortOrder.DATE_NEW_OLD)
val readItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.PLAYED), SortOrder.DATE_NEW_OLD)
val favoriteItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.IS_FAVORITE), SortOrder.DATE_NEW_OLD)
val comItems = mutableSetOf<FeedItem>()
comItems.addAll(pausedItems)
comItems.addAll(readItems)
comItems.addAll(favoriteItems)
Logd(TAG, "First sync. Upload state for all " + comItems.size + " played episodes")
for (item in comItems) {
val media = item.media ?: continue
Expand All @@ -257,6 +259,7 @@ import kotlin.math.min
.started(media.getPosition() / 1000)
.position(media.getPosition() / 1000)
.total(media.getDuration() / 1000)
.isFavorite(item.isTagged(FeedItem.TAG_FAVORITE))
.playState(item.playState)
.build()
queuedEpisodeActions.add(played)
Expand Down Expand Up @@ -326,6 +329,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)
if (action.isFavorite) feedItem.addTag(FeedItem.TAG_FAVORITE)
feedItem.setPlayed(action.playState == PLAYED)
if (hasAlmostEnded(feedItem.media!!)) {
Logd(TAG, "Marking as played")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ object EpisodeProgressReader {
var idRemove = 0L
feedItem.media!!.setPosition(action.position * 1000)
feedItem.setPlayed(action.playState == PLAYED)
if (action.isFavorite) feedItem.addTag(FeedItem.TAG_FAVORITE)
feedItem.media!!.setLastPlayedTime(action.timestamp!!.time)
if (hasAlmostEnded(feedItem.media!!)) {
Logd(SyncService.TAG, "Marking as played: $action")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ class EpisodesProgressWriter : ExportWriter {
val queuedEpisodeActions: MutableList<EpisodeAction> = mutableListOf()
val pausedItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.PAUSED), SortOrder.DATE_NEW_OLD)
val readItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.PLAYED), SortOrder.DATE_NEW_OLD)
val favoriteItems = getEpisodes(0, Int.MAX_VALUE, FeedItemFilter(FeedItemFilter.IS_FAVORITE), SortOrder.DATE_NEW_OLD)
val comItems = mutableSetOf<FeedItem>()
comItems.addAll(pausedItems)
comItems.addAll(readItems)
comItems.addAll(favoriteItems)
Logd(TAG, "Save state for all " + comItems.size + " played episodes")
for (item in comItems) {
val media = item.media ?: continue
Expand All @@ -36,6 +38,7 @@ class EpisodesProgressWriter : ExportWriter {
.started(media.getPosition() / 1000)
.position(media.getPosition() / 1000)
.total(media.getDuration() / 1000)
.isFavorite(item.isTagged(FeedItem.TAG_FAVORITE))
.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.2

* another minor release for better migration to Podcini 6
* in wifi sync and episode progress export/import, included favorites info for episodes

## 5.5.1

* a minor release for better migration to Podcini 6
Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/3020152.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Version 5.5.2 brings several changes:

* another minor release for better migration to Podcini 6
* in wifi sync and episode progress export/import, included favorites info for episodes

0 comments on commit 0f8d450

Please sign in to comment.