From 012ed2e8f25054aabb72a8825ce1551d7722a0ec Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Sun, 21 Jul 2019 23:18:38 -0400 Subject: [PATCH 1/5] Re-enable linting We were currently ignoring both deprecation and serial warnings. This prevents warnings during the build, but hides useful information about code that could/should be changed for all sorts of reasons. In some instances of such warnings, the appropriate action is already being taken (e.g. StorageUtils), so instead of ignoring all warnings, we can just add a @SuppressWarnings("deprecation") in the appropriate methods. Others scenarios will require more effort, like replacing ProgressDialogs with something else. Let's re-enable the lint warnings and work our way through them. Closes: #3273 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 55c44bb77..9c7e856c9 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ allprojects { gradle.projectsEvaluated { tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint" << "-Xlint:-deprecation" << "-Xlint:-serial" + options.compilerArgs << "-Xlint" } } } From f484b7965c9ad8d6151c6dd8c99cc9d04915d780 Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Sun, 21 Jul 2019 23:26:47 -0400 Subject: [PATCH 2/5] Reformat exceptions This also makes the variable and attribute names consistent with the standard `Exception` class. --- ...GpodnetServiceAuthenticationException.java | 1 - .../GpodnetServiceBadStatusCodeException.java | 2 - .../storage/DownloadRequestException.java | 25 +++++----- .../handler/UnsupportedFeedtypeException.java | 50 +++++++++---------- .../core/util/InvalidFeedException.java | 27 +++++----- .../exception/MediaFileNotFoundException.java | 18 +++---- .../util/id3reader/ID3ReaderException.java | 23 ++++----- .../VorbisCommentReaderException.java | 30 +++++------ 8 files changed, 83 insertions(+), 93 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java index 8bd56218c..2f9c6b54c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java @@ -17,5 +17,4 @@ public class GpodnetServiceAuthenticationException extends GpodnetServiceExcepti public GpodnetServiceAuthenticationException(Throwable cause) { super(cause); } - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java index 84c085ed2..3592cbc5a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java @@ -7,6 +7,4 @@ class GpodnetServiceBadStatusCodeException extends GpodnetServiceException { super(message); this.statusCode = statusCode; } - - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java index c85559e20..35b41d0d2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java @@ -6,20 +6,19 @@ package de.danoeh.antennapod.core.storage; */ public class DownloadRequestException extends Exception { - public DownloadRequestException() { - super(); - } + public DownloadRequestException() { + super(); + } - public DownloadRequestException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } + public DownloadRequestException(String message, Throwable cause) { + super(message, cause); + } - public DownloadRequestException(String detailMessage) { - super(detailMessage); - } - - public DownloadRequestException(Throwable throwable) { - super(throwable); - } + public DownloadRequestException(String message) { + super(message); + } + public DownloadRequestException(Throwable cause) { + super(cause); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/UnsupportedFeedtypeException.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/UnsupportedFeedtypeException.java index fd7d0a4e1..c9f9f19c8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/UnsupportedFeedtypeException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/UnsupportedFeedtypeException.java @@ -3,44 +3,42 @@ package de.danoeh.antennapod.core.syndication.handler; import de.danoeh.antennapod.core.syndication.handler.TypeGetter.Type; public class UnsupportedFeedtypeException extends Exception { - private static final long serialVersionUID = 9105878964928170669L; - private final TypeGetter.Type type; - private String rootElement; - private String message = null; - - public UnsupportedFeedtypeException(Type type) { - super(); - this.type = type; - } + private static final long serialVersionUID = 9105878964928170669L; + private final TypeGetter.Type type; + private String rootElement; + private String message = null; + + public UnsupportedFeedtypeException(Type type) { + super(); + this.type = type; + } public UnsupportedFeedtypeException(Type type, String rootElement) { this.type = type; this.rootElement = rootElement; } - public UnsupportedFeedtypeException(String message) { - this.message = message; - type = Type.INVALID; - } + public UnsupportedFeedtypeException(String message) { + this.message = message; + type = Type.INVALID; + } public TypeGetter.Type getType() { - return type; - } + return type; + } public String getRootElement() { return rootElement; } @Override - public String getMessage() { - if (message != null) { - return message; - } else if (type == TypeGetter.Type.INVALID) { - return "Invalid type"; - } else { - return "Type " + type + " not supported"; - } - } - - + public String getMessage() { + if (message != null) { + return message; + } else if (type == TypeGetter.Type.INVALID) { + return "Invalid type"; + } else { + return "Type " + type + " not supported"; + } + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java index c98c2d82a..1e0cd2d9b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java @@ -1,21 +1,22 @@ package de.danoeh.antennapod.core.util; -/** Thrown if a feed has invalid attribute values. */ +/** + * Thrown if a feed has invalid attribute values. + */ public class InvalidFeedException extends Exception { - public InvalidFeedException() { - } + public InvalidFeedException() { + } - public InvalidFeedException(String detailMessage) { - super(detailMessage); - } + public InvalidFeedException(String message) { + super(message); + } - public InvalidFeedException(Throwable throwable) { - super(throwable); - } - - public InvalidFeedException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } + public InvalidFeedException(Throwable cause) { + super(cause); + } + public InvalidFeedException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java b/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java index 3000e2fa4..f9e2e9991 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java @@ -3,16 +3,16 @@ package de.danoeh.antennapod.core.util.exception; import de.danoeh.antennapod.core.feed.FeedMedia; public class MediaFileNotFoundException extends Exception { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private final FeedMedia media; + private final FeedMedia media; - public MediaFileNotFoundException(String msg, FeedMedia media) { - super(msg); - this.media = media; - } + public MediaFileNotFoundException(String msg, FeedMedia media) { + super(msg); + this.media = media; + } - public FeedMedia getMedia() { - return media; - } + public FeedMedia getMedia() { + return media; + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java index 0c746d7e5..35f009d2d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java @@ -2,19 +2,18 @@ package de.danoeh.antennapod.core.util.id3reader; public class ID3ReaderException extends Exception { - public ID3ReaderException() { - } + public ID3ReaderException() { + } - public ID3ReaderException(String arg0) { - super(arg0); - } + public ID3ReaderException(String message) { + super(message); + } - public ID3ReaderException(Throwable arg0) { - super(arg0); - } - - public ID3ReaderException(String arg0, Throwable arg1) { - super(arg0, arg1); - } + public ID3ReaderException(Throwable message) { + super(message); + } + public ID3ReaderException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java b/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java index 89ab20db0..d7839a803 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java @@ -1,24 +1,20 @@ package de.danoeh.antennapod.core.util.vorbiscommentreader; + public class VorbisCommentReaderException extends Exception { - public VorbisCommentReaderException() { - super(); - // TODO Auto-generated constructor stub - } + public VorbisCommentReaderException() { + super(); + } - public VorbisCommentReaderException(String arg0, Throwable arg1) { - super(arg0, arg1); - // TODO Auto-generated constructor stub - } + public VorbisCommentReaderException(String message, Throwable cause) { + super(message, cause); + } - public VorbisCommentReaderException(String arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - public VorbisCommentReaderException(Throwable arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } + public VorbisCommentReaderException(String message) { + super(message); + } + public VorbisCommentReaderException(Throwable message) { + super(message); + } } From 28c7858387611db17d7225122c052f14868dc28c Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Sun, 21 Jul 2019 23:37:01 -0400 Subject: [PATCH 3/5] Add serialVersionUID to all exceptions For more info, see [1]. [1]: https://stackoverflow.com/questions/146715/use-the-serialversionuid-or-suppress-warnings --- .../de/test/antennapod/util/service/download/NanoHTTPD.java | 1 + .../core/gpoddernet/GpodnetServiceAuthenticationException.java | 1 + .../core/gpoddernet/GpodnetServiceBadStatusCodeException.java | 2 ++ .../antennapod/core/gpoddernet/GpodnetServiceException.java | 1 + .../antennapod/core/storage/DownloadRequestException.java | 1 + .../de/danoeh/antennapod/core/util/InvalidFeedException.java | 1 + .../antennapod/core/util/id3reader/ID3ReaderException.java | 1 + .../util/vorbiscommentreader/VorbisCommentReaderException.java | 1 + 8 files changed, 9 insertions(+) diff --git a/app/src/androidTest/java/de/test/antennapod/util/service/download/NanoHTTPD.java b/app/src/androidTest/java/de/test/antennapod/util/service/download/NanoHTTPD.java index 61ff65809..8d9cedbd1 100644 --- a/app/src/androidTest/java/de/test/antennapod/util/service/download/NanoHTTPD.java +++ b/app/src/androidTest/java/de/test/antennapod/util/service/download/NanoHTTPD.java @@ -776,6 +776,7 @@ public abstract class NanoHTTPD { } public static final class ResponseException extends Exception { + private static final long serialVersionUID = 1L; private final Response.Status status; diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java index 2f9c6b54c..1127d0b67 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceAuthenticationException.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.core.gpoddernet; public class GpodnetServiceAuthenticationException extends GpodnetServiceException { + private static final long serialVersionUID = 1L; public GpodnetServiceAuthenticationException() { super(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java index 3592cbc5a..54c3bc7c8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceBadStatusCodeException.java @@ -1,6 +1,8 @@ package de.danoeh.antennapod.core.gpoddernet; class GpodnetServiceBadStatusCodeException extends GpodnetServiceException { + private static final long serialVersionUID = 1L; + private final int statusCode; public GpodnetServiceBadStatusCodeException(String message, int statusCode) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceException.java b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceException.java index 78ddfc945..7b99ddbc4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/gpoddernet/GpodnetServiceException.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.core.gpoddernet; public class GpodnetServiceException extends Exception { + private static final long serialVersionUID = 1L; GpodnetServiceException() { } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java index 35b41d0d2..f152ec531 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequestException.java @@ -5,6 +5,7 @@ package de.danoeh.antennapod.core.storage; * or something went wrong while processing the request. */ public class DownloadRequestException extends Exception { + private static final long serialVersionUID = 1L; public DownloadRequestException() { super(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java index 1e0cd2d9b..a2795194d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java @@ -4,6 +4,7 @@ package de.danoeh.antennapod.core.util; * Thrown if a feed has invalid attribute values. */ public class InvalidFeedException extends Exception { + private static final long serialVersionUID = 1L; public InvalidFeedException() { } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java index 35f009d2d..021268adb 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.core.util.id3reader; public class ID3ReaderException extends Exception { + private static final long serialVersionUID = 1L; public ID3ReaderException() { } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java b/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java index d7839a803..8b0f3052b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/vorbiscommentreader/VorbisCommentReaderException.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.core.util.vorbiscommentreader; public class VorbisCommentReaderException extends Exception { + private static final long serialVersionUID = 1L; public VorbisCommentReaderException() { super(); From fd0cac5957a9d3da83c86fe4cc25cdd6e2609332 Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Mon, 22 Jul 2019 18:34:01 -0400 Subject: [PATCH 4/5] Fix deprecation warning Original class: https://github.com/jhy/jsoup/blob/9e36f9e/src/main/java/org/jsoup/examples/HtmlToPlainText.java --- .../antennapod/core/util/syndication/HtmlToPlainText.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 cc6a8ec90..61072f1ad 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 @@ -33,8 +33,8 @@ public class HtmlToPlainText { */ public String getPlainText(Element element) { FormattingVisitor formatter = new FormattingVisitor(); - NodeTraversor traversor = new NodeTraversor(formatter); - traversor.traverse(element); // walk the DOM, and call .head() and .tail() for each node + // walk the DOM, and call .head() and .tail() for each node + NodeTraversor.traverse(formatter, element); return formatter.toString(); } From ba4a7dd865e8d0fe92cf0035dde31ff6aeff193c Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Mon, 22 Jul 2019 18:45:11 -0400 Subject: [PATCH 5/5] Fix deprecation warning --- .../de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java b/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java index f63c9aeb0..8b2d4eb98 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.core.menuhandler; -import android.support.v4.view.MenuItemCompat; import android.view.Menu; import android.view.MenuItem; @@ -25,7 +24,7 @@ public class MenuItemUtils { // expand actionview if feeds are being downloaded, collapse otherwise if (checker.isRefreshing()) { MenuItem refreshItem = menu.findItem(resId); - MenuItemCompat.setActionView(refreshItem, R.layout.refresh_action_view); + refreshItem.setActionView(R.layout.refresh_action_view); return true; } else { return false;