5.5.2 commit

This commit is contained in:
Xilin Jia 2024-06-19 09:52:17 +01:00
parent a78d108dc9
commit 0f8d4504c7
7 changed files with 34 additions and 5 deletions

View File

@ -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 {

View File

@ -38,6 +38,8 @@ class EpisodeAction private constructor(builder: Builder) {
val playState: Int
val isFavorite: Boolean
init {
this.guid = builder.guid
this.action = builder.action
@ -45,6 +47,7 @@ class EpisodeAction private constructor(builder: Builder) {
this.started = builder.started
this.position = builder.position
this.playState = builder.playState
this.isFavorite = builder.isFavorite
this.total = builder.total
}
@ -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 {
@ -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)
@ -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 {
@ -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) {
@ -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)
}
@ -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()

View File

@ -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
@ -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)
@ -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")

View File

@ -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")

View File

@ -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
@ -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)

View File

@ -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

View File

@ -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