diff --git a/.circleci/config.yml b/.circleci/config.yml index 80dbab808..c2eea438d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,8 +94,5 @@ workflows: name: SpotBugs build-steps: - run: - name: SpotBugs (Modules with Play flavour) - command: ./gradlew spotbugsPlayDebug | grep "\[SpotBugs\]" - - run: - name: SpotBugs (Modules without Play flavour) - command: ./gradlew spotbugsDebug | grep "\[SpotBugs\]" + name: SpotBugs + command: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs" diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index b5edcc878..aa1d746a5 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -188,7 +188,9 @@ public class MainActivity extends CastEnabledActivity { public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) { if (drawerLayout != null) { // Tablet layout does not have a drawer - drawerLayout.removeDrawerListener(drawerToggle); + if (drawerToggle != null) { + drawerLayout.removeDrawerListener(drawerToggle); + } drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); drawerLayout.addDrawerListener(drawerToggle); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index de3242b1a..05099777c 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -58,9 +58,8 @@ public class NavListAdapter extends RecyclerView.Adapter */ public static final String SUBSCRIPTION_LIST_TAG = "SubscriptionList"; - private static List fragmentTags; - private static String[] titles; - + private final List fragmentTags = new ArrayList<>(); + private final String[] titles; private final ItemAccess itemAccess; private final WeakReference activity; public boolean showSubscriptionList = true; @@ -98,7 +97,8 @@ public class NavListAdapter extends RecyclerView.Adapter showSubscriptionList = false; } - fragmentTags = newTags; + fragmentTags.clear(); + fragmentTags.addAll(newTags); notifyDataSetChanged(); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index d0fb91692..375f676c8 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -206,7 +206,7 @@ public class ProxyDialog { private boolean checkPort() { int port = getPort(); - if(port < 0 && port > 65535) { + if (port < 0 || port > 65535) { etPort.setError(context.getString(R.string.proxy_port_invalid_error)); return false; } diff --git a/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java b/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java index 16c5548be..dfea627df 100644 --- a/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java +++ b/app/src/main/java/de/danoeh/antennapod/discovery/PodcastSearcherRegistry.java @@ -12,7 +12,7 @@ public class PodcastSearcherRegistry { private PodcastSearcherRegistry() { } - public static List getSearchProviders() { + public static synchronized List getSearchProviders() { if (searchProviders == null) { searchProviders = new ArrayList<>(); searchProviders.add(new SearcherInfo(new CombinedSearcher(), 1.0f)); diff --git a/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java b/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java index dc62863f9..23c8ffdd5 100644 --- a/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java +++ b/app/src/main/java/de/danoeh/antennapod/error/CrashReportWriter.java @@ -7,7 +7,6 @@ import de.danoeh.antennapod.BuildConfig; import org.apache.commons.io.IOUtils; import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; @@ -40,7 +39,7 @@ public class CrashReportWriter implements Thread.UncaughtExceptionHandler { File path = getFile(); PrintWriter out = null; try { - out = new PrintWriter(new FileWriter(path)); + out = new PrintWriter(path, "UTF-8"); out.println("## Crash info"); out.println("Time: " + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.getDefault()).format(new Date())); out.println("AntennaPod version: " + BuildConfig.VERSION_NAME); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 612959c04..18b011a08 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -27,7 +27,7 @@ public class AllEpisodesFragment extends EpisodesListFragment { private static final String PREF_NAME = "PrefAllEpisodesFragment"; private static final String PREF_FILTER = "filter"; - private static FeedItemFilter feedItemFilter = new FeedItemFilter(""); + private FeedItemFilter feedItemFilter = new FeedItemFilter(""); @Override public void onCreate(@Nullable Bundle savedInstanceState) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java index 0ce38656a..0d9181d84 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagFragment.java @@ -1,13 +1,13 @@ package de.danoeh.antennapod.fragment.gpodnet; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetTag; -import org.apache.commons.lang3.Validate; import de.danoeh.antennapod.activity.MainActivity; @@ -24,8 +24,7 @@ public class TagFragment extends PodcastListFragment { private GpodnetTag tag; - public static TagFragment newInstance(GpodnetTag tag) { - Validate.notNull(tag); + public static TagFragment newInstance(@NonNull GpodnetTag tag) { TagFragment fragment = new TagFragment(); Bundle args = new Bundle(); args.putParcelable("tag", tag); @@ -38,7 +37,9 @@ public class TagFragment extends PodcastListFragment { super.onCreate(savedInstanceState); Bundle args = getArguments(); - Validate.isTrue(args != null && args.getParcelable("tag") != null, "args invalid"); + if (args == null || args.getParcelable("tag") == null) { + throw new IllegalArgumentException("Arguments not given"); + } tag = args.getParcelable("tag"); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java index b844234b7..dcd720dc2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java @@ -29,7 +29,7 @@ public class DevelopersFragment extends ListFragment { developersLoader = Single.create((SingleOnSubscribe>) emitter -> { ArrayList developers = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("developers.csv"))); + getContext().getAssets().open("developers.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java index 97565a613..38e532aed 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java @@ -95,7 +95,7 @@ public class LicensesFragment extends ListFragment { private void showLicenseText(String licenseTextFile) { try { BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open(licenseTextFile))); + getContext().getAssets().open(licenseTextFile), "UTF-8")); StringBuilder licenseText = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java index d759a5ff2..1b4beeea0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java @@ -29,7 +29,7 @@ public class SpecialThanksFragment extends ListFragment { translatorsLoader = Single.create((SingleOnSubscribe>) emitter -> { ArrayList translators = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("special_thanks.csv"))); + getContext().getAssets().open("special_thanks.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java index b77c74de6..ed0d53145 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java @@ -29,7 +29,7 @@ public class TranslatorsFragment extends ListFragment { translatorsLoader = Single.create((SingleOnSubscribe>) emitter -> { ArrayList translators = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader( - getContext().getAssets().open("translators.csv"))); + getContext().getAssets().open("translators.csv"), "UTF-8")); String line; while ((line = reader.readLine()) != null) { String[] info = line.split(";"); diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 4c1e23ece..c2e97c780 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -1,13 +1,39 @@ - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java index d6926385e..47df099b5 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java @@ -43,7 +43,7 @@ public class FeedItem extends FeedComponent implements Serializable { private Date pubDate; private FeedMedia media; - private Feed feed; + private transient Feed feed; private long feedId; private int state; diff --git a/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java b/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java index 519d625e2..d6d63fed0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/glide/ChapterImageModelLoader.java @@ -1,7 +1,6 @@ package de.danoeh.antennapod.core.glide; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import com.bumptech.glide.Priority; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.Options; @@ -36,7 +35,6 @@ public final class ChapterImageModelLoader implements ModelLoader buildLoadData(@NonNull EmbeddedChapterImage model, int width, @@ -65,9 +63,9 @@ public final class ChapterImageModelLoader implements ModelLoader { Request request = chain.request().newBuilder() diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java index cecfc0d2c..cd0fc93ea 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/gpoddernet/GpodnetService.java @@ -667,11 +667,11 @@ public class GpodnetService implements ISyncService { while ((count = in.read(buffer)) > 0) { outputStream.write(buffer, 0, count); } + return outputStream.toString("UTF-8"); } catch (IOException e) { e.printStackTrace(); throw new GpodnetServiceException(e); } - return outputStream.toString(); } private void checkStatusCode(@NonNull Response response) throws GpodnetServiceException { diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/syndication/HtmlToPlainText.java b/core/src/main/java/de/danoeh/antennapod/core/util/syndication/HtmlToPlainText.java index baa467acf..37dee0486 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/syndication/HtmlToPlainText.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/syndication/HtmlToPlainText.java @@ -34,8 +34,7 @@ import java.util.regex.Pattern; public class HtmlToPlainText { /** - * Use this method to strip off HTML encoding from given text - *

+ * Use this method to strip off HTML encoding from given text. * Replaces bullet points with *, ignores colors/bold/... * * @param str String with any encoding @@ -60,10 +59,8 @@ public class HtmlToPlainText { * @return True if text contains any HTML tags
False is no HTML tag is found */ private static boolean isHtml(String str) { - final String HTML_TAG_PATTERN = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>"; - Pattern htmlValidator = TextUtils.isEmpty(HTML_TAG_PATTERN) ? null : Pattern.compile(HTML_TAG_PATTERN); - - return htmlValidator.matcher(str).find(); + final String htmlTagPattern = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>"; + return Pattern.compile(htmlTagPattern).matcher(str).find(); } /**