Skip to content

Commit

Permalink
6.14.7 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Nov 25, 2024
1 parent 309d7c9 commit 5f09864
Show file tree
Hide file tree
Showing 68 changed files with 845 additions and 1,203 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
vectorDrawables.useSupportLibrary false
vectorDrawables.generatedDensities = []

versionCode 3020305
versionName "6.14.6"
versionCode 3020306
versionName "6.14.7"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
94 changes: 3 additions & 91 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,6 @@
android:windowSoftInputMode="stateAlwaysHidden"
android:launchMode="singleTask"
android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->

<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->

<!-- <data-->
<!-- android:host="podcini.org"-->
<!-- android:pathPrefix="/deeplink/main"-->
<!-- android:scheme="https" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->

<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->

<!-- <data-->
<!-- android:host="podcini.org"-->
<!-- android:pathPrefix="/deeplink/search"-->
<!-- android:scheme="https" />-->
<!-- </intent-filter>-->
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="ac.mdiq.podcini.intents.MAIN_ACTIVITY" />
Expand Down Expand Up @@ -233,9 +211,9 @@
<data android:scheme="http"/>
<data android:scheme="https"/>

<data android:host="*"/>
<data android:pathPattern=".*.xml" />
<data android:pathPattern=".*.opml" />
<!-- <data android:host="*"/>-->
<data android:pathPattern="/.*\\.xml" />
<data android:pathPattern="/.*\\.opml" />
</intent-filter>
</activity>
<activity
Expand Down Expand Up @@ -272,34 +250,6 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="ac.mdiq.podcini.ui.activity.MainActivity"/>

<!-- URLs ending with '.xml' or '.rss' -->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW"/>-->
<!-- <category android:name="android.intent.category.DEFAULT"/>-->
<!-- <category android:name="android.intent.category.BROWSABLE"/>-->

<!-- <data android:scheme="http"/>-->
<!-- <data android:scheme="https"/>-->
<!-- <data android:host="*"/>-->
<!-- <data android:pathPattern=".*\\.xml"/>-->
<!-- <data android:pathPattern=".*\\.rss"/>-->
<!-- <data android:pathPattern=".*\\.atom"/>-->
<!-- </intent-filter>-->

<!-- Feedburner URLs -->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW"/>-->
<!-- <category android:name="android.intent.category.DEFAULT"/>-->
<!-- <category android:name="android.intent.category.BROWSABLE"/>-->

<!-- <data android:scheme="http"/>-->
<!-- <data android:scheme="https"/>-->
<!-- <data android:host="feeds.feedburner.com"/>-->
<!-- <data android:host="feedproxy.google.com"/>-->
<!-- <data android:host="feeds2.feedburner.com"/>-->
<!-- <data android:host="feedsproxy.google.com"/>-->
<!-- </intent-filter>-->

<!-- Files with mimeType rss/xml/atom -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
Expand All @@ -326,44 +276,6 @@
<data android:scheme="podcini-subscribe"/>
</intent-filter>

<!-- Support for subscribeonandroid.com URLS -->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->
<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->

<!-- <data android:pathPattern=".*\\..*/.*" />-->
<!-- <data android:host="subscribeonandroid.com" />-->
<!-- <data android:host="www.subscribeonandroid.com" />-->
<!-- <data android:host="*subscribeonandroid.com" />-->
<!-- <data android:scheme="http" />-->
<!-- <data android:scheme="https" />-->
<!-- </intent-filter>-->

<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->

<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->

<!-- <data android:host="podcini.org" />-->
<!-- <data android:host="www.podcini.org" />-->
<!-- <data android:pathPrefix="/deeplink/subscribe" />-->
<!-- <data android:scheme="http" />-->
<!-- <data android:scheme="https" />-->
<!-- </intent-filter>-->

<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->
<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->

<!-- <data android:pathPattern="/.*/podcast/.*" />-->
<!-- <data android:host="podcasts.apple.com" />-->
<!-- <data android:scheme="http" />-->
<!-- <data android:scheme="https" />-->
<!-- </intent-filter>-->

<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.model.EpisodeSortOrder
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.database.Episodes.hasAlmostEnded
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ac.mdiq.podcini.storage.model.Episode
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.storage.model.EpisodeSortOrder
import ac.mdiq.podcini.storage.model.Rating
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.storage.database.Episodes.hasAlmostEnded
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.Logd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import ac.mdiq.podcini.playback.base.InTheatre.curMedia
import ac.mdiq.podcini.playback.base.InTheatre.curQueue
import ac.mdiq.podcini.preferences.UserPreferences.isSkipSilence
import ac.mdiq.podcini.preferences.UserPreferences.rewindSecs
import ac.mdiq.podcini.storage.database.Episodes
import ac.mdiq.podcini.storage.database.Episodes.setPlayStateSync
import ac.mdiq.podcini.storage.database.RealmDB.runOnIOScope
import ac.mdiq.podcini.storage.model.*
import ac.mdiq.podcini.storage.utils.EpisodeUtil
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.FlowEvent.PlayEvent.Action
Expand Down Expand Up @@ -44,6 +44,7 @@ import kotlinx.coroutines.*
import java.io.IOException
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlin.Throws

/**
* Manages the MediaPlayer object of the PlaybackService.
Expand Down Expand Up @@ -195,7 +196,7 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP
var item = media_.episodeOrFetch()
if (item != null && item.playState < PlayState.PROGRESS.code) item = runBlocking { setPlayStateSync(PlayState.PROGRESS.code, item, false) }
val eList = if (item?.feed?.preferences?.queue != null) curQueue.episodes else item?.feed?.getVirtualQueueItems() ?: listOf()
curIndexInQueue = EpisodeUtil.indexOfItemWithId(eList, media_.id)
curIndexInQueue = Episodes.indexOfItemWithId(eList, media_.id)
} else curIndexInQueue = -1

prevMedia = curMedia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ import ac.mdiq.podcini.preferences.UserPreferences.isSkipSilence
import ac.mdiq.podcini.preferences.UserPreferences.prefAdaptiveProgressUpdate
import ac.mdiq.podcini.preferences.UserPreferences.rewindSecs
import ac.mdiq.podcini.receiver.MediaButtonReceiver
import ac.mdiq.podcini.storage.database.Episodes
import ac.mdiq.podcini.storage.database.Episodes.deleteMediaSync
import ac.mdiq.podcini.storage.database.Episodes.getEpisodeByGuidOrUrl
import ac.mdiq.podcini.storage.database.Episodes.hasAlmostEnded
import ac.mdiq.podcini.storage.database.Episodes.prefDeleteRemovesFromQueue
import ac.mdiq.podcini.storage.database.Episodes.prefRemoveFromQueueMarkedPlayed
import ac.mdiq.podcini.storage.database.Episodes.setPlayStateSync
Expand All @@ -51,8 +53,6 @@ import ac.mdiq.podcini.storage.model.CurrentState.Companion.PLAYER_STATUS_PAUSED
import ac.mdiq.podcini.storage.model.CurrentState.Companion.PLAYER_STATUS_PLAYING
import ac.mdiq.podcini.storage.model.FeedPreferences.AutoDeleteAction
import ac.mdiq.podcini.storage.utils.ChapterUtils
import ac.mdiq.podcini.storage.utils.EpisodeUtil
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.activity.starter.VideoPlayerActivityStarter
import ac.mdiq.podcini.ui.utils.NotificationUtils
Expand Down Expand Up @@ -444,7 +444,7 @@ class PlaybackService : MediaLibraryService() {
}
Logd(TAG, "getNextInQueue eList: ${eList.size}")
var j = 0
val i = EpisodeUtil.indexOfItemWithId(eList, item.id)
val i = Episodes.indexOfItemWithId(eList, item.id)
Logd(TAG, "getNextInQueue current i: $i curIndexInQueue: $curIndexInQueue")
if (i < 0) {
j = if (curIndexInQueue >= 0 && curIndexInQueue < eList.size) curIndexInQueue else eList.size-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.io.Writer

interface ExportWriter {
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
fun writeDocument(feeds: List<Feed?>?, writer: Writer?, context: Context)
fun writeDocument(feeds: List<Feed>, writer: Writer?, context: Context)

fun fileExtension(): String?
}
82 changes: 72 additions & 10 deletions app/src/main/kotlin/ac/mdiq/podcini/preferences/OpmlTransporter.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package ac.mdiq.podcini.preferences

import ac.mdiq.podcini.R
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.util.MiscFormatter.formatRfc822Date
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.MiscFormatter.formatRfc822Date
import android.Manifest
import android.content.Context
import android.content.DialogInterface
import android.content.pm.PackageManager
import android.net.Uri
import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.util.Log
import android.util.Xml
import androidx.core.app.ActivityCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.apache.commons.io.input.BOMInputStream
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
import java.io.IOException
import java.io.InputStreamReader
import java.io.Reader
import java.io.Writer
import java.util.*
import kotlin.Throws

class OpmlTransporter {

Expand Down Expand Up @@ -44,11 +57,10 @@ class OpmlTransporter {
/** Writes OPML documents. */
class OpmlWriter : ExportWriter {
/**
* Takes a list of feeds and a writer and writes those into an OPML
* document.
* Takes a list of feeds and a writer and writes those into an OPML document.
*/
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
override fun writeDocument(feeds: List<Feed?>?, writer: Writer?, context: Context) {
override fun writeDocument(feeds: List<Feed>, writer: Writer?, context: Context) {
val xs = Xml.newSerializer()
xs.setFeature(OpmlSymbols.XML_FEATURE_INDENT_OUTPUT, true)
xs.setOutput(writer)
Expand All @@ -67,11 +79,10 @@ class OpmlTransporter {
xs.endTag(null, OpmlSymbols.HEAD)

xs.startTag(null, OpmlSymbols.BODY)
for (feed in feeds!!) {
if (feed == null) continue
Logd(TAG, "writeDocument ${feed?.title}")
for (feed in feeds) {
Logd(TAG, "writeDocument ${feed.title}")
xs.startTag(null, OpmlSymbols.OUTLINE)
xs.attribute(null, OpmlSymbols.TEXT, feed!!.title)
xs.attribute(null, OpmlSymbols.TEXT, feed.title)
xs.attribute(null, OpmlSymbols.TITLE, feed.title)
if (feed.type != null) xs.attribute(null, OpmlSymbols.TYPE, feed.type)
xs.attribute(null, OpmlSymbols.XMLURL, feed.downloadUrl)
Expand Down Expand Up @@ -138,8 +149,7 @@ class OpmlTransporter {
}
}
// TODO: on first install app: java.io.IOException: Underlying input stream returned zero bytes
try {
eventType = xpp.next()
try { eventType = xpp.next()
} catch(e: Exception) {
Log.e(TAG, "xpp.next() invalid: $e")
break
Expand All @@ -152,4 +162,56 @@ class OpmlTransporter {
private val TAG: String = OpmlReader::class.simpleName ?: "Anonymous"
}
}

companion object {
fun startImport(context: Context, uri: Uri) {
val TAG = "OpmlTransporter"
// CoroutineScope(Dispatchers.IO).launch {
try {
val opmlFileStream = context.contentResolver.openInputStream(uri)
val bomInputStream = BOMInputStream(opmlFileStream)
val bom = bomInputStream.bom
val charsetName = if (bom == null) "UTF-8" else bom.charsetName
val reader: Reader = InputStreamReader(bomInputStream, charsetName)
val opmlReader = OpmlReader()
val result = opmlReader.readDocument(reader)
reader.close()
// withContext(Dispatchers.Main) {
// binding.progressBar.visibility = View.GONE
Logd(TAG, "Parsing was successful")
// readElements = result
// }
} catch (e: Throwable) {
// withContext(Dispatchers.Main) {
Logd(TAG, Log.getStackTraceString(e))
val message = if (e.message == null) "" else e.message!!
if (message.lowercase().contains("permission")) {
val permission = ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)
if (permission != PackageManager.PERMISSION_GRANTED) {
// requestPermission()
return
}
}
// binding.progressBar.visibility = View.GONE
val alert = MaterialAlertDialogBuilder(context)
alert.setTitle(R.string.error_label)
val userReadable = context.getString(R.string.opml_reader_error)
val details = e.message
val total = """
$userReadable
$details
""".trimIndent()
val errorMessage = SpannableString(total)
errorMessage.setSpan(ForegroundColorSpan(-0x77777778), userReadable.length, total.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
alert.setMessage(errorMessage)
alert.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
// finish()
}
alert.show()
// }
}
// }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ class AutoDownloadPreferencesFragment : PreferenceFragmentCompat() {
Log.e(TAG, "Couldn't get list of configure Wi-Fi networks")
return
}
networks.sortWith { x: WifiConfiguration, y: WifiConfiguration ->
blankIfNull(x.SSID).compareTo(blankIfNull(y.SSID), ignoreCase = true)
}
networks.sortWith { x: WifiConfiguration, y: WifiConfiguration -> blankIfNull(x.SSID).compareTo(blankIfNull(y.SSID), ignoreCase = true) }
selectedNetworks = arrayOfNulls(networks.size)
val prefValues = listOf(*autodownloadSelectedNetworks)
val prefScreen = preferenceScreen
Expand Down Expand Up @@ -130,10 +128,7 @@ class AutoDownloadPreferencesFragment : PreferenceFragmentCompat() {
private fun clearAutodownloadSelectedNetworsPreference() {
if (selectedNetworks != null) {
val prefScreen = preferenceScreen

for (network in selectedNetworks!!) {
if (network != null) prefScreen.removePreference(network)
}
for (network in selectedNetworks!!) if (network != null) prefScreen.removePreference(network)
}
}

Expand All @@ -160,11 +155,7 @@ class AutoDownloadPreferencesFragment : PreferenceFragmentCompat() {
}

private fun setSelectedNetworksEnabled(b: Boolean) {
if (selectedNetworks != null) {
for (p in selectedNetworks!!) {
p!!.isEnabled = b
}
}
if (selectedNetworks != null) for (p in selectedNetworks!!) p!!.isEnabled = b
}

companion object {
Expand Down
Loading

0 comments on commit 5f09864

Please sign in to comment.