Make AntennaPod pass the medium SpotBugs findings
This commit is contained in:
parent
b1e15e8704
commit
998535515b
|
@ -53,6 +53,9 @@ public class ViewPagerBottomSheetBehavior<V extends View> extends BottomSheetBeh
|
|||
}
|
||||
|
||||
public void updateScrollingChild() {
|
||||
if (viewRef == null) {
|
||||
return;
|
||||
}
|
||||
final View scrollingChild = findScrollingChild(viewRef.get());
|
||||
nestedScrollingChildRef = new WeakReference<>(scrollingChild);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,10 @@ public class BugReportActivity extends AppCompatActivity {
|
|||
private void exportLog() {
|
||||
try {
|
||||
File filename = new File(UserPreferences.getDataFolder(null), "full-logs.txt");
|
||||
filename.createNewFile();
|
||||
boolean success = filename.createNewFile();
|
||||
if (!success) {
|
||||
throw new IOException("Unable to create output file");
|
||||
}
|
||||
String cmd = "logcat -d -f " + filename.getAbsolutePath();
|
||||
Runtime.getRuntime().exec(cmd);
|
||||
//share file
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.danoeh.antennapod.activity;
|
|||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -479,7 +478,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
cardViewSeek = findViewById(R.id.cardViewSeek);
|
||||
txtvSeek = findViewById(R.id.txtvSeek);
|
||||
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
|
||||
showTimeLeft = UserPreferences.shouldShowRemainingTime();
|
||||
Log.d("timeleft", showTimeLeft ? "true" : "false");
|
||||
txtvLength = findViewById(R.id.txtvLength);
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.net.Uri;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
@ -37,9 +36,6 @@ public class DocumentFileExportWorker {
|
|||
OutputStreamWriter writer = null;
|
||||
try {
|
||||
Uri uri = output.getUri();
|
||||
if (uri == null) {
|
||||
throw new FileNotFoundException("Export file not found.");
|
||||
}
|
||||
outputStream = context.getContentResolver().openOutputStream(uri);
|
||||
if (outputStream == null) {
|
||||
throw new IOException();
|
||||
|
|
|
@ -41,8 +41,8 @@ public class ExportWorker {
|
|||
|
||||
public Observable<File> exportObservable() {
|
||||
if (output.exists()) {
|
||||
Log.w(TAG, "Overwriting previously exported file.");
|
||||
output.delete();
|
||||
boolean success = output.delete();
|
||||
Log.w(TAG, "Overwriting previously exported file: " + success);
|
||||
}
|
||||
return Observable.create(subscriber -> {
|
||||
OutputStreamWriter writer = null;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.danoeh.antennapod.discovery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
|
@ -24,8 +23,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
public class ItunesTopListLoader {
|
||||
private static final String TAG = "ITunesTopListLoader";
|
||||
private final Context context;
|
||||
|
@ -38,13 +35,6 @@ public class ItunesTopListLoader {
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
public Single<List<PodcastSearchResult>> loadToplist() {
|
||||
String defaultCountry = Locale.getDefault().getCountry();
|
||||
SharedPreferences prefs = context.getSharedPreferences(PREFS, MODE_PRIVATE);
|
||||
String countryCode = prefs.getString(PREF_KEY_COUNTRY_CODE, COUNTRY_CODE_UNSET);
|
||||
return this.loadToplist(countryCode, 25);
|
||||
}
|
||||
|
||||
public Single<List<PodcastSearchResult>> loadToplist(String country, int limit) {
|
||||
return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) emitter -> {
|
||||
OkHttpClient client = AntennapodHttpClient.getHttpClient();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
@ -14,12 +15,12 @@ public abstract class PagedToolbarFragment extends Fragment {
|
|||
|
||||
/**
|
||||
* Invalidate the toolbar menu if the current child fragment is visible.
|
||||
* @param child The fragment, or null to force-refresh whatever the active fragment is.
|
||||
* @param child The fragment to invalidate
|
||||
*/
|
||||
void invalidateOptionsMenuIfActive(Fragment child) {
|
||||
void invalidateOptionsMenuIfActive(@NonNull Fragment child) {
|
||||
Fragment visibleChild = getChildFragmentManager().findFragmentByTag("f" + viewPager.getCurrentItem());
|
||||
if (visibleChild == child || child == null) {
|
||||
child.onPrepareOptionsMenu(toolbar.getMenu());
|
||||
if (visibleChild == child) {
|
||||
visibleChild.onPrepareOptionsMenu(toolbar.getMenu());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -291,6 +291,9 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem
|
|||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if (menuInfo == null) {
|
||||
return;
|
||||
}
|
||||
AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
||||
int position = adapterInfo.position;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ allprojects {
|
|||
|
||||
spotbugs {
|
||||
effort = 'max'
|
||||
reportLevel = 'high' // for now
|
||||
reportLevel = 'medium'
|
||||
excludeFilter = rootProject.file('config/spotbugs/exclude.xml')
|
||||
ignoreFailures = true // Handled by printing task
|
||||
}
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<FindBugsFilter>
|
||||
<Match>
|
||||
<Bug pattern="BC_UNCONFIRMED_CAST"/>
|
||||
<Class name="de.danoeh.antennapod.adapter.NavListAdapter"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
|
||||
<Class name="de.danoeh.antennapod.net.ssl.NoV1SslSocketFactory"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="DM_DEFAULT_ENCODING"/>
|
||||
<Class name="de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentReader"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_MUTABLE_ARRAY"/>
|
||||
<Class name="de.danoeh.antennapod.fragment.NavDrawerFragment"/>
|
||||
<Bug pattern="HSC_HUGE_SHARED_STRING_CONSTANT"/>
|
||||
<Class name="de.danoeh.antennapod.net.ssl.BackportCaCerts"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_SHOULD_BE_FINAL"/>
|
||||
<Class name="de.danoeh.antennapod.core.ClientConfig"/>
|
||||
<Bug pattern="MS_CANNOT_BE_FINAL"/>
|
||||
<Class name="de.danoeh.antennapod.core.service.playback.PlaybackService"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_MUTABLE_ARRAY"/>
|
||||
<Class name="de.danoeh.antennapod.fragment.NavDrawerFragment"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
|
||||
|
@ -28,12 +40,58 @@
|
|||
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
|
||||
<Class name="de.danoeh.antennapod.core.feed.FeedMedia"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
|
||||
<Class name="de.danoeh.antennapod.dialog.PlaybackControlsDialog"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_PARAM_DEREF"/>
|
||||
<Class name="de.danoeh.antennapod.core.feed.FeedMedia"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
|
||||
<Class name="de.danoeh.antennapod.preferences.PreferenceUpgrader"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
|
||||
<Class name="de.danoeh.antennapod.PodcastApp"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
|
||||
<Class name="de.danoeh.antennapod.core.service.download.DownloadService"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
|
||||
<Class name="de.danoeh.antennapod.core.service.playback.PlaybackService"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
|
||||
<Class name="de.danoeh.antennapod.core.storage.NavDrawerData$FolderDrawerItem"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
|
||||
<Class name="de.danoeh.antennapod.core.cast.CastButtonVisibilityManager"/>
|
||||
</Match>
|
||||
|
||||
<Match><Class name="de.danoeh.antennapod.core.ClientConfig"/></Match>
|
||||
|
||||
<Match><Package name="de.danoeh.antennapod.core.glide"/></Match>
|
||||
<Match><Package name="de.danoeh.antennapod.databinding"/></Match>
|
||||
|
||||
<Match><Bug pattern="EI_EXPOSE_REP"/></Match>
|
||||
<Match><Bug pattern="EI_EXPOSE_REP2"/></Match>
|
||||
<Match><Bug pattern="HE_EQUALS_NO_HASHCODE"/></Match>
|
||||
<Match><Bug pattern="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG"/></Match>
|
||||
<Match><Bug pattern="IS2_INCONSISTENT_SYNC"/></Match>
|
||||
<Match><Bug pattern="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION"/></Match>
|
||||
<Match><Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/></Match>
|
||||
<Match><Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE"/></Match>
|
||||
<Match><Bug pattern="OS_OPEN_STREAM"/></Match>
|
||||
<Match><Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/></Match>
|
||||
<Match><Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN"/></Match>
|
||||
<Match><Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/></Match>
|
||||
<Match><Bug pattern="RV_RETURN_VALUE_IGNORED"/></Match>
|
||||
<Match><Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/></Match>
|
||||
<Match><Bug pattern="SE_NO_SERIALVERSIONID"/></Match>
|
||||
<Match><Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/></Match>
|
||||
<Match><Bug pattern="SF_SWITCH_NO_DEFAULT"/></Match>
|
||||
<Match><Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/></Match>
|
||||
<Match><Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/></Match>
|
||||
<Match><Bug pattern="WMI_WRONG_MAP_ITERATOR"/></Match>
|
||||
</FindBugsFilter>
|
||||
|
|
|
@ -94,7 +94,7 @@ public class OpmlBackupAgent extends BackupAgentHelper {
|
|||
|
||||
if (len != -1) {
|
||||
byte[] oldChecksum = new byte[len];
|
||||
inState.read(oldChecksum);
|
||||
IOUtils.read(inState, oldChecksum, 0, len);
|
||||
Log.d(TAG, "Old checksum: " + new BigInteger(1, oldChecksum).toString(16));
|
||||
|
||||
if (Arrays.equals(oldChecksum, newChecksum)) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public abstract class Chapter extends FeedComponent {
|
|||
String imageUrl = cursor.getString(indexImage);
|
||||
int chapterType = cursor.getInt(indexChapterType);
|
||||
|
||||
Chapter chapter = null;
|
||||
Chapter chapter;
|
||||
switch (chapterType) {
|
||||
case SimpleChapter.CHAPTERTYPE_SIMPLECHAPTER:
|
||||
chapter = new SimpleChapter(start, title, link, imageUrl);
|
||||
|
@ -54,6 +54,8 @@ public abstract class Chapter extends FeedComponent {
|
|||
case VorbisCommentChapter.CHAPTERTYPE_VORBISCOMMENT_CHAPTER:
|
||||
chapter = new VorbisCommentChapter(start, title, link, imageUrl);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown chapter type");
|
||||
}
|
||||
chapter.setId(id);
|
||||
return chapter;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FeedItem extends FeedComponent implements Serializable {
|
|||
* The list of chapters of this item. This might be null even if there are chapters of this item
|
||||
* in the database. The 'hasChapters' attribute should be used to check if this item has any chapters.
|
||||
* */
|
||||
private List<Chapter> chapters;
|
||||
private transient List<Chapter> chapters;
|
||||
private String imageUrl;
|
||||
|
||||
/*
|
||||
|
|
|
@ -188,8 +188,11 @@ public class HttpDownloader extends Downloader {
|
|||
out = new RandomAccessFile(destination, "rw");
|
||||
out.seek(request.getSoFar());
|
||||
} else {
|
||||
destination.delete();
|
||||
destination.createNewFile();
|
||||
boolean success = destination.delete();
|
||||
success |= destination.createNewFile();
|
||||
if (!success) {
|
||||
throw new IOException("Unable to recreate partially downloaded file");
|
||||
}
|
||||
out = new RandomAccessFile(destination, "rw");
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
|||
* could result in nonsensical results (like a status of PLAYING, but a null playable)
|
||||
* @return the current player status
|
||||
*/
|
||||
public PlayerStatus getPlayerStatus() {
|
||||
public synchronized PlayerStatus getPlayerStatus() {
|
||||
return playerStatus;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,10 @@ public class DatabaseExporter {
|
|||
db.close();
|
||||
|
||||
File currentDB = context.getDatabasePath(PodDBAdapter.DATABASE_NAME);
|
||||
currentDB.delete();
|
||||
boolean success = currentDB.delete();
|
||||
if (!success) {
|
||||
throw new IOException("Unable to delete old database");
|
||||
}
|
||||
FileUtils.moveFile(tempDB, currentDB);
|
||||
} catch (IOException | SQLiteException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
|
|
|
@ -331,7 +331,7 @@ public class PodDBAdapter {
|
|||
PodDBAdapter.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static PodDBAdapter getInstance() {
|
||||
public static synchronized PodDBAdapter getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PodDBAdapter();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ public class CastUtils {
|
|||
public static final String KEY_FEED_URL = "de.danoeh.antennapod.core.cast.FeedUrl";
|
||||
public static final String KEY_FEED_WEBSITE = "de.danoeh.antennapod.core.cast.FeedWebsite";
|
||||
public static final String KEY_EPISODE_NOTES = "de.danoeh.antennapod.core.cast.EpisodeNotes";
|
||||
public static final int EPISODE_NOTES_MAX_LENGTH = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* The field <code>AntennaPod.FormatVersion</code> specifies which version of MediaMetaData
|
||||
|
|
|
@ -39,9 +39,6 @@ public class MediaInfoCreator {
|
|||
}
|
||||
String notes = media.getNotes();
|
||||
if (notes != null) {
|
||||
if (notes.length() > CastUtils.EPISODE_NOTES_MAX_LENGTH) {
|
||||
notes = notes.substring(0, CastUtils.EPISODE_NOTES_MAX_LENGTH);
|
||||
}
|
||||
metadata.putString(CastUtils.KEY_EPISODE_NOTES, notes);
|
||||
}
|
||||
// Default id value
|
||||
|
|
|
@ -6,10 +6,12 @@ import javax.net.ssl.TrustManager;
|
|||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -52,7 +54,7 @@ public class BackportTrustManager {
|
|||
managers.add(getSystemTrustManager(keystore));
|
||||
managers.add(getSystemTrustManager(null));
|
||||
return new CompositeX509TrustManager(managers);
|
||||
} catch (Exception e) {
|
||||
} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue