diff --git a/app/build.gradle b/app/build.gradle index 486502cd868..1cf1c34c0b5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,8 +5,8 @@ apply plugin: 'kotlin-kapt' apply plugin: 'checkstyle' android { - compileSdkVersion 29 - buildToolsVersion '29.0.3' + compileSdkVersion 30 + buildToolsVersion '30.0.2' defaultConfig { applicationId "org.schabi.newpipe" diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index cd4a04d9abe..afa2115844c 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -35,7 +35,6 @@ import java.io.InterruptedIOException; import java.net.SocketException; import java.util.Arrays; -import java.util.Collections; import java.util.List; import io.reactivex.rxjava3.disposables.Disposable; @@ -154,7 +153,7 @@ public void accept(@NonNull final Throwable throwable) { if (actualThrowable instanceof CompositeException) { errors = ((CompositeException) actualThrowable).getExceptions(); } else { - errors = Collections.singletonList(actualThrowable); + errors = List.of(actualThrowable); } for (final Throwable error : errors) { diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 68bcf3cc1e2..35516d02273 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -61,7 +61,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Locale; @@ -594,7 +593,7 @@ private void showFailedDialog(@StringRes final int msg) { private void showErrorActivity(final Exception e) { ErrorActivity.reportError( context, - Collections.singletonList(e), + List.of(e), null, null, ErrorInfo diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index f876b767c3c..fb3d73646d1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -29,7 +29,6 @@ import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.InfoCache; -import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -253,8 +252,7 @@ public void onReCaptchaException(final ReCaptchaException exception) { public void onUnrecoverableError(final Throwable exception, final UserAction userAction, final String serviceName, final String request, @StringRes final int errorId) { - onUnrecoverableError(Collections.singletonList(exception), userAction, serviceName, - request, errorId); + onUnrecoverableError(List.of(exception), userAction, serviceName, request, errorId); } public void onUnrecoverableError(final List exception, final UserAction userAction, @@ -272,8 +270,7 @@ public void onUnrecoverableError(final List exception, final UserActi public void showSnackBarError(final Throwable exception, final UserAction userAction, final String serviceName, final String request, @StringRes final int errorId) { - showSnackBarError(Collections.singletonList(exception), userAction, serviceName, request, - errorId); + showSnackBarError(List.of(exception), userAction, serviceName, request, errorId); } /** diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 93e1141c7ff..a83a911a200 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -25,7 +25,6 @@ import org.schabi.newpipe.util.OnClickGesture; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; @@ -59,7 +58,7 @@ public static Disposable onPlaylistFound( public static PlaylistAppendDialog fromStreamInfo(final StreamInfo info) { final PlaylistAppendDialog dialog = new PlaylistAppendDialog(); - dialog.setInfo(Collections.singletonList(new StreamEntity(info))); + dialog.setInfo(List.of(new StreamEntity(info))); return dialog; } diff --git a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java index f9aa38054eb..8eb73ba7459 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java @@ -453,7 +453,7 @@ private PlayQueue getPlayQueue() { private PlayQueue getPlayQueue(final int index) { if (itemListAdapter == null) { - return new SinglePlayQueue(Collections.emptyList(), 0); + return new SinglePlayQueue(List.of(), 0); } final List infoItems = itemListAdapter.getItemsList(); diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 3137de9e6f7..447c5918e24 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -803,7 +803,7 @@ private PlayQueue getPlayQueue() { private PlayQueue getPlayQueue(final int index) { if (itemListAdapter == null) { - return new SinglePlayQueue(Collections.emptyList(), 0); + return new SinglePlayQueue(List.of(), 0); } final List infoItems = itemListAdapter.getItemsList(); diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java index d7a1051e634..20204909e8f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java @@ -33,7 +33,6 @@ import org.schabi.newpipe.util.FilePickerActivityHelper; import org.schabi.newpipe.util.ServiceHelper; -import java.util.Collections; import java.util.List; import icepick.State; @@ -84,7 +83,7 @@ public void onCreate(final Bundle savedInstanceState) { setupServiceVariables(); if (supportedSources.isEmpty() && currentServiceId != Constants.NO_SERVICE_ID) { - ErrorActivity.reportError(activity, Collections.emptyList(), null, null, + ErrorActivity.reportError(activity, List.of(), null, null, ErrorInfo.make(UserAction.SOMETHING_ELSE, NewPipe.getNameOfService(currentServiceId), "Service don't support importing", R.string.general_error)); @@ -211,7 +210,7 @@ private void setupServiceVariables() { } } - supportedSources = Collections.emptyList(); + supportedSources = List.of(); relatedUrl = null; instructionsString = 0; } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/services/BaseImportExportService.java b/app/src/main/java/org/schabi/newpipe/local/subscription/services/BaseImportExportService.java index f573f4679a1..5459ccaff16 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/services/BaseImportExportService.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/services/BaseImportExportService.java @@ -43,7 +43,7 @@ import org.schabi.newpipe.report.UserAction; import java.io.FileNotFoundException; -import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -157,8 +157,8 @@ protected void stopAndReportError(@Nullable final Throwable error, final String final ErrorInfo errorInfo = ErrorInfo .make(UserAction.SUBSCRIPTION, "unknown", request, R.string.general_error); - ErrorActivity.reportError(this, error != null ? Collections.singletonList(error) - : Collections.emptyList(), null, null, errorInfo); + ErrorActivity.reportError(this, error != null ? List.of(error) : List.of(), + null, null, errorInfo); } protected void postErrorResult(final String title, final String text) { diff --git a/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java b/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java index d757a926844..a2ef6730b58 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java @@ -41,7 +41,6 @@ import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.ThemeHelper; -import java.util.Collections; import java.util.List; import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed; @@ -305,7 +304,7 @@ private void buildItemPopupMenu(final PlayQueueItem item, final View view) { final MenuItem append = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 2, Menu.NONE, R.string.append_playlist); append.setOnMenuItemClickListener(menuItem -> { - openPlaylistAppendDialog(Collections.singletonList(item)); + openPlaylistAppendDialog(List.of(item)); return true; }); diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java b/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java index 62664c8270d..120f6e15c3f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasession/PlayQueueNavigator.java @@ -13,7 +13,6 @@ import com.google.android.exoplayer2.util.Util; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import static android.support.v4.media.session.PlaybackStateCompat.ACTION_SKIP_TO_NEXT; @@ -81,7 +80,7 @@ public void onSkipToNext(final Player player, final ControlDispatcher controlDis private void publishFloatingQueueWindow() { if (callback.getQueueSize() == 0) { - mediaSession.setQueue(Collections.emptyList()); + mediaSession.setQueue(List.of()); activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID; return; } diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java index 07c8d9f90b4..7bbd4651126 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/AbstractInfoPlayQueue.java @@ -11,7 +11,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import io.reactivex.rxjava3.core.SingleObserver; @@ -28,7 +27,7 @@ abstract class AbstractInfoPlayQueue ext private transient Disposable fetchReactor; AbstractInfoPlayQueue(final U item) { - this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0); + this(item.getServiceId(), item.getUrl(), null, List.of(), 0); } AbstractInfoPlayQueue(final int serviceId, final String url, final Page nextPage, diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/SinglePlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/SinglePlayQueue.java index 527e804703c..e5117321407 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/SinglePlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/SinglePlayQueue.java @@ -4,20 +4,19 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public final class SinglePlayQueue extends PlayQueue { public SinglePlayQueue(final StreamInfoItem item) { - super(0, Collections.singletonList(new PlayQueueItem(item))); + super(0, List.of(new PlayQueueItem(item))); } public SinglePlayQueue(final StreamInfo info) { - super(0, Collections.singletonList(new PlayQueueItem(info))); + super(0, List.of(new PlayQueueItem(info))); } public SinglePlayQueue(final StreamInfo info, final long startPosition) { - super(0, Collections.singletonList(new PlayQueueItem(info))); + super(0, List.of(new PlayQueueItem(info))); getItem().setRecoveryPosition(startPosition); } diff --git a/app/src/main/java/org/schabi/newpipe/player/resolver/MediaSourceTag.java b/app/src/main/java/org/schabi/newpipe/player/resolver/MediaSourceTag.java index 360e92e7fcc..bfb8dcec667 100644 --- a/app/src/main/java/org/schabi/newpipe/player/resolver/MediaSourceTag.java +++ b/app/src/main/java/org/schabi/newpipe/player/resolver/MediaSourceTag.java @@ -7,7 +7,6 @@ import org.schabi.newpipe.extractor.stream.VideoStream; import java.io.Serializable; -import java.util.Collections; import java.util.List; public class MediaSourceTag implements Serializable { @@ -27,7 +26,7 @@ public MediaSourceTag(@NonNull final StreamInfo metadata, } public MediaSourceTag(@NonNull final StreamInfo metadata) { - this(metadata, Collections.emptyList(), /*indexNotAvailable=*/-1); + this(metadata, List.of(), /*indexNotAvailable=*/-1); } @NonNull diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index e76af3944da..c361aa22794 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -41,7 +41,6 @@ import java.util.Date; import java.util.List; import java.util.TimeZone; -import java.util.Vector; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; @@ -118,25 +117,14 @@ private static void startErrorActivity(final Class returnActivity, final Context public static void reportError(final Context context, final Throwable e, final Class returnActivity, final View rootView, final ErrorInfo errorInfo) { - List el = null; - if (e != null) { - el = new Vector<>(); - el.add(e); - } - reportError(context, el, returnActivity, rootView, errorInfo); + reportError(context, List.of(e), returnActivity, rootView, errorInfo); } // async call public static void reportError(final Handler handler, final Context context, final Throwable e, final Class returnActivity, final View rootView, final ErrorInfo errorInfo) { - - List el = null; - if (e != null) { - el = new Vector<>(); - el.add(e); - } - reportError(handler, context, el, returnActivity, rootView, errorInfo); + reportError(handler, context, List.of(e), returnActivity, rootView, errorInfo); } // async call diff --git a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java index 6ee69dcd9a4..86dfdefc959 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ExtractorHelper.java @@ -62,7 +62,6 @@ import org.schabi.newpipe.report.ErrorInfo; import org.schabi.newpipe.report.UserAction; -import java.util.Collections; import java.util.List; import io.reactivex.rxjava3.core.Maybe; @@ -115,9 +114,7 @@ public static Single> suggestionsFor(final int serviceId, final Str return Single.fromCallable(() -> { final SuggestionExtractor extractor = NewPipe.getService(serviceId) .getSuggestionExtractor(); - return extractor != null - ? extractor.suggestionList(query) - : Collections.emptyList(); + return extractor != null ? extractor.suggestionList(query) : List.of(); }); } diff --git a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java index dcc39eccf6d..17fcd3bad44 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PeertubeHelper.java @@ -17,7 +17,6 @@ import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public final class PeertubeHelper { @@ -29,7 +28,7 @@ public static List getInstanceList(final Context context) { final String savedInstanceListKey = context.getString(R.string.peertube_instance_list_key); final String savedJson = sharedPreferences.getString(savedInstanceListKey, null); if (null == savedJson) { - return Collections.singletonList(getCurrentInstance()); + return List.of(getCurrentInstance()); } try { @@ -45,9 +44,8 @@ public static List getInstanceList(final Context context) { } return result; } catch (final JsonParserException e) { - return Collections.singletonList(getCurrentInstance()); + return List.of(getCurrentInstance()); } - } public static PeertubeInstance selectInstance(final PeertubeInstance instance, diff --git a/app/src/main/java/org/schabi/newpipe/util/RelatedStreamInfo.java b/app/src/main/java/org/schabi/newpipe/util/RelatedStreamInfo.java index 81e203b1f3b..7098f89ab9b 100644 --- a/app/src/main/java/org/schabi/newpipe/util/RelatedStreamInfo.java +++ b/app/src/main/java/org/schabi/newpipe/util/RelatedStreamInfo.java @@ -6,7 +6,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfo; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class RelatedStreamInfo extends ListInfo { @@ -17,7 +16,7 @@ public RelatedStreamInfo(final int serviceId, final ListLinkHandler listUrlIdHan public static RelatedStreamInfo getInfo(final StreamInfo info) { final ListLinkHandler handler = new ListLinkHandler( - info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null); + info.getOriginalUrl(), info.getUrl(), info.getId(), List.of(), null); final RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo( info.getServiceId(), handler, info.getName()); final List streams = new ArrayList<>(info.getRelatedStreams()); diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java index 73fee32f7f5..f0cfdefda0a 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java +++ b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java @@ -13,7 +13,6 @@ import org.schabi.newpipe.player.helper.PlayerHolder; import org.schabi.newpipe.player.playqueue.SinglePlayQueue; -import java.util.Collections; import java.util.List; import static org.schabi.newpipe.player.MainPlayer.PlayerType.AUDIO; @@ -60,8 +59,7 @@ public enum StreamDialogEntry { append_playlist(R.string.append_playlist, (fragment, item) -> { if (fragment.getFragmentManager() != null) { - final PlaylistAppendDialog d = PlaylistAppendDialog - .fromStreamInfoItems(Collections.singletonList(item)); + final PlaylistAppendDialog d = PlaylistAppendDialog.fromStreamInfoItems(List.of(item)); PlaylistAppendDialog.onPlaylistFound(fragment.getContext(), () -> d.show(fragment.getFragmentManager(), "StreamDialogEntry@append_playlist"), diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java b/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java index 9150b5c1a69..e79adfe6689 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java @@ -19,7 +19,6 @@ import java.io.Serializable; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; @@ -178,15 +177,13 @@ private View getCustomView(final int position, final View view, final ViewGroup */ public static class StreamSizeWrapper implements Serializable { private static final StreamSizeWrapper EMPTY = new StreamSizeWrapper<>( - Collections.emptyList(), null); + List.of(), null); private final List streamsList; private final long[] streamSizes; private final String unknownSize; public StreamSizeWrapper(final List sL, final Context context) { - this.streamsList = sL != null - ? sL - : Collections.emptyList(); + this.streamsList = sL != null ? sL : List.of(); this.streamSizes = new long[streamsList.size()]; this.unknownSize = context == null ? "--.-" : context.getString(R.string.unknown_content);