From dc144a5b4a7df617af95e5e5ad5a9ff9eb40acd2 Mon Sep 17 00:00:00 2001 From: Xilin Jia <6257601+XilinJia@users.noreply.github.com> Date: Sun, 2 Jun 2024 20:44:19 +0100 Subject: [PATCH] 5.4.2 commit --- .directory | 2 +- app/build.gradle | 4 +- .../podcini/playback/PlaybackController.kt | 12 ++++- .../playback/service/LocalMediaPlayer.kt | 46 +++++++++++-------- .../podcini/storage/PreferencesTransporter.kt | 1 - .../ui/fragment/EpisodeHomeFragment.kt | 2 +- .../ui/fragment/PlayerDetailsFragment.kt | 6 +-- changelog.md | 7 +++ .../android/en-US/changelogs/3020149.txt | 8 ++++ 9 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/3020149.txt diff --git a/.directory b/.directory index f9b3623b..9b03bcbc 100644 --- a/.directory +++ b/.directory @@ -1,5 +1,5 @@ [Dolphin] -Timestamp=2024,2,5,7,26,48.63 +Timestamp=2024,6,2,20,10,4.557 Version=4 ViewMode=1 diff --git a/app/build.gradle b/app/build.gradle index 5b1801ee..4cd6813e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -159,8 +159,8 @@ android { // Version code schema (not used): // "1.2.3-beta4" -> 1020304 // "1.2.3" -> 1020395 - versionCode 3020148 - versionName "5.4.1" + versionCode 3020149 + versionName "5.4.2" def commit = "" try { diff --git a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt index 33d958d6..15f0357c 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt @@ -100,8 +100,16 @@ abstract class PlaybackController(private val activity: FragmentActivity) { activity.registerReceiver(notificationReceiver, IntentFilter(PlaybackServiceConstants.ACTION_PLAYER_NOTIFICATION)) } - if (!released) bindToService() - else throw IllegalStateException("Can't call init() after release() has been called") +// TODO: java.lang.IllegalStateException: Can't call init() after release() has been called +// at ac.mdiq.podcini.playback.PlaybackController.initServiceRunning(SourceFile:104) + if (!released) { + bindToService() + } else { + released = false + bindToService() + Logd(TAG, "Testing bindToService if released") +// throw IllegalStateException("Can't call init() after release() has been called") + } checkMediaInfoLoaded() } diff --git a/app/src/main/java/ac/mdiq/podcini/playback/service/LocalMediaPlayer.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/LocalMediaPlayer.kt index 5a0378f5..ae9ce165 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/service/LocalMediaPlayer.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/LocalMediaPlayer.kt @@ -84,6 +84,7 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP private val bufferUpdateInterval = 5000L // private val bufferingUpdateDisposable: Disposable private var mediaSource: MediaSource? = null + private var mediaItem: MediaItem? = null private var playbackParameters: PlaybackParameters private var bufferedPercentagePrev = 0 @@ -119,8 +120,10 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP @Throws(IllegalStateException::class) private fun prepareWR() { - if (mediaSource == null) return - exoPlayer?.setMediaSource(mediaSource!!, false) + if (mediaSource == null && mediaItem == null) return + + if (mediaSource != null) exoPlayer?.setMediaSource(mediaSource!!, false) + else exoPlayer?.setMediaItem(mediaItem!!) exoPlayer?.prepare() } @@ -159,26 +162,29 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP @Throws(IllegalArgumentException::class, IllegalStateException::class) private fun setDataSource(m: MediaMetadata, s: String, user: String?, password: String?) { Logd(TAG, "setDataSource: $s") - - if (httpDataSourceFactory == null) - httpDataSourceFactory = OkHttpDataSource.Factory(PodciniHttpClient.getHttpClient() as okhttp3.Call.Factory).setUserAgent(ClientConfig.USER_AGENT) - - if (!user.isNullOrEmpty() && !password.isNullOrEmpty()) { - val requestProperties = HashMap() - requestProperties["Authorization"] = HttpCredentialEncoder.encode(user, password, "ISO-8859-1") - httpDataSourceFactory!!.setDefaultRequestProperties(requestProperties) - } - val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(context, null, httpDataSourceFactory!!) - val extractorsFactory = DefaultExtractorsFactory() - extractorsFactory.setConstantBitrateSeekingEnabled(true) - extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_DISABLE_ID3_METADATA) - val f = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory) - - val mediaItem = MediaItem.Builder() + + mediaItem = MediaItem.Builder() .setUri(Uri.parse(s)) .setMediaMetadata(m).build() + mediaSource = null - mediaSource = f.createMediaSource(mediaItem) + if (!user.isNullOrEmpty() && !password.isNullOrEmpty()) { + if (httpDataSourceFactory == null) + httpDataSourceFactory = OkHttpDataSource.Factory(PodciniHttpClient.getHttpClient() as okhttp3.Call.Factory).setUserAgent(ClientConfig.USER_AGENT) + + if (!user.isNullOrEmpty() && !password.isNullOrEmpty()) { + val requestProperties = HashMap() + requestProperties["Authorization"] = HttpCredentialEncoder.encode(user, password, "ISO-8859-1") + httpDataSourceFactory!!.setDefaultRequestProperties(requestProperties) + } + val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(context, null, httpDataSourceFactory!!) + val extractorsFactory = DefaultExtractorsFactory() + extractorsFactory.setConstantBitrateSeekingEnabled(true) + extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_DISABLE_ID3_METADATA) + val f = ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory) + + mediaSource = f.createMediaSource(mediaItem!!) + } } private fun play() { @@ -821,7 +827,7 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP var cause = error.cause if (cause is HttpDataSourceException && cause.cause != null) cause = cause.cause if (cause != null && "Source error" == cause.message) cause = cause.cause - audioErrorListener?.accept(if (cause != null) cause.message else error.message) + audioErrorListener?.accept((if (cause != null) cause.message else error.message) ?:"no message") } } diff --git a/app/src/main/java/ac/mdiq/podcini/storage/PreferencesTransporter.kt b/app/src/main/java/ac/mdiq/podcini/storage/PreferencesTransporter.kt index 386b7973..205b066f 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/PreferencesTransporter.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/PreferencesTransporter.kt @@ -1,6 +1,5 @@ package ac.mdiq.podcini.storage -import ac.mdiq.podcini.util.Logd import android.content.Context import android.net.Uri import android.util.Log diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeHomeFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeHomeFragment.kt index a468a52b..b1a591b1 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeHomeFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeHomeFragment.kt @@ -119,7 +119,7 @@ class EpisodeHomeFragment : Fragment() { if (!ttsReady) initializeTTS(requireContext()) withContext(Dispatchers.Main) { - binding.readerView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes!!, "text/html", "UTF-8", null) + binding.readerView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes?:"No notes", "text/html", "UTF-8", null) binding.readerView.visibility = View.VISIBLE binding.webView.visibility = View.GONE } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt index 74225fbd..562de501 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt @@ -210,7 +210,7 @@ class PlayerDetailsFragment : Fragment() { withContext(Dispatchers.Main) { Logd(TAG, "subscribe: ${media?.getEpisodeTitle()}") displayMediaInfo(media!!) - shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes!!, "text/html", "utf-8", "about:blank") + shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes?:"No notes", "text/html", "utf-8", "about:blank") Logd(TAG, "Webview loaded") } }.invokeOnCompletion { throwable -> @@ -241,12 +241,12 @@ class PlayerDetailsFragment : Fragment() { if (!homeText.isNullOrEmpty()) { val shownotesCleaner = ShownotesCleaner(requireContext(), homeText!!, 0) cleanedNotes = shownotesCleaner.processShownotes() - shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes!!, "text/html", "UTF-8", null) + shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes?:"No notes", "text/html", "UTF-8", null) } else Toast.makeText(context, R.string.web_content_not_available, Toast.LENGTH_LONG).show() } else { val shownotesCleaner = ShownotesCleaner(requireContext(), item?.description ?: "", media?.getDuration()?:0) cleanedNotes = shownotesCleaner.processShownotes() - if (!cleanedNotes.isNullOrEmpty()) shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes!!, "text/html", "UTF-8", null) + if (!cleanedNotes.isNullOrEmpty()) shownoteView.loadDataWithBaseURL("https://127.0.0.1", cleanedNotes?:"No notes", "text/html", "UTF-8", null) else Toast.makeText(context, R.string.web_content_not_available, Toast.LENGTH_LONG).show() } } diff --git a/changelog.md b/changelog.md index e1bdb425..2105ce8b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +## 5.4.2 + +* likely fixed crash issue when the app is restarted after long idle +* fixed null pointer crash issue in when trying to report player error +* fixed null pointer crash issue when open player detailed view with online episode +* likely fixed the audio break issue when streaming some podcasts, particularly those related to "iHeart" (actually the server has some invalid settings, someone should notify them). +this should take effect with episodes in both subscribed or online feeds ## 5.4.1 diff --git a/fastlane/metadata/android/en-US/changelogs/3020149.txt b/fastlane/metadata/android/en-US/changelogs/3020149.txt new file mode 100644 index 00000000..29fa27fa --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/3020149.txt @@ -0,0 +1,8 @@ + +Version 5.4.2 brings several changes: + +* likely fixed crash issue when the app is restarted after long idle +* fixed null pointer crash issue in when trying to report player error +* fixed null pointer crash issue when open player detailed view with online episode +* likely fixed the audio break issue when streaming some podcasts, particularly those related to "iHeart" (actually the server has some invalid settings, someone should notify them). +this should take effect with episodes in both subscribed or online feeds