Skip to content

Commit

Permalink
6.1.6 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Jul 25, 2024
1 parent 109a8b1 commit 0c9c13d
Show file tree
Hide file tree
Showing 34 changed files with 153 additions and 91 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ While podcast subscriptions' OPML files (from AntennaPod or any other sources) c
* Long-press filter button in FeedEpisodes view enables/disables filters without changing filter settings
* History view shows time of last play, and allows filters and sorts
* Multiple queues can be used: 5 queues are provided by default: Default queue, and Queues 1-4
* all queue operations are on the curQueue, which can be set in all episodes list views
* on app startup, the most recently updated queue is set to curQueue
* all queue operations are on the curQueue, which can be set in all episodes list views
* on app startup, the most recently updated queue is set to curQueue
* Every queue is circular: if the final item in queue finished, the first item in queue (if exists) will get played
* Every queue has a bin of past episodes added to the queue
* Every queue has a bin containing past episodes removed from the queue

### Podcast/Episode

Expand Down Expand Up @@ -127,13 +127,13 @@ While podcast subscriptions' OPML files (from AntennaPod or any other sources) c
* there are now separate dialogs for inclusive and exclusive filters where filter tokens can be specified independently
* on exclusive dialog, there are optional check boxes "Exclude episodes shorter than" and "Mark excluded episodes played"


### Security and reliability

* Disabled `usesCleartextTraffic`, so that all content transmission is more private and secure
* Settings/Preferences can now be exported and imported
* Play history/progress can be separately exported/imported as Json files
* Downloaded media files can be exported/imported
* Reconsile feature (accessed from Downloads view) is added to ensure downloaded media files are in sync with specs in DB
* There is a setting to disable/enable auto backup of OPML files to Google
* Upon re-install of Podcini, the OPML file previously backed up to Google is not imported automatically but based on user confirmation.

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ android {
buildConfig true
}
defaultConfig {
versionCode 3020219
versionName "6.1.5"
versionCode 3020220
versionName "6.1.6"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,

/**
* Searches the podcast directory for a given string.
*
* @param query The search query
* @param scaledLogoSize The size of the logos that are returned by the search query.
* Must be in range 1..256. If the value is out of range, the
Expand Down Expand Up @@ -82,10 +81,7 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
val devices: List<GpodnetDevice>
/**
* Returns all devices of a given user.
*
*
* This method requires authentication.
*
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
get() {
Expand All @@ -110,10 +106,7 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,

/**
* Configures the device of a given user.
*
*
* This method requires authentication.
*
* @param deviceId The ID of the device that should be configured.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
Expand Down Expand Up @@ -147,13 +140,9 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,

/**
* Uploads the subscriptions of a specific device.
*
*
* This method requires authentication.
*
* @param deviceId The ID of the device whose subscriptions should be updated.
* @param subscriptions A list of feed URLs containing all subscriptions of the
* device.
* @param subscriptions A list of feed URLs containing all subscriptions of the device.
* @throws IllegalArgumentException If username, deviceId or subscriptions is null.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
Expand Down Expand Up @@ -181,16 +170,11 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,

/**
* Updates the subscription list of a specific device.
*
*
* This method requires authentication.
*
* @param added Collection of feed URLs of added feeds. This Collection MUST NOT contain any duplicates
* @param removed Collection of feed URLs of removed feeds. This Collection MUST NOT contain any duplicates
* @return a GpodnetUploadChangesResponse. See [GpodnetUploadChangesResponse]
* for details.
* @throws GpodnetServiceException if added or removed contain duplicates or if there
* is an authentication error.
* @return a GpodnetUploadChangesResponse. See [GpodnetUploadChangesResponse] for details.
* @throws GpodnetServiceException if added or removed contain duplicates or if there is an authentication error.
*/
@Throws(GpodnetServiceException::class)
override fun uploadSubscriptionChanges(added: List<String>, removed: List<String>): UploadChangesResponse {
Expand Down Expand Up @@ -220,13 +204,8 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
}

/**
* Returns all subscription changes of a specific device.
*
*
* This method requires authentication.
*
* @param timestamp A timestamp that can be used to receive all changes since a
* specific point in time.
* Returns all subscription changes of a specific device. This method requires authentication.
* @param timestamp A timestamp that can be used to receive all changes since a specific point in time.
* @throws GpodnetServiceAuthenticationException If there is an authentication error.
*/
@Throws(GpodnetServiceException::class)
Expand Down Expand Up @@ -254,16 +233,10 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
}

/**
* Updates the episode actions
*
*
* This method requires authentication.
*
* Updates the episode actions. This method requires authentication.
* @param episodeActions Collection of episode actions.
* @return a GpodnetUploadChangesResponse. See [GpodnetUploadChangesResponse]
* for details.
* @throws GpodnetServiceException if added or removed contain duplicates or if there
* is an authentication error.
* @return a GpodnetUploadChangesResponse. See [GpodnetUploadChangesResponse] for details.
* @throws GpodnetServiceException if added or removed contain duplicates or if there is an authentication error.
*/
@Throws(SyncServiceException::class)
override fun uploadEpisodeActions(episodeActions: List<EpisodeAction>): UploadChangesResponse? {
Expand All @@ -287,7 +260,7 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
val list = JSONArray()
for (i in from until to) {
val episodeAction = episodeActions[i]
val obj = episodeAction!!.writeToJsonObject()
val obj = episodeAction!!.writeToJsonObjectForServer()
if (obj != null) {
obj.put("device", deviceId)
list.put(obj)
Expand All @@ -312,13 +285,8 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
}

/**
* Returns all subscription changes of a specific device.
*
*
* This method requires authentication.
*
* @param timestamp A timestamp that can be used to receive all changes since a
* specific point in time.
* Returns all subscription changes of a specific device. This method requires authentication.
* @param timestamp A timestamp that can be used to receive all changes since a specific point in time.
* @throws SyncServiceException If there is an authentication error.
*/
@Throws(SyncServiceException::class)
Expand Down Expand Up @@ -346,9 +314,7 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,
}

/**
* Logs in a specific user. This method must be called if any of the methods
* that require authentication is used.
*
* Logs in a specific user. This method must be called if any of the methods that require authentication is used.
* @throws IllegalArgumentException If username or password is null.
*/
@Throws(GpodnetServiceException::class)
Expand Down Expand Up @@ -508,9 +474,7 @@ class GpodnetService(private val httpClient: OkHttpClient, baseHosturl: String?,

open class GpodnetServiceException : SyncServiceException {
constructor(message: String?) : super(message)

constructor(e: Throwable?) : super(e)

companion object {
private const val serialVersionUID = 1L
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class EpisodeAction private constructor(builder: Builder) {

/**
* Returns the position (in seconds) at which the client started playback.
*
* @return start position (in seconds)
*/
val started: Int

/**
* Returns the position (in seconds) at which the client stopped playback.
*
* @return stop position (in seconds)
*/
val position: Int
Expand All @@ -33,7 +31,6 @@ class EpisodeAction private constructor(builder: Builder) {

/**
* Returns the total length of the file in seconds.
*
* @return total length in seconds
*/
val total: Int
Expand Down Expand Up @@ -82,7 +79,6 @@ class EpisodeAction private constructor(builder: Builder) {

/**
* Returns a JSON object representation of this object.
*
* @return JSON object representation, or null if the object is invalid
*/
fun writeToJsonObject(): JSONObject? {
Expand Down Expand Up @@ -110,6 +106,32 @@ class EpisodeAction private constructor(builder: Builder) {
return obj
}

/**
* Returns a JSON object representation of this object.
* @return JSON object representation, or null if the object is invalid
*/
fun writeToJsonObjectForServer(): JSONObject? {
val obj = JSONObject()
try {
obj.putOpt("podcast", this.podcast)
obj.putOpt("episode", this.episode)
obj.putOpt("guid", this.guid)
obj.put("action", this.actionString)
val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
formatter.timeZone = TimeZone.getTimeZone("UTC")
if (this.timestamp != null) obj.put("timestamp", formatter.format(this.timestamp))
if (this.action == Action.PLAY) {
obj.put("started", this.started)
obj.put("position", this.position)
obj.put("total", this.total)
}
} catch (e: JSONException) {
Log.e(TAG, "writeToJSONObject(): " + e.message)
return null
}
return obj
}

override fun toString(): String {
return ("EpisodeAction{podcast='$podcast', episode='$episode', guid='$guid', action=$action, timestamp=$timestamp, started=$started, position=$position, total=$total playState=$playState isFavorite=$isFavorite}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class NextcloudSyncService(private val httpClient: OkHttpClient, baseHosturl: St
val list = JSONArray()
for (i in from until to) {
val episodeAction = queuedEpisodeActions!![i]
val obj = episodeAction!!.writeToJsonObject()
val obj = episodeAction!!.writeToJsonObjectForServer()
if (obj != null) list.put(obj)
}
val url: HttpUrl.Builder = makeUrl("/index.php/apps/gpoddersync/episode_action/create")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SynchronizationQueueStorage(context: Context) {
val json = sharedPreferences.getString(QUEUED_EPISODE_ACTIONS, "[]")
try {
val queue = JSONArray(json)
queue.put(action.writeToJsonObject())
queue.put(action.writeToJsonObjectForServer())
sharedPreferences.edit().putString(QUEUED_EPISODE_ACTIONS, queue.toString()).apply()
} catch (jsonException: JSONException) {
jsonException.printStackTrace()
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/database/Queues.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ object Queues {
return runOnIOScope {
curQueue.update()
curQueue.episodes.clear()
curQueue.idsBin.addAll(curQueue.episodeIds)
curQueue.idsBinList.addAll(curQueue.episodeIds)
curQueue.episodeIds.clear()
upsert(curQueue) {}
EventFlow.postEvent(FlowEvent.QueueEvent.cleared())
Expand Down Expand Up @@ -242,7 +242,9 @@ object Queues {
}
if (indicesToRemove.isNotEmpty()) {
for (i in indicesToRemove.indices.reversed()) {
queue.idsBin.add(qItems[indicesToRemove[i]].id)
val id = qItems[indicesToRemove[i]].id
queue.idsBinList.remove(id)
queue.idsBinList.add(id)
qItems.removeAt(indicesToRemove[i])
}
queue.update()
Expand All @@ -265,7 +267,8 @@ object Queues {
if (q.id == curQueue.id) continue
idsInQueuesToRemove = q.episodeIds.intersect(episodeIds.toSet()).toMutableSet()
if (idsInQueuesToRemove.isNotEmpty()) {
q.idsBin.addAll(idsInQueuesToRemove)
q.idsBinList.removeAll(idsInQueuesToRemove)
q.idsBinList.addAll(idsInQueuesToRemove)
val qeids = q.episodeIds.minus(idsInQueuesToRemove)
upsert(q) {
it.episodeIds.clear()
Expand All @@ -278,7 +281,8 @@ object Queues {
val q = curQueue
idsInQueuesToRemove = q.episodeIds.intersect(episodeIds.toSet()).toMutableSet()
if (idsInQueuesToRemove.isNotEmpty()) {
q.idsBin.addAll(idsInQueuesToRemove)
q.idsBinList.removeAll(idsInQueuesToRemove)
q.idsBinList.addAll(idsInQueuesToRemove)
val qeids = q.episodeIds.minus(idsInQueuesToRemove)
upsert(q) {
it.episodeIds.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlin.coroutines.ContinuationInterceptor
object RealmDB {
private val TAG: String = RealmDB::class.simpleName ?: "Anonymous"

private const val SCHEMA_VERSION_NUMBER = 13L
private const val SCHEMA_VERSION_NUMBER = 14L

private val ioScope = CoroutineScope(Dispatchers.IO)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class PlayQueue : RealmObject {
@Ignore
val episodes: MutableList<Episode> = mutableListOf()

var idsBin: RealmSet<Long> = realmSetOf()

// @Ignore
// val episodesBin: MutableList<Episode> = mutableListOf()
var idsBinList: RealmList<Long> = realmListOf()

fun isInQueue(episode: Episode): Boolean {
return episodeIds.contains(episode.id)
Expand Down
Loading

0 comments on commit 0c9c13d

Please sign in to comment.