Skip to content

Commit

Permalink
6.0.6 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Jul 8, 2024
1 parent 27f5f5e commit 09328bf
Show file tree
Hide file tree
Showing 96 changed files with 311 additions and 359 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ android {
buildConfig true
}
defaultConfig {
versionCode 3020205
versionName "6.0.5"
versionCode 3020206
versionName "6.0.6"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down Expand Up @@ -265,7 +265,7 @@ dependencies {
testImplementation 'org.awaitility:awaitility:4.2.1'
testImplementation "junit:junit:4.13.2"
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.robolectric:robolectric:4.12'
testImplementation 'org.robolectric:robolectric:4.13'
testImplementation 'javax.inject:javax.inject:1'

playImplementation 'com.google.android.gms:play-services-base:18.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import ac.mdiq.podcini.storage.database.Episodes.getEpisode
import ac.mdiq.podcini.storage.database.Episodes.getEpisodes
import ac.mdiq.podcini.storage.database.Queues.clearQueue
import ac.mdiq.podcini.storage.database.Queues.getInQueueEpisodeIds
import ac.mdiq.podcini.storage.utils.EpisodeFilter.Companion.unfiltered
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.model.EpisodeFilter.Companion.unfiltered
import ac.mdiq.podcini.storage.model.SortOrder
import ac.mdiq.podcini.ui.activity.MainActivity
import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.test.podcini.service.playback

import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.playback.base.MediaPlayerBase.MediaPlayerInfo
import ac.mdiq.podcini.playback.base.MediaPlayerCallback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.test.podcini.service.playback

import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.playback.base.MediaPlayerBase.MediaPlayerInfo
import ac.mdiq.podcini.playback.base.MediaPlayerCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ac.mdiq.podcini.playback.base.MediaPlayerBase.MediaPlayerInfo
import ac.mdiq.podcini.playback.base.PlayerStatus
import ac.mdiq.podcini.playback.service.LocalMediaPlayer
import ac.mdiq.podcini.storage.model.*
import ac.mdiq.podcini.storage.utils.VolumeAdaptionSetting
import ac.mdiq.podcini.storage.model.VolumeAdaptionSetting
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ac.mdiq.podcini.net.download

import ac.mdiq.podcini.storage.model.FeedPreferences.AutoDeleteAction
import ac.mdiq.podcini.storage.model.FeedPreferences.AutoDeleteAction.NEVER

/** Utility class for Download Errors. */
/** Get machine-readable code. */
enum class DownloadError(@JvmField val code: Int) {
Expand Down Expand Up @@ -31,10 +34,7 @@ enum class DownloadError(@JvmField val code: Int) {
/** Return DownloadError from its associated code. */
@JvmStatic
fun fromCode(code: Int): DownloadError {
for (reason in entries) {
if (reason.code == code) return reason
}
throw IllegalArgumentException("unknown code: $code")
return enumValues<DownloadError>().firstOrNull { it.code == code } ?: throw IllegalArgumentException("unknown code: $code")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ac.mdiq.podcini.storage.database.LogsAndStats
import ac.mdiq.podcini.storage.database.RealmDB.unmanaged
import ac.mdiq.podcini.storage.model.DownloadResult
import ac.mdiq.podcini.storage.model.FeedPreferences
import ac.mdiq.podcini.storage.utils.VolumeAdaptionSetting
import ac.mdiq.podcini.storage.model.VolumeAdaptionSetting
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.util.config.ClientConfigurator
import ac.mdiq.podcini.util.event.EventFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ac.mdiq.podcini.storage.model.DownloadResult
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.storage.utils.FastDocumentFile
import ac.mdiq.podcini.util.Logd
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ac.mdiq.podcini.net.feed.parser

import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.utils.FeedFunding
import ac.mdiq.podcini.storage.model.FeedFunding
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.net.feed.parser.element.SyndElement
import ac.mdiq.podcini.net.feed.parser.namespace.Namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ac.mdiq.podcini.net.feed.parser.media.id3

import android.util.Log
import ac.mdiq.podcini.storage.model.Chapter
import ac.mdiq.podcini.storage.utils.EmbeddedChapterImage.Companion.makeUrl
import ac.mdiq.podcini.storage.model.EmbeddedChapterImage.Companion.makeUrl
import ac.mdiq.podcini.net.feed.parser.media.id3.model.FrameHeader
import ac.mdiq.podcini.util.Logd
import org.apache.commons.io.input.CountingInputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ac.mdiq.podcini.net.feed.parser.utils.MimeTypeUtils.getMimeType
import ac.mdiq.podcini.net.feed.parser.utils.MimeTypeUtils.isMediaFile
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.utils.FeedFunding
import ac.mdiq.podcini.storage.model.FeedFunding
import ac.mdiq.podcini.util.Logd
import org.xml.sax.Attributes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ac.mdiq.podcini.net.feed.parser.namespace

import ac.mdiq.podcini.net.feed.parser.HandlerState
import ac.mdiq.podcini.storage.utils.FeedFunding
import ac.mdiq.podcini.storage.model.FeedFunding
import ac.mdiq.podcini.net.feed.parser.element.SyndElement
import org.xml.sax.Attributes

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/ac/mdiq/podcini/net/sync/SyncService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import ac.mdiq.podcini.storage.database.Feeds.updateFeed
import ac.mdiq.podcini.storage.database.Queues.removeFromQueue
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.utils.EpisodeFilter
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.model.SortOrder
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.event.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class EpisodeAction private constructor(builder: Builder) {
*/
val position: Int

var playedDuration: Int

/**
* Returns the total length of the file in seconds.
*
Expand All @@ -46,6 +48,7 @@ class EpisodeAction private constructor(builder: Builder) {
this.timestamp = builder.timestamp
this.started = builder.started
this.position = builder.position
this.playedDuration = builder.playedDuration
this.playState = builder.playState
this.isFavorite = builder.isFavorite
this.total = builder.total
Expand All @@ -60,7 +63,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 && isFavorite == that.isFavorite && action != that.action && podcast == that.podcast && episode == that.episode && timestamp == that.timestamp && guid == that.guid
return started == that.started && position == that.position && playedDuration == that.playedDuration && 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 All @@ -71,6 +74,7 @@ class EpisodeAction private constructor(builder: Builder) {
result = 31 * result + (timestamp?.hashCode() ?: 0)
result = 31 * result + started
result = 31 * result + position
result = 31 * result + playedDuration
result = 31 * result + playState
result = 31 * result + total
return result
Expand All @@ -94,6 +98,7 @@ class EpisodeAction private constructor(builder: Builder) {
if (this.action == Action.PLAY) {
obj.put("started", this.started)
obj.put("position", this.position)
obj.put("playedDuration", this.playedDuration)
obj.put("playState", this.playState)
obj.put("total", this.total)
obj.put("isFavorite", this.isFavorite)
Expand All @@ -119,6 +124,7 @@ class EpisodeAction private constructor(builder: Builder) {
var timestamp: Date? = null
var started: Int = -1
var position: Int = -1
var playedDuration: Int = -1
var total: Int = -1
var playState: Int = 0
var isFavorite: Boolean = false
Expand Down Expand Up @@ -152,6 +158,11 @@ class EpisodeAction private constructor(builder: Builder) {
return this
}

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

fun total(seconds: Int): Builder {
if (action == Action.PLAY) this.total = seconds
return this
Expand Down Expand Up @@ -217,11 +228,12 @@ class EpisodeAction private constructor(builder: Builder) {
if (action == Action.PLAY) {
val started = `object`.optInt("started", -1)
val position = `object`.optInt("position", -1)
val playedDuration = `object`.optInt("playedDuration", -1)
val total = `object`.optInt("total", -1)
val playState = `object`.optInt("playState", 0)
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)
if (started >= 0 && position >= 0 && playedDuration >= 0 && total > 0) builder.started(started).position(position).playedDuration(playedDuration).total(total)
}
return builder.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import ac.mdiq.podcini.storage.database.Episodes.getEpisodeByGuidOrUrl
import ac.mdiq.podcini.storage.database.Episodes.getEpisodes
import ac.mdiq.podcini.storage.database.Episodes.persistEpisode
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.utils.EpisodeFilter
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.model.SortOrder
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.event.EventFlow
import ac.mdiq.podcini.util.event.FlowEvent
Expand Down Expand Up @@ -256,8 +256,9 @@ import kotlin.math.min
val media = item.media ?: continue
val played = EpisodeAction.Builder(item, EpisodeAction.PLAY)
.timestamp(Date(media.getLastPlayedTime()))
.started(media.getPosition() / 1000)
.started(media.startPosition / 1000)
.position(media.getPosition() / 1000)
.playedDuration(media.playedDuration / 1000)
.total(media.getDuration() / 1000)
.isFavorite(item.isFavorite)
.playState(item.playState)
Expand Down Expand Up @@ -327,7 +328,9 @@ import kotlin.math.min
var idRemove: Long? = null
Logd(TAG, "processEpisodeAction ${feedItem.media!!.getLastPlayedTime()} ${(action.timestamp?.time?:0L)} ${action.position} ${feedItem.title}")
if (feedItem.media!!.getLastPlayedTime() < (action.timestamp?.time?:0L)) {
feedItem.media!!.startPosition = action.started * 1000
feedItem.media!!.setPosition(action.position * 1000)
feedItem.media!!.playedDuration = action.playedDuration * 1000
feedItem.media!!.setLastPlayedTime(action.timestamp!!.time)
feedItem.isFavorite = action.isFavorite
feedItem.playState = action.playState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ac.mdiq.podcini.playback.service.PlaybackService.Companion.isRunning
import ac.mdiq.podcini.playback.service.PlaybackService.LocalBinder
import ac.mdiq.podcini.preferences.UserPreferences.isSkipSilence
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.activity.starter.VideoPlayerActivityStarter
import ac.mdiq.podcini.util.Logd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ac.mdiq.podcini.preferences.UserPreferences
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.model.FeedPreferences
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.util.Logd
import android.content.Context
import android.media.AudioManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ac.mdiq.podcini.playback.base

import ac.mdiq.podcini.playback.base.MediaPlayerBase.MediaPlayerInfo
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType

interface MediaPlayerCallback {
fun statusChanged(newInfo: MediaPlayerInfo?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ac.mdiq.podcini.preferences.UserPreferences
import ac.mdiq.podcini.storage.database.RealmDB.runOnIOScope
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.config.ClientConfig
import ac.mdiq.podcini.util.event.EventFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ import ac.mdiq.podcini.storage.model.FeedPreferences
import ac.mdiq.podcini.storage.model.FeedPreferences.AutoDeleteAction
import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.utils.VolumeAdaptionSetting
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.storage.model.VolumeAdaptionSetting
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.ui.widget.WidgetUpdater.WidgetState
import ac.mdiq.podcini.util.IntentUtils.sendLocalBroadcast
Expand Down Expand Up @@ -318,7 +318,7 @@ class PlaybackService : MediaSessionService() {
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(Episode.PLAYED, ended || (skipped && smartMarkAsPlayed), item!!)
val action = item?.feed?.preferences?.currentAutoDelete
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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package ac.mdiq.podcini.preferences

import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.model.ProxyConfig
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.utils.MediaType
import ac.mdiq.podcini.storage.model.SortOrder
import ac.mdiq.podcini.storage.model.MediaType
import ac.mdiq.podcini.util.Logd
import android.content.Context
import android.content.SharedPreferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import ac.mdiq.podcini.storage.database.RealmDB.upsertBlk
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.preferences.OpmlTransporter.*
import ac.mdiq.podcini.storage.utils.EpisodeFilter
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.model.SortOrder
import ac.mdiq.podcini.ui.activity.OpmlImportActivity
import ac.mdiq.podcini.ui.activity.PreferenceActivity
import ac.mdiq.podcini.util.Logd
Expand All @@ -34,7 +34,6 @@ import android.os.Bundle
import android.os.ParcelFileDescriptor
import android.text.format.Formatter
import android.util.Log
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
Expand Down Expand Up @@ -281,7 +280,7 @@ class ImportExportPreferencesFragment : PreferenceFragmentCompat() {
builder.setNegativeButton(R.string.no, null)
builder.setPositiveButton(R.string.confirm_label) { _: DialogInterface?, _: Int ->
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
intent.setType("application/octet-stream")
intent.setType("*/*")
intent.addCategory(Intent.CATEGORY_OPENABLE)
restoreProgressLauncher.launch(intent)
}
Expand Down Expand Up @@ -711,7 +710,9 @@ class ImportExportPreferencesFragment : PreferenceFragmentCompat() {
return null
}
var idRemove = 0L
feedItem.media!!.startPosition = action.started * 1000
feedItem.media!!.setPosition(action.position * 1000)
feedItem.media!!.playedDuration = action.playedDuration * 1000
feedItem.media!!.setLastPlayedTime(action.timestamp!!.time)
feedItem.isFavorite = action.isFavorite
feedItem.playState = action.playState
Expand Down Expand Up @@ -743,8 +744,9 @@ class ImportExportPreferencesFragment : PreferenceFragmentCompat() {
val media = item.media ?: continue
val played = EpisodeAction.Builder(item, EpisodeAction.PLAY)
.timestamp(Date(media.getLastPlayedTime()))
.started(media.getPosition() / 1000)
.started(media.startPosition / 1000)
.position(media.getPosition() / 1000)
.playedDuration(media.playedDuration / 1000)
.total(media.getDuration() / 1000)
.isFavorite(item.isFavorite)
.playState(item.playState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import ac.mdiq.podcini.storage.database.Episodes.getEpisodes
import ac.mdiq.podcini.storage.database.Episodes.getEpisodesCount
import ac.mdiq.podcini.storage.database.Queues.getInQueueEpisodeIds
import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.utils.EpisodeFilter
import ac.mdiq.podcini.storage.utils.SortOrder
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.model.SortOrder
import android.content.Context
import android.util.Log
import androidx.annotation.OptIn
Expand Down
Loading

0 comments on commit 09328bf

Please sign in to comment.