Skip to content

Commit

Permalink
6.7.1 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Sep 18, 2024
1 parent 692426d commit daeee36
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 227 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ An open source podcast instrument, attuned to Puccini ![Puccini](./images/Puccin
#### Podcini.R 6.6 introduces the powerful feature of synthetic podcasts, enables the receiving/handling shared single media as well as playlist from Youtube and YT Music, for more see the Youtube section below or the changelogs.
That means finally: [Nessun dorma](https://www.youtube.com/watch?v=cWc7vYjgnTs)
#### Podcini.R version 6.5 as a major step forward brings YouTube channels in the app. They can be searched, received from share, subscribed and played from within Podcini. For more see the Youtube section below or the changelogs
#### If you are migrating from Podcini version 5, please read the migrationTo5.md file for migration instructions.
#### For Podcini to show up on car's HUD with Android Auto, please read AnroidAuto.md for instructions.
#### If you are migrating from Podcini version 5, please read the migrationTo5.md file for migration instructions.

This project was developed from a fork of [AntennaPod](<https://github.com/AntennaPod/AntennaPod>) as of Feb 5 2024.

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

versionCode 3020253
versionName "6.7.0"
versionCode 3020254
versionName "6.7.1"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package ac.mdiq.podcini.net.download.service

import ac.mdiq.podcini.net.utils.UrlChecker.prepareUrl
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.showStackTrace
import android.os.Bundle
import android.os.Parcel
import android.os.Parcelable
Expand All @@ -27,6 +26,7 @@ class DownloadRequest private constructor(
var size: Long = 0
private var statusMsg = 0

// only used in tests
constructor(destination: String, source: String, title: String, feedfileId: Long,
feedfileType: Int, username: String?, password: String?, arguments: Bundle?, initiatedByUser: Boolean)
: this(destination, source, title, feedfileId, feedfileType, null, username, password, false, arguments, initiatedByUser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package ac.mdiq.podcini.net.download.service
import ac.mdiq.podcini.R
import ac.mdiq.podcini.net.download.DownloadError
import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create
import ac.mdiq.podcini.net.sync.SynchronizationSettings.isProviderConnected
import ac.mdiq.podcini.net.sync.model.EpisodeAction
import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink
import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink.needSynch
import ac.mdiq.podcini.net.utils.NetworkUtils.isAllowMobileEpisodeDownload
import ac.mdiq.podcini.preferences.UserPreferences
import ac.mdiq.podcini.preferences.UserPreferences.appPrefs
Expand All @@ -21,10 +21,10 @@ import ac.mdiq.podcini.storage.utils.ChapterUtils
import ac.mdiq.podcini.storage.utils.MediaMetadataRetrieverCompat
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.config.ClientConfigurator
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.config.ClientConfigurator
import android.app.Notification
import android.app.NotificationManager
import android.app.PendingIntent
Expand Down Expand Up @@ -328,7 +328,7 @@ class DownloadServiceInterfaceImpl : DownloadServiceInterface() {
EventFlow.postEvent(FlowEvent.EpisodeEvent.updated(item))
// TODO: should use different event?
if (broadcastUnreadStateUpdate) EventFlow.postEvent(FlowEvent.EpisodePlayedEvent(item))
if (needSynch()) {
if (isProviderConnected) {
Logd(TAG, "enqueue synch")
val action = EpisodeAction.Builder(item, EpisodeAction.DOWNLOAD).currentTimestamp().build()
SynchronizationQueueSink.enqueueEpisodeActionIfSyncActive(context, action)
Expand Down
35 changes: 17 additions & 18 deletions app/src/main/kotlin/ac/mdiq/podcini/net/feed/FeedUpdateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ac.mdiq.podcini.net.feed
import ac.mdiq.podcini.R
import ac.mdiq.podcini.net.download.DownloadError
import ac.mdiq.podcini.net.download.service.DefaultDownloaderFactory
import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create
import ac.mdiq.podcini.net.download.service.DownloadRequest
import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create
import ac.mdiq.podcini.net.feed.parser.FeedHandler
import ac.mdiq.podcini.net.feed.parser.FeedHandler.FeedHandlerResult
import ac.mdiq.podcini.net.utils.NetworkUtils.isAllowMobileFeedRefresh
Expand Down Expand Up @@ -46,8 +46,6 @@ import androidx.core.app.NotificationManagerCompat
import androidx.media3.common.util.UnstableApi
import androidx.work.*
import androidx.work.Constraints.Builder
import com.annimon.stream.Collectors
import com.annimon.stream.Stream
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
Expand Down Expand Up @@ -163,7 +161,7 @@ object FeedUpdateManager {
feedsToUpdate.shuffle() // If the worker gets cancelled early, every feed has a chance to be updated
} else {
val feed = Feeds.getFeed(feedId) ?: return Result.success()
Logd(TAG, "doWork feed.downloadUrl: ${feed.downloadUrl}")
Logd(TAG, "doWork updating single feed: ${feed.title} ${feed.downloadUrl}")
if (!feed.isLocalFeed) allAreLocal = false
feedsToUpdate = mutableListOf(feed)
// feedsToUpdate.add(feed) // Needs to be updatable, so no singletonList
Expand All @@ -181,14 +179,13 @@ object FeedUpdateManager {
feedsToUpdate.clear()
return Result.success()
}
private fun createNotification(toUpdate: List<Feed?>?): Notification {
private fun createNotification(titles: List<String>?): Notification {
val context = applicationContext
var contentText = ""
var bigText: String? = ""
if (toUpdate != null) {
contentText = context.resources.getQuantityString(R.plurals.downloads_left,
toUpdate.size, toUpdate.size)
bigText = Stream.of(toUpdate).map { feed: Feed? -> "" + feed!!.title }.collect(Collectors.joining("\n"))
if (titles != null) {
contentText = context.resources.getQuantityString(R.plurals.downloads_left, titles.size, titles.size)
bigText = titles.map { "$it" }.joinToString("\n")
}
return NotificationCompat.Builder(context, NotificationUtils.CHANNEL_ID.downloading.name)
.setContentTitle(context.getString(R.string.download_notification_title_feeds))
Expand All @@ -199,6 +196,7 @@ object FeedUpdateManager {
.addAction(R.drawable.ic_cancel, context.getString(R.string.cancel_label), WorkManager.getInstance(context).createCancelPendingIntent(id))
.build()
}

override fun getForegroundInfoAsync(): ListenableFuture<ForegroundInfo> {
return Futures.immediateFuture(ForegroundInfo(R.id.notification_updating_feeds, createNotification(null)))
}
Expand All @@ -218,10 +216,11 @@ object FeedUpdateManager {
// Toast.makeText(applicationContext, R.string.notification_permission_text, Toast.LENGTH_LONG).show()
return
}
val titles = feedsToUpdate.map { it.title ?: "No title" }.toMutableList()
var i = 0
while (i < feedsToUpdate.size) {
if (isStopped) return
notificationManager.notify(R.id.notification_updating_feeds, createNotification(feedsToUpdate))
notificationManager.notify(R.id.notification_updating_feeds, createNotification(titles))
val feed = unmanaged(feedsToUpdate[i++])
try {
Logd(TAG, "updating local feed? ${feed.isLocalFeed} ${feed.title}")
Expand All @@ -236,7 +235,7 @@ object FeedUpdateManager {
val status = DownloadResult(feed.id, feed.title?:"", DownloadError.ERROR_IO_ERROR, false, e.message?:"")
LogsAndStats.addDownloadStatus(status)
}
// toUpdate.removeAt(0)
titles.removeAt(0)
}
}
private fun refreshYoutubeFeed(feed: Feed) {
Expand Down Expand Up @@ -283,23 +282,23 @@ object FeedUpdateManager {
LogsAndStats.addDownloadStatus(downloader.result)
return
}
val feedSyncTask = FeedSyncTask(applicationContext, request)
val success = feedSyncTask.run()
val feedUpdateTask = FeedUpdateTask(applicationContext, request)
val success = feedUpdateTask.run()
if (!success) {
Logd(TAG, "update failed: unsuccessful")
Feeds.persistFeedLastUpdateFailed(feed, true)
LogsAndStats.addDownloadStatus(feedSyncTask.downloadStatus)
LogsAndStats.addDownloadStatus(feedUpdateTask.downloadStatus)
return
}
if (request.feedfileId == null) return // No download logs for new subscriptions
// we create a 'successful' download log if the feed's last refresh failed
val log = LogsAndStats.getFeedDownloadLog(request.feedfileId)
if (log.isNotEmpty() && !log[0].isSuccessful) LogsAndStats.addDownloadStatus(feedSyncTask.downloadStatus)
if (log.isNotEmpty() && !log[0].isSuccessful) LogsAndStats.addDownloadStatus(feedUpdateTask.downloadStatus)
if (!request.source.isNullOrEmpty()) {
when {
!downloader.permanentRedirectUrl.isNullOrEmpty() -> Feeds.updateFeedDownloadURL(request.source, downloader.permanentRedirectUrl!!)
feedSyncTask.redirectUrl.isNotEmpty() && feedSyncTask.redirectUrl != request.source ->
Feeds.updateFeedDownloadURL(request.source, feedSyncTask.redirectUrl)
feedUpdateTask.redirectUrl.isNotEmpty() && feedUpdateTask.redirectUrl != request.source ->
Feeds.updateFeedDownloadURL(request.source, feedUpdateTask.redirectUrl)
}
}
}
Expand Down Expand Up @@ -393,7 +392,7 @@ object FeedUpdateManager {
}
}

class FeedSyncTask(private val context: Context, request: DownloadRequest) {
class FeedUpdateTask(private val context: Context, request: DownloadRequest) {
private val task = FeedParserTask(request)
private var feedHandlerResult: FeedHandlerResult? = null
val downloadStatus: DownloadResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ object SynchronizationQueueSink {
// To avoid a dependency loop of every class to SyncService, and from SyncService back to every class.
private var serviceStarterImpl = Runnable {}

fun needSynch() : Boolean {
return isProviderConnected
}

fun setServiceStarterImpl(serviceStarter: Runnable) {
serviceStarterImpl = serviceStarter
}
Expand All @@ -34,7 +30,6 @@ object SynchronizationQueueSink {

fun enqueueFeedAddedIfSyncActive(context: Context, downloadUrl: String) {
if (!isProviderConnected) return

LockingAsyncExecutor.executeLockedAsync {
SynchronizationQueueStorage(context).enqueueFeedAdded(downloadUrl)
syncNow()
Expand All @@ -43,7 +38,6 @@ object SynchronizationQueueSink {

fun enqueueFeedRemovedIfSyncActive(context: Context, downloadUrl: String) {
if (!isProviderConnected) return

LockingAsyncExecutor.executeLockedAsync {
SynchronizationQueueStorage(context).enqueueFeedRemoved(downloadUrl)
syncNow()
Expand All @@ -52,7 +46,6 @@ object SynchronizationQueueSink {

fun enqueueEpisodeActionIfSyncActive(context: Context, action: EpisodeAction) {
if (!isProviderConnected) return

LockingAsyncExecutor.executeLockedAsync {
SynchronizationQueueStorage(context).enqueueEpisodeAction(action)
syncNow()
Expand All @@ -61,7 +54,6 @@ object SynchronizationQueueSink {

fun enqueueEpisodePlayedIfSyncActive(context: Context, media: EpisodeMedia, completed: Boolean) {
if (!isProviderConnected) return

val item_ = media.episodeOrFetch()
if (item_?.feed?.isLocalFeed == true) return
if (media.startPosition < 0 || (!completed && media.startPosition >= media.getPosition())) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package ac.mdiq.podcini.storage.database
import ac.mdiq.podcini.R
import ac.mdiq.podcini.net.download.service.DownloadServiceInterface
import ac.mdiq.podcini.net.feed.LocalFeedUpdater.updateFeed
import ac.mdiq.podcini.net.sync.SynchronizationSettings.isProviderConnected
import ac.mdiq.podcini.net.sync.model.EpisodeAction
import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink
import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink.needSynch
import ac.mdiq.podcini.playback.base.InTheatre.curQueue
import ac.mdiq.podcini.playback.base.InTheatre.curState
import ac.mdiq.podcini.playback.base.InTheatre.writeNoMediaPlaying
Expand Down Expand Up @@ -164,7 +164,7 @@ object Episodes {
// Do full update of this feed to get rid of the episode
if (episode.feed != null) updateFeed(episode.feed!!, context.applicationContext, null)
} else {
if (needSynch()) {
if (isProviderConnected) {
// Gpodder: queue delete action for synchronization
val action = EpisodeAction.Builder(episode, EpisodeAction.DELETE).currentTimestamp().build()
SynchronizationQueueSink.enqueueEpisodeActionIfSyncActive(context, action)
Expand Down
Loading

0 comments on commit daeee36

Please sign in to comment.