6.0.11 commit
This commit is contained in:
parent
43054ec52e
commit
abb0736579
|
@ -126,8 +126,8 @@ android {
|
|||
buildConfig true
|
||||
}
|
||||
defaultConfig {
|
||||
versionCode 3020210
|
||||
versionName "6.0.10"
|
||||
versionCode 3020211
|
||||
versionName "6.0.11"
|
||||
|
||||
applicationId "ac.mdiq.podcini.R"
|
||||
def commit = ""
|
||||
|
|
|
@ -130,7 +130,7 @@ class DownloadServiceInterfaceImpl : DownloadServiceInterface() {
|
|||
override fun doWork(): Result {
|
||||
Logd(TAG, "starting doWork")
|
||||
ClientConfigurator.initialize(applicationContext)
|
||||
val mediaId = inputData.getLong(DownloadServiceInterface.WORK_DATA_MEDIA_ID, 0)
|
||||
val mediaId = inputData.getLong(WORK_DATA_MEDIA_ID, 0)
|
||||
val media = Episodes.getEpisodeMedia(mediaId)
|
||||
if (media == null) {
|
||||
Log.e(TAG, "media is null for mediaId: $mediaId")
|
||||
|
@ -146,7 +146,7 @@ class DownloadServiceInterfaceImpl : DownloadServiceInterface() {
|
|||
if (isInterrupted) return
|
||||
notificationProgress.put(media.getEpisodeTitle(), request.progressPercent)
|
||||
}
|
||||
setProgressAsync(Data.Builder().putInt(DownloadServiceInterface.WORK_DATA_PROGRESS, request.progressPercent).build()).get()
|
||||
setProgressAsync(Data.Builder().putInt(WORK_DATA_PROGRESS, request.progressPercent).build()).get()
|
||||
val nm = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
nm.notify(R.id.notification_downloading, generateProgressNotification())
|
||||
sleep(1000)
|
||||
|
|
|
@ -17,6 +17,7 @@ import ac.mdiq.podcini.storage.database.RealmDB.upsertBlk
|
|||
import ac.mdiq.podcini.storage.model.Episode
|
||||
import ac.mdiq.podcini.storage.model.Feed
|
||||
import ac.mdiq.podcini.preferences.OpmlTransporter.*
|
||||
import ac.mdiq.podcini.storage.database.Episodes.getEpisodeByTitle
|
||||
import ac.mdiq.podcini.storage.model.EpisodeFilter
|
||||
import ac.mdiq.podcini.storage.utils.EpisodeUtil.hasAlmostEnded
|
||||
import ac.mdiq.podcini.storage.model.EpisodeSortOrder
|
||||
|
@ -167,7 +168,7 @@ class ImportExportPreferencesFragment : PreferenceFragmentCompat() {
|
|||
exportPreferences()
|
||||
true
|
||||
}
|
||||
findPreference<Preference>(PREF_MEDIAFILES_IMPORT)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
findPreference<Preference>(PREF_MEDIAFILES_IMPORT)?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
importMediaFiles()
|
||||
true
|
||||
}
|
||||
|
@ -750,15 +751,26 @@ class ImportExportPreferencesFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
}
|
||||
private fun copyRecursive(context: Context, srcFile: DocumentFile, srcRootDir: DocumentFile, destRootDir: File) {
|
||||
val relativePath = srcFile.uri.path?.substring(srcRootDir.uri.path!!.length) ?: return
|
||||
val destFile = File(destRootDir, relativePath)
|
||||
val relativePath = srcFile.uri.path?.substring(srcRootDir.uri.path!!.length+1) ?: return
|
||||
if (srcFile.isDirectory) {
|
||||
val destFile = File(destRootDir, relativePath)
|
||||
if (!destFile.exists()) destFile.mkdirs()
|
||||
srcFile.listFiles().forEach { file ->
|
||||
copyRecursive(context, file, srcFile, destFile)
|
||||
}
|
||||
} else {
|
||||
if (!destFile.exists()) copyFile(srcFile, destFile, context)
|
||||
val nameParts = relativePath.split(".")
|
||||
if (nameParts.size < 3) return
|
||||
val ext = nameParts[nameParts.size-1]
|
||||
val title = nameParts.dropLast(2).joinToString(".")
|
||||
Logd(TAG, "copyRecursive title: $title")
|
||||
val episode = getEpisodeByTitle(title) ?: return
|
||||
val destName = "$title.${episode.id}.$ext"
|
||||
val destFile = File(destRootDir, destName)
|
||||
if (!destFile.exists()) {
|
||||
copyFile(srcFile, destFile, context)
|
||||
upsertBlk(episode) { it.media?.setfileUrlOrNull(destFile.name)}
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun copyFile(sourceFile: DocumentFile, destFile: File, context: Context) {
|
||||
|
|
|
@ -84,6 +84,12 @@ object Episodes {
|
|||
return if (episode != null) realm.copyFromRealm(episode) else null
|
||||
}
|
||||
|
||||
fun getEpisodeByTitle(title: String): Episode? {
|
||||
Logd(TAG, "getEpisodeByTitle called $title ")
|
||||
val episode = realm.query(Episode::class).query("title == $0", title).first().find()
|
||||
return if (episode != null) realm.copyFromRealm(episode) else null
|
||||
}
|
||||
|
||||
fun getEpisodeMedia(mediaId: Long): EpisodeMedia? {
|
||||
Logd(TAG, "getEpisodeMedia called $mediaId")
|
||||
val media = realm.query(EpisodeMedia::class).query("id == $0", mediaId).first().find()
|
||||
|
|
|
@ -369,7 +369,7 @@ class PlayerDetailsFragment : Fragment() {
|
|||
|
||||
@UnstableApi private fun savePreference() {
|
||||
Logd(TAG, "Saving preferences")
|
||||
val editor = prefs!!.edit()
|
||||
val editor = prefs?.edit() ?: return
|
||||
if (curMedia != null) {
|
||||
Logd(TAG, "Saving scroll position: " + binding.itemDescriptionFragment.scrollY)
|
||||
editor.putInt(PREF_SCROLL_Y, binding.itemDescriptionFragment.scrollY)
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
search:keywords="@string/import_export_search_keywords"
|
||||
android:title="@string/media_files_export_label"
|
||||
android:summary="@string/media_files_export_summary"/>
|
||||
<Preference
|
||||
android:key="prefMediaFilesImport"
|
||||
search:keywords="@string/import_export_search_keywords"
|
||||
android:title="@string/media_files_import_label"
|
||||
android:summary="@string/media_files_import_summary"/>
|
||||
<!-- <Preference-->
|
||||
<!-- android:key="prefMediaFilesImport"-->
|
||||
<!-- search:keywords="@string/import_export_search_keywords"-->
|
||||
<!-- android:title="@string/media_files_import_label"-->
|
||||
<!-- android:summary="@string/media_files_import_summary"/>-->
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/preferences">
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# 6.0.11
|
||||
|
||||
* This is a minor release of subtraction: import of downloaded media files is temporarily disabled as it's more complicated than I thought. Although it works on files exported from Podcini.R, file names from earlier versions aren't easily recognizable.
|
||||
|
||||
# 6.0.10
|
||||
|
||||
* for better migrating from version 5, added export/import of downloaded media files: inter-operable with Podcini 5.5.4
|
||||
|
|
|
@ -13,7 +13,7 @@ the following can be imported to it from Settings -> Import/Export:
|
|||
* preferences files
|
||||
* OPML file
|
||||
* json file of episodes progress
|
||||
* downloaded media files (5.5.4 only)
|
||||
* downloaded media files (5.5.4 only, but currently not enabled for import)
|
||||
|
||||
An OPML file should be imported before importing episodes progress, but you can always re-do any of the above
|
||||
|
||||
|
|
Loading…
Reference in New Issue