Skip to content

Commit

Permalink
6.6.2 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Sep 14, 2024
1 parent 8220797 commit 86f0cb9
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 105 deletions.
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 3020246
versionName "6.6.1"
versionCode 3020247
versionName "6.6.2"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ object UserPreferences {
prefQueueKeepSorted,
prefQueueKeepSortedOrder,
prefDownloadSortedOrder,
prefDownloadsFilter,

// Episodes
prefEpisodesSort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ object Feeds {
feed.fileUrl = File(feedfilePath, getFeedfileName(feed)).toString()
feed.preferences = FeedPreferences(feed.id, false, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, "", "")
feed.preferences!!.keepUpdated = false
feed.preferences!!.queue = null
feed.preferences!!.queueId = -2L
feed.preferences!!.videoModePolicy = if (video) VideoMode.WINDOW_VIEW else VideoMode.AUDIO_ONLY
upsertBlk(feed) {}
return feed
Expand Down
36 changes: 19 additions & 17 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/database/Queues.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,28 @@ object Queues {
appPrefs.edit().putBoolean(UserPreferences.Prefs.prefQueueLocked.name, locked).apply()
}

/**
* Returns if the queue is in keep sorted mode.
* Enables/disables the keep sorted mode of the queue.
* @see .queueKeepSortedOrder
*/
var isQueueKeepSorted: Boolean
/**
* Returns if the queue is in keep sorted mode.
* @see .queueKeepSortedOrder
*/
get() = appPrefs.getBoolean(UserPreferences.Prefs.prefQueueKeepSorted.name, false)
/**
* Enables/disables the keep sorted mode of the queue.
* @see .queueKeepSortedOrder
*/
set(keepSorted) {
appPrefs.edit().putBoolean(UserPreferences.Prefs.prefQueueKeepSorted.name, keepSorted).apply()
}

/**
* Returns the sort order for the queue keep sorted mode.
* Note: This value is stored independently from the keep sorted state.
* Sets the sort order for the queue keep sorted mode.
* @see .isQueueKeepSorted
*/
var queueKeepSortedOrder: EpisodeSortOrder?
/**
* Returns the sort order for the queue keep sorted mode.
* Note: This value is stored independently from the keep sorted state.
* @see .isQueueKeepSorted
*/
get() {
val sortOrderStr = appPrefs.getString(UserPreferences.Prefs.prefQueueKeepSortedOrder.name, "use-default")
return EpisodeSortOrder.parseWithDefault(sortOrderStr, EpisodeSortOrder.DATE_NEW_OLD)
}
/**
* Sets the sort order for the queue keep sorted mode.
* @see .setQueueKeepSorted
*/
set(sortOrder) {
if (sortOrder == null) return
appPrefs.edit().putString(UserPreferences.Prefs.prefQueueKeepSortedOrder.name, sortOrder.name).apply()
Expand Down Expand Up @@ -344,6 +338,14 @@ object Queues {
}
}

fun inAnyQueue(episode: Episode): Boolean {
val queues = realm.query(PlayQueue::class).find()
for (q in queues) {
if (q.contains(episode)) return true
}
return false
}

class EnqueuePositionPolicy(private val enqueueLocation: EnqueueLocation) {
/**
* Determine the position (0-based) that the item(s) should be inserted to the named queue.
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/model/EpisodeFilter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ac.mdiq.podcini.storage.model

import ac.mdiq.podcini.playback.base.InTheatre.curQueue
import ac.mdiq.podcini.storage.database.Queues.inAnyQueue
import java.io.Serializable

class EpisodeFilter(vararg properties: String) : Serializable {
Expand Down Expand Up @@ -49,8 +50,17 @@ class EpisodeFilter(vararg properties: String) : Serializable {
showNoMedia && item.media != null -> return false
showIsFavorite && !item.isFavorite -> return false
showNotFavorite && item.isFavorite -> return false
showQueued && curQueue.isInQueue(item) -> return false
showNotQueued && !curQueue.isInQueue(item) -> return false
showQueued && !inAnyQueue(item) -> return false
showNotQueued && inAnyQueue(item) -> return false
else -> return true
}
}

// filter on queues does not have a query string so it's not applied on query results, need to filter separately
fun matchesForQueues(item: Episode): Boolean {
when {
showQueued && !inAnyQueue(item) -> return false
showNotQueued && inAnyQueue(item) -> return false
else -> return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FeedFilter(vararg properties: String) : Serializable {
}
when {
showAlwaysAutoDelete -> statements.add(" preferences.autoDelete == ${FeedPreferences.AutoDeleteAction.ALWAYS.code} ")
showNeverAutoDelete -> statements.add(" preferences.playSpeed != ${FeedPreferences.AutoDeleteAction.NEVER.code} ")
showNeverAutoDelete -> statements.add(" preferences.playSpeed == ${FeedPreferences.AutoDeleteAction.NEVER.code} ")
}
when {
showAutoDownload -> statements.add(" preferences.autoDownload == true ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PlayQueue : RealmObject {

var idsBinList: RealmList<Long> = realmListOf()

fun isInQueue(episode: Episode): Boolean {
fun contains(episode: Episode): Boolean {
return episodeIds.contains(episode.id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object EpisodeMenuHandler {

val hasMedia = selectedItem.media != null
val isPlaying = hasMedia && InTheatre.isCurMedia(selectedItem.media)
val isInQueue: Boolean = curQueue.isInQueue(selectedItem)
val isInQueue: Boolean = curQueue.contains(selectedItem)
val isLocalFile = hasMedia && selectedItem.feed?.isLocalFeed?:false
val isFavorite: Boolean = selectedItem.isFavorite

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ class EpisodeMultiSelectHandler(private val activity: MainActivity, private val
val toRemove = mutableSetOf<Long>()
val toRemoveCur = mutableListOf<Episode>()
items.forEach { e ->
if (curQueue.isInQueue(e)) toRemoveCur.add(e)
if (curQueue.contains(e)) toRemoveCur.add(e)
}
items.forEach { e ->
for (q in queues) {
if (q.isInQueue(e)) {
if (q.contains(e)) {
toRemove.add(e.id)
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract class EpisodeFilterDialog : BottomSheetDialogFragment() {

var filter: EpisodeFilter? = null
private val buttonMap: MutableMap<String, Button> = mutableMapOf()
val filtersDisabled: MutableSet<FeedItemFilterGroup> = mutableSetOf()

private val newFilterValues: Set<String>
get() {
Expand All @@ -50,10 +51,9 @@ abstract class EpisodeFilterDialog : BottomSheetDialogFragment() {
//add filter rows
for (item in FeedItemFilterGroup.entries) {
// Logd("EpisodeFilterDialog", "FeedItemFilterGroup: ${item.values[0].filterId} ${item.values[1].filterId}")
if (item in filtersDisabled) continue

val rBinding = FilterDialogRowBinding.inflate(inflater)
// rowBinding.root.addOnButtonCheckedListener { _: MaterialButtonToggleGroup?, _: Int, _: Boolean ->
// onFilterChanged(newFilterValues)
// }
rBinding.filterButton1.setOnClickListener { onFilterChanged(newFilterValues) }
rBinding.filterButton2.setOnClickListener { onFilterChanged(newFilterValues) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import kotlin.math.min
toolbar.inflateMenu(R.menu.episodes)
toolbar.setTitle(R.string.episodes_label)
updateToolbar()
txtvInformation.visibility = View.VISIBLE
txtvInformation.setOnClickListener {
AllEpisodesFilterDialog.newInstance(getFilter()).show(childFragmentManager, null)
}
Expand All @@ -66,13 +67,15 @@ import kotlin.math.min

private var loadItemsRunning = false
override fun loadData(): List<Episode> {
val filter = getFilter()
if (!loadItemsRunning) {
loadItemsRunning = true
allEpisodes = getEpisodes(0, Int.MAX_VALUE, getFilter(), allEpisodesSortOrder, false)
allEpisodes = getEpisodes(0, Int.MAX_VALUE, filter, allEpisodesSortOrder, false)
Logd(TAG, "loadData ${allEpisodes.size}")
loadItemsRunning = false
}
if (allEpisodes.isEmpty()) return listOf()
allEpisodes = allEpisodes.filter { filter.matchesForQueues(it) }
return allEpisodes.subList(0, min(allEpisodes.size-1, page * EPISODES_PER_PAGE))
}

Expand Down Expand Up @@ -144,11 +147,9 @@ import kotlin.math.min
override fun updateToolbar() {
swipeActions.setFilter(getFilter())
if (getFilter().values.isNotEmpty()) {
txtvInformation.visibility = View.VISIBLE
txtvInformation.text = "${adapter.totalNumberOfItems} episodes - filtered"
txtvInformation.text = "${adapter.totalNumberOfItems} episodes - ${getString(R.string.filtered_label)}"
emptyView.setMessage(R.string.no_all_episodes_filtered_label)
} else {
txtvInformation.visibility = View.VISIBLE
txtvInformation.text = "${adapter.totalNumberOfItems} episodes"
emptyView.setMessage(R.string.no_all_episodes_label)
}
Expand Down
Loading

0 comments on commit 86f0cb9

Please sign in to comment.