Skip to content

Commit

Permalink
6.3.6 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Aug 9, 2024
1 parent 889195c commit 3da5148
Show file tree
Hide file tree
Showing 31 changed files with 214 additions and 127 deletions.
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ body:
attributes:
label: Checklist
options:
- label: I have used the search function for [**OPEN**](https://github.com/XilinJia/PodVinci/issues) issues to see if someone else has already submitted the same bug report.
- label: I have used the search function for [**OPEN**](https://github.com/XilinJia/Podcini/issues) issues to see if someone else has already submitted the same bug report.
required: true
- label: I have **also** used the search function for [**CLOSED**](https://github.com/XilinJia/PodVinci/issues?q=is%3Aissue+is%3Aclosed) issues to see if the problem is already solved and just waiting to be released.
- label: I have **also** used the search function for [**CLOSED**](https://github.com/XilinJia/podcini/issues?q=is%3Aissue+is%3Aclosed) issues to see if the problem is already solved and just waiting to be released.
required: true
- label: I will describe the problem with as much detail as possible.
required: true
Expand Down Expand Up @@ -67,14 +67,14 @@ body:
id: expected
attributes:
label: Expected behaviour
description: After following the steps, what did you think PodVinci would do?
description: After following the steps, what did you think Podcini would do?
- type: textarea
id: current
attributes:
label: Current behaviour
description: What did PodVinci do instead? Screenshots might help. Usually, you can take a screenshot of your smartphone by pressing *Power* + *Volume down* for a few seconds.
description: What did Podcini do instead? Screenshots might help. Usually, you can take a screenshot of your smartphone by pressing *Power* + *Volume down* for a few seconds.
- type: textarea
id: logs
attributes:
label: Logs
description: If you are experiencing a crash, including the stacktrace will likely get it fixed sooner. PodVinci has an `export logs` feature for this.
description: If you are experiencing a crash, including the stacktrace will likely get it fixed sooner. Podcini has an `export logs` feature for this.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Help & Support
url: https://forum.podvinci.org/
url: https://github.com/XilinJia/Podcini
about: Reduce developer's support workload by asking other users on our forum.
- name: F-Droid Release
url: https://podvinci.org/documentation/general/f-droid
url: https://f-droid.org/packages/ac.mdiq.podcini.R/
about: Waiting for an update to appear on F-Droid? No need to create an issue, please just be patient!
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ body:
attributes:
label: Checklist
options:
- label: I have used the search function for [**OPEN**](https://github.com/XilinJia/PodVinci/issues) issues to see if someone else has already submitted the same feature request.
- label: I have used the search function for [**OPEN**](https://github.com/XilinJia/podcini/issues) issues to see if someone else has already submitted the same feature request.
required: true
- label: I have **also** used the search function for [**CLOSED**](https://github.com/XilinJia/PodVinci/issues?q=is%3Aissue+is%3Aclosed) issues to see if the feature was already implemented and is just waiting to be released, or if the feature was rejected.
- label: I have **also** used the search function for [**CLOSED**](https://github.com/XilinJia/Podcini/issues?q=is%3Aissue+is%3Aclosed) issues to see if the feature was already implemented and is just waiting to be released, or if the feature was rejected.
required: true
- label: I will describe the problem with as much detail as possible.
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- Please make sure that you have read our contribution guidelines: https://github.com/XilinJia/PodVinci/blob/develop/CONTRIBUTING.md#submit-a-pull-request -->
<!-- Please make sure that you have read our contribution guidelines: https://github.com/XilinJia/Podcini/blob/main/CONTRIBUTING.md#submit-a-pull-request -->
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Create temporary release keystore
run: keytool -noprompt -genkey -v -keystore "app/keystore" -alias alias -storepass password -keypass password -keyalg RSA -validity 10 -dname "CN=podvinci.org, OU=dummy, O=dummy, L=dummy, S=dummy, C=US"
run: keytool -noprompt -genkey -v -keystore "app/keystore" -alias alias -storepass password -keypass password -keyalg RSA -validity 10 -dname "CN=podcini.org, OU=dummy, O=dummy, L=dummy, S=dummy, C=US"
- name: Build
run: ./gradlew assemble${{ matrix.variant }}
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/runEmulatorTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o pipefail

runTests() {
./gradlew connectedPlayDebugAndroidTest connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.notAnnotation=de.test.podvinci.IgnoreOnCi
-Pandroid.testInstrumentationRunnerArguments.notAnnotation=de.test.podcini.IgnoreOnCi
}

# Retry tests to make them less flaky
Expand Down
8 changes: 4 additions & 4 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 3020229
versionName "6.3.5"
versionCode 3020230
versionName "6.3.6"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down Expand Up @@ -189,7 +189,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'

implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.4"
implementation "androidx.annotation:annotation:1.8.1"
implementation "androidx.annotation:annotation:1.8.2"
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation "androidx.fragment:fragment-ktx:1.8.2"
Expand All @@ -204,7 +204,7 @@ dependencies {
implementation "androidx.preference:preference-ktx:1.2.1"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.viewpager2:viewpager2:1.1.0"
implementation "androidx.work:work-runtime:2.9.0"
implementation "androidx.work:work-runtime:2.9.1"
implementation "androidx.core:core-splashscreen:1.0.1"
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.webkit:webkit:1.11.0'
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/database/Queues.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ object Queues {
val markAsUnplayeds = mutableListOf<Episode>()
val events: MutableList<FlowEvent.QueueEvent> = ArrayList()
val updatedItems: MutableList<Episode> = ArrayList()
val positionCalculator = EnqueuePositionCalculator(enqueueLocation)
val positionCalculator = EnqueuePositionPolicy(enqueueLocation)
val currentlyPlaying = curMedia
var insertPosition = positionCalculator.calcPosition(curQueue.episodes, currentlyPlaying)

Expand Down Expand Up @@ -151,8 +151,9 @@ object Queues {

val queue = queue_ ?: curQueue
val currentlyPlaying = curMedia
val positionCalculator = EnqueuePositionCalculator(enqueueLocation)
val positionCalculator = EnqueuePositionPolicy(enqueueLocation)
var insertPosition = positionCalculator.calcPosition(queue.episodes, currentlyPlaying)
Logd(TAG, "addToQueueSync insertPosition: $insertPosition")

if (queue.episodeIds.contains(episode.id)) return

Expand Down Expand Up @@ -345,20 +346,21 @@ object Queues {
}
}

class EnqueuePositionCalculator(private val enqueueLocation: EnqueueLocation) {
class EnqueuePositionPolicy(private val enqueueLocation: EnqueueLocation) {
/**
* Determine the position (0-based) that the item(s) should be inserted to the named queue.
* @param queueItems the queue to which the item is to be inserted
* @param currentPlaying the currently playing media
*/
fun calcPosition(queueItems: List<Episode>, currentPlaying: Playable?): Int {
if (queueItems.isEmpty()) return 0
when (enqueueLocation) {
EnqueueLocation.BACK -> return queueItems.size
EnqueueLocation.FRONT -> // Return not necessarily 0, so that when a list of items are downloaded and enqueued
// in succession of calls (e.g., users manually tapping download one by one),
// the items enqueued are kept the same order.
// Simply returning 0 will reverse the order.
return getPositionOfFirstNonDownloadingItem(0, queueItems)
// Return not necessarily 0, so that when a list of items are downloaded and enqueued
// in succession of calls (e.g., users manually tapping download one by one),
// the items enqueued are kept the same order.
// Simply returning 0 will reverse the order.
EnqueueLocation.FRONT -> return getPositionOfFirstNonDownloadingItem(0, queueItems)
EnqueueLocation.AFTER_CURRENTLY_PLAYING -> {
val currentlyPlayingPosition = getCurrentlyPlayingPosition(queueItems, currentPlaying)
return getPositionOfFirstNonDownloadingItem(currentlyPlayingPosition + 1, queueItems)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ class DatasetStats(val queueSize: Int,
val numDownloaded: Int,
val numReclaimables: Int,
val numEpisodes: Int,
val numFeeds: Int)
val numFeeds: Int,
val historyCount: Int)
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ import androidx.annotation.PluralsRes
import androidx.media3.common.util.UnstableApi
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import java.lang.ref.WeakReference
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.coroutineContext


@UnstableApi
Expand Down Expand Up @@ -139,7 +143,7 @@ class EpisodeMultiSelectHandler(private val activity: MainActivity, private val
val selectedIndex = radioButton.tag as Int
toQueue = queues[selectedIndex]
}
MaterialAlertDialogBuilder(activity)
val dialog = MaterialAlertDialogBuilder(activity)
.setView(binding.root)
.setTitle(R.string.put_in_queue_label)
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
Expand All @@ -166,7 +170,7 @@ class EpisodeMultiSelectHandler(private val activity: MainActivity, private val
}
}
.setNegativeButton(R.string.cancel_label, null)
.show()
dialog.show()
}
}

Expand Down
10 changes: 0 additions & 10 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,6 @@ class MainActivity : CastEnabledActivity() {
lastTheme = getNoTitleTheme(this) // Don't recreate activity when a result is pending
}

// override fun onTrimMemory(level: Int) {
// super.onTrimMemory(level)
//// Glide.get(this).trimMemory(level)
// }
//
// override fun onLowMemory() {
// super.onLowMemory()
//// Glide.get(this).clearMemory()
// }

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Logd(TAG, "onOptionsItemSelected ${item.title}")
when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ open class EpisodesAdapter(mainActivity: MainActivity, var refreshFragPosCallbac
private var longPressedPosition: Int = 0 // used to init actionMode
private var dummyViews = 0

val selectedItems: List<Any>
val selectedItems: List<Episode>
get() {
val items: MutableList<Episode> = ArrayList()
for (i in 0 until itemCount) {
Expand Down Expand Up @@ -91,12 +91,13 @@ open class EpisodesAdapter(mainActivity: MainActivity, var refreshFragPosCallbac

@UnstableApi
override fun onBindViewHolder(holder: EpisodeViewHolder, pos: Int) {
// Logd(TAG, "onBindViewHolder $pos ${holder.episode?.title}")
// Logd(TAG, "onBindViewHolder $pos ${episodes[pos].title}")
if (pos >= episodes.size || pos < 0) {
beforeBindViewHolder(holder, pos)
holder.bindDummy()
afterBindViewHolder(holder, pos)
holder.hideSeparatorIfNecessary()
// beforeBindViewHolder(holder, pos)
// holder.bindDummy()
// afterBindViewHolder(holder, pos)
// holder.hideSeparatorIfNecessary()
Logd(TAG, "onBindViewHolder got invalid pos: $pos of ${episodes.size}")
return
}

Expand Down
31 changes: 19 additions & 12 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/adapter/SelectableAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ac.mdiq.podcini.ui.adapter

import ac.mdiq.podcini.R
import ac.mdiq.podcini.util.Logd
import android.app.Activity
import android.view.ActionMode
import android.view.Menu
Expand All @@ -22,6 +23,7 @@ abstract class SelectableAdapter<T : RecyclerView.ViewHolder?>(private val activ
get() = selectedIds.size

fun startSelectMode(pos: Int) {
Logd("SelectableAdapter", "startSelectMode: $pos ${actionMode == null}")
if (inActionMode()) endSelectMode()

onSelectModeListener?.onStartSelectMode()
Expand Down Expand Up @@ -96,10 +98,12 @@ abstract class SelectableAdapter<T : RecyclerView.ViewHolder?>(private val activ
* @param pos the position to select
* @param selected true for selected state and false for unselected
*/
open fun setSelected(pos: Int, selected: Boolean) {
if (selected) selectedIds.add(getItemId(pos))
else selectedIds.remove(getItemId(pos))
updateTitle()
open fun setSelected(pos: Int, selected: Boolean, updateTitle: Boolean = true) {
val itemId = getItemId(pos)
// Logd("SelectableAdapter", "setSelected: $pos $itemId ${getItemViewType(pos)} selectedIds: ${selectedIds.size}")
if (selected) selectedIds.add(itemId)
else selectedIds.remove(itemId)
if (updateTitle) updateTitle()
}

/**
Expand All @@ -111,27 +115,30 @@ abstract class SelectableAdapter<T : RecyclerView.ViewHolder?>(private val activ
*/
@Throws(IllegalArgumentException::class)
fun setSelected(startPos: Int, endPos: Int, selected: Boolean) {
// Logd("SelectableAdapter", "setSelected: $startPos, $endPos $selected")
var i = startPos
while (i < endPos && i < itemCount) {
setSelected(i, selected)
setSelected(i, selected, false)
i++
}
updateTitle()
notifyItemRangeChanged(startPos, (endPos - startPos))
}

fun toggleSelected(startPos: Int, endPos: Int) {
var i = startPos
// Logd("SelectableAdapter", "toggleSelected: $startPos, $endPos")
while (i < endPos && i < itemCount) {
toggleSelection(i)
toggleSelection(i, false)
i++
}
updateTitle()
notifyItemRangeChanged(startPos, (endPos - startPos))
}

protected fun toggleSelection(pos: Int) {
setSelected(pos, !isSelected(pos))
protected fun toggleSelection(pos: Int, updateTitle: Boolean = true) {
setSelected(pos, !isSelected(pos), updateTitle)
notifyItemChanged(pos)

if (selectedIds.size == 0) endSelectMode()
}

Expand All @@ -152,11 +159,12 @@ abstract class SelectableAdapter<T : RecyclerView.ViewHolder?>(private val activ
fun updateTitle() {
if (actionMode == null) return
var totalCount = itemCount
var selectedCount = selectedIds.size
// var selectedCount = selectedIds.size
if (totalNumberOfItems != COUNT_AUTOMATICALLY) {
totalCount = totalNumberOfItems
if (shouldSelectLazyLoadedItems) selectedCount += (totalNumberOfItems - itemCount)
// if (shouldSelectLazyLoadedItems) selectedCount += (totalNumberOfItems - itemCount)
}
// Logd("SelectableAdapter", "updateTitle: $selectedCount $totalCount")
actionMode!!.title = activity.resources.getQuantityString(R.plurals.num_selected_label, selectedIds.size, selectedCount, totalCount)
}

Expand All @@ -182,7 +190,6 @@ abstract class SelectableAdapter<T : RecyclerView.ViewHolder?>(private val activ

interface OnSelectModeListener {
fun onStartSelectMode()

fun onEndSelectMode()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ abstract class ConfirmationDialog(private val context: Context, private val titl
val builder = MaterialAlertDialogBuilder(context)
builder.setTitle(titleId)
builder.setMessage(message)
builder.setPositiveButton(if (positiveText != 0) positiveText else R.string.confirm_label) {
dialog: DialogInterface, _: Int -> onConfirmButtonPressed(dialog) }
builder.setNegativeButton(R.string.cancel_label) { dialog: DialogInterface, _: Int ->
onCancelButtonPressed(dialog)
}
builder.setPositiveButton(if (positiveText != 0) positiveText else R.string.confirm_label) { dialog: DialogInterface, _: Int -> onConfirmButtonPressed(dialog) }
builder.setNegativeButton(R.string.cancel_label) { dialog: DialogInterface, _: Int -> onCancelButtonPressed(dialog) }
builder.setOnCancelListener { dialog: DialogInterface -> this@ConfirmationDialog.onCancelButtonPressed(dialog) }
return builder.create()
}
Expand Down
Loading

0 comments on commit 3da5148

Please sign in to comment.