diff --git a/app/build.gradle b/app/build.gradle index ed92a517..d466d443 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 { diff --git a/app/src/main/java/ac/mdiq/podcini/net/sync/model/EpisodeAction.kt b/app/src/main/java/ac/mdiq/podcini/net/sync/model/EpisodeAction.kt index 257c5487..f6251dcf 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/sync/model/EpisodeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/sync/model/EpisodeAction.kt @@ -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() diff --git a/app/src/main/java/ac/mdiq/podcini/net/sync/wifi/WifiSyncService.kt b/app/src/main/java/ac/mdiq/podcini/net/sync/wifi/WifiSyncService.kt index fe1f6cfc..ef74a786 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/sync/wifi/WifiSyncService.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/sync/wifi/WifiSyncService.kt @@ -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() 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") diff --git a/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodeProgressReader.kt b/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodeProgressReader.kt index 403119a3..0cb7572f 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodeProgressReader.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodeProgressReader.kt @@ -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") diff --git a/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodesProgressWriter.kt b/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodesProgressWriter.kt index bbe1669b..ffa6b1b2 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodesProgressWriter.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/export/progress/EpisodesProgressWriter.kt @@ -25,9 +25,11 @@ class EpisodesProgressWriter : ExportWriter { val queuedEpisodeActions: MutableList = 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() 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) diff --git a/changelog.md b/changelog.md index 13aa3c4d..f743753b 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/fastlane/metadata/android/en-US/changelogs/3020152.txt b/fastlane/metadata/android/en-US/changelogs/3020152.txt new file mode 100644 index 00000000..8f595f51 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/3020152.txt @@ -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