From dd6c0a22f30b5dcd04238a180a868c562b8e1822 Mon Sep 17 00:00:00 2001 From: y20k Date: Fri, 19 Mar 2021 20:26:54 +0100 Subject: [PATCH] fixes a crash in the search dialog (see #65) --- app/build.gradle | 10 +++++----- app/proguard-rules.pro | 5 ++--- .../java/org/y20k/escapepod/PlayerFragment.kt | 4 ++-- .../y20k/escapepod/dialogs/FindPodcastDialog.kt | 8 ++++---- .../org/y20k/escapepod/helpers/FileHelper.kt | 2 +- .../escapepod/search/SearchResultAdapter.kt | 1 + .../search/{ => results}/GpodderResult.kt | 6 +++++- .../search/{ => results}/PodcastindexResult.kt | 8 ++++++-- .../search/{ => results}/SearchResult.kt | 17 +++++++++-------- build.gradle | 2 +- metadata/en-US/changelogs/33.txt | 5 +++++ 11 files changed, 41 insertions(+), 27 deletions(-) rename app/src/main/java/org/y20k/escapepod/search/{ => results}/GpodderResult.kt (84%) rename app/src/main/java/org/y20k/escapepod/search/{ => results}/PodcastindexResult.kt (93%) rename app/src/main/java/org/y20k/escapepod/search/{ => results}/SearchResult.kt (50%) create mode 100644 metadata/en-US/changelogs/33.txt diff --git a/app/build.gradle b/app/build.gradle index 94cf080a..0bff30bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId 'org.y20k.escapepod' minSdkVersion 25 targetSdkVersion 30 - versionCode 32 - versionName '1.0.1' + versionCode 33 + versionName '1.0.2' resConfigs "de", "en", "es", "eu", "fi", "fr", "fr-rCA", "he", "hr", "it", "nb-rNO", "nl", "pl", "pt", "ru", "tr", "zh-rCN" } @@ -73,11 +73,11 @@ dependencies { implementation "androidx.constraintlayout:constraintlayout:2.0.4" implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation "androidx.core:core-ktx:1.3.2" - implementation "androidx.activity:activity-ktx:1.2.0" + implementation "androidx.activity:activity-ktx:1.2.1" implementation "androidx.palette:palette-ktx:1.0.0" implementation "androidx.preference:preference-ktx:1.1.1" - def navigationVersion = "2.3.3" + def navigationVersion = "2.3.4" implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion" implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion" @@ -93,6 +93,6 @@ dependencies { implementation "com.google.android.exoplayer:extension-mediasession:$exoplayerVersion" implementation "com.google.code.gson:gson:2.8.6" - implementation 'com.android.volley:volley:1.1.1' + implementation 'com.android.volley:volley:1.2.0' } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 41b70eba..f10f4bfd 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -21,9 +21,8 @@ -renamesourcefileattribute SourceFile -# Preserve the core classes - because they need to be de-/serialized with GSON --keep public class org.y20k.escapepod.core.** { *; } +# Preserve classes - because they need to be de-/serialized with GSON +-keep public class org.y20k.escapepod.search.results.* { *; } -keep public class org.y20k.escapepod.playback.PlayerService { *; } --keep public class org.y20k.escapepod.search.GpodderResult { *; } diff --git a/app/src/main/java/org/y20k/escapepod/PlayerFragment.kt b/app/src/main/java/org/y20k/escapepod/PlayerFragment.kt index af9f4539..47ba7834 100644 --- a/app/src/main/java/org/y20k/escapepod/PlayerFragment.kt +++ b/app/src/main/java/org/y20k/escapepod/PlayerFragment.kt @@ -218,7 +218,7 @@ class PlayerFragment: Fragment(), CoroutineScope, override fun onStop() { super.onStop() // (see "stay in sync with the MediaSession") - playerController.unregisterCallback(mediaControllerCallback) + if (this::playerController.isInitialized) playerController.unregisterCallback(mediaControllerCallback) mediaBrowser.disconnect() playerServiceConnected = false } @@ -876,7 +876,7 @@ class PlayerFragment: Fragment(), CoroutineScope, private val periodicProgressUpdateRequestRunnable: Runnable = object : Runnable { override fun run() { // request current playback position - playerController.requestProgressUpdate(resultReceiver) + if (this@PlayerFragment::playerController.isInitialized) playerController.requestProgressUpdate(resultReceiver) // use the handler to start runnable again after specified delay handler.postDelayed(this, 500) } diff --git a/app/src/main/java/org/y20k/escapepod/dialogs/FindPodcastDialog.kt b/app/src/main/java/org/y20k/escapepod/dialogs/FindPodcastDialog.kt index d59b12f7..3dd5458f 100644 --- a/app/src/main/java/org/y20k/escapepod/dialogs/FindPodcastDialog.kt +++ b/app/src/main/java/org/y20k/escapepod/dialogs/FindPodcastDialog.kt @@ -41,10 +41,10 @@ import org.y20k.escapepod.R import org.y20k.escapepod.helpers.LogHelper import org.y20k.escapepod.helpers.NetworkHelper import org.y20k.escapepod.helpers.PreferencesHelper -import org.y20k.escapepod.search.GpodderResult -import org.y20k.escapepod.search.PodcastindexResult -import org.y20k.escapepod.search.SearchResult import org.y20k.escapepod.search.SearchResultAdapter +import org.y20k.escapepod.search.results.GpodderResult +import org.y20k.escapepod.search.results.PodcastindexResult +import org.y20k.escapepod.search.results.SearchResult /* @@ -373,4 +373,4 @@ class FindPodcastDialog (private var context: Context, private var listener: Fin return searchResults } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/y20k/escapepod/helpers/FileHelper.kt b/app/src/main/java/org/y20k/escapepod/helpers/FileHelper.kt index 819b48b5..17459fda 100644 --- a/app/src/main/java/org/y20k/escapepod/helpers/FileHelper.kt +++ b/app/src/main/java/org/y20k/escapepod/helpers/FileHelper.kt @@ -437,7 +437,7 @@ object FileHelper { // check if file exists val file: File = File(context.getExternalFilesDir(folder), fileName) - if (!file.exists()) { + if (!file.exists() || !file.canRead()) { return String() } // readSuspended until last line reached diff --git a/app/src/main/java/org/y20k/escapepod/search/SearchResultAdapter.kt b/app/src/main/java/org/y20k/escapepod/search/SearchResultAdapter.kt index 915a251f..73bebfaf 100644 --- a/app/src/main/java/org/y20k/escapepod/search/SearchResultAdapter.kt +++ b/app/src/main/java/org/y20k/escapepod/search/SearchResultAdapter.kt @@ -21,6 +21,7 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.textview.MaterialTextView import org.y20k.escapepod.R import org.y20k.escapepod.helpers.LogHelper +import org.y20k.escapepod.search.results.SearchResult /* diff --git a/app/src/main/java/org/y20k/escapepod/search/GpodderResult.kt b/app/src/main/java/org/y20k/escapepod/search/results/GpodderResult.kt similarity index 84% rename from app/src/main/java/org/y20k/escapepod/search/GpodderResult.kt rename to app/src/main/java/org/y20k/escapepod/search/results/GpodderResult.kt index 59778337..e835e1af 100644 --- a/app/src/main/java/org/y20k/escapepod/search/GpodderResult.kt +++ b/app/src/main/java/org/y20k/escapepod/search/results/GpodderResult.kt @@ -12,14 +12,18 @@ */ -package org.y20k.escapepod.search +package org.y20k.escapepod.search.results +import androidx.annotation.Keep import com.google.gson.annotations.Expose /* * GpodderResult class */ +// NOTE: This class needs to be excepted from Obfuscation to work with GSON +// therefore it is added to proguard-rules.pro with "-keep public class ..." +@Keep data class GpodderResult (@Expose val url: String, @Expose val title: String, @Expose val description: String, diff --git a/app/src/main/java/org/y20k/escapepod/search/PodcastindexResult.kt b/app/src/main/java/org/y20k/escapepod/search/results/PodcastindexResult.kt similarity index 93% rename from app/src/main/java/org/y20k/escapepod/search/PodcastindexResult.kt rename to app/src/main/java/org/y20k/escapepod/search/results/PodcastindexResult.kt index 5518d110..f539ee35 100644 --- a/app/src/main/java/org/y20k/escapepod/search/PodcastindexResult.kt +++ b/app/src/main/java/org/y20k/escapepod/search/results/PodcastindexResult.kt @@ -12,8 +12,9 @@ */ -package org.y20k.escapepod.search +package org.y20k.escapepod.search.results +import androidx.annotation.Keep import com.google.gson.annotations.Expose @@ -21,6 +22,9 @@ import com.google.gson.annotations.Expose * PodcastindexResult class * Documentation of format for PodcastindexResult - see: https://podcastindex-org.github.io/docs-api/ */ +// NOTE: This class needs to be excepted from Obfuscation to work with GSON +// therefore it is added to proguard-rules.pro with "-keep public class ..." +@Keep data class PodcastindexResult (@Expose val status: Boolean, @Expose val feeds: List, @Expose val count: Int, @@ -103,4 +107,4 @@ data class PodcastindexResult (@Expose val status: Boolean, "query": "batman university", "description": "Found matching feeds." } - */ \ No newline at end of file + */ diff --git a/app/src/main/java/org/y20k/escapepod/search/SearchResult.kt b/app/src/main/java/org/y20k/escapepod/search/results/SearchResult.kt similarity index 50% rename from app/src/main/java/org/y20k/escapepod/search/SearchResult.kt rename to app/src/main/java/org/y20k/escapepod/search/results/SearchResult.kt index 6ad891c0..353ff703 100644 --- a/app/src/main/java/org/y20k/escapepod/search/SearchResult.kt +++ b/app/src/main/java/org/y20k/escapepod/search/results/SearchResult.kt @@ -1,7 +1,7 @@ /* - * GpodderResult.kt - * Implements the GpodderResult class - * A GpodderResult is the search result of a request to the gpodder.net search API + * SearchResult.kt + * Implements the SearchResult class + * A SearchResult contains data needed to display the search dialog results * * This file is part of * ESCAPEPOD - Free and Open Podcast App @@ -12,17 +12,18 @@ */ -package org.y20k.escapepod.search +package org.y20k.escapepod.search.results +import androidx.annotation.Keep import com.google.gson.annotations.Expose /* - * GpodderResult class + * SearchResult class */ +// NOTE: This class needs to be excepted from Obfuscation to work with GSON +// therefore it is added to proguard-rules.pro with "-keep public class ..." +@Keep data class SearchResult (@Expose val url: String, @Expose val title: String, @Expose val description: String) - -// Documentation of format for GpodderResult - see: -// https://gpoddernet.readthedocs.io/en/latest/api/reference/general.html#formats \ No newline at end of file diff --git a/build.gradle b/build.gradle index 84175545..2e05343a 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/metadata/en-US/changelogs/33.txt b/metadata/en-US/changelogs/33.txt new file mode 100644 index 00000000..ee4f4e84 --- /dev/null +++ b/metadata/en-US/changelogs/33.txt @@ -0,0 +1,5 @@ +# v1.0.2 - Sag Alles Ab + +**2021-03-19** + +- fixes a crash in the search dialog