From d30651331922db62cd13371e79a42bfb39102fea Mon Sep 17 00:00:00 2001
From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com>
Date: Sun, 16 Aug 2020 08:42:56 +0200
Subject: [PATCH 1/2] Add checkstyle rule to show final local variable
violations as warning
---
checkstyle.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/checkstyle.xml b/checkstyle.xml
index c61b92247..af8c5480f 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -154,6 +154,10 @@
+
+
+
+
From 87228673b45225a57b53937ab2c9715d7bf205ca Mon Sep 17 00:00:00 2001
From: wb9688
Date: Sun, 16 Aug 2020 10:24:58 +0200
Subject: [PATCH 2/2] Use final where possible
---
.../schabi/newpipe/report/ErrorInfoTest.java | 6 +-
...agmentStatePagerAdapterMenuWorkaround.java | 28 +++---
.../material/appbar/FlingBehavior.java | 28 +++---
app/src/main/java/org/schabi/newpipe/App.java | 12 +--
.../newpipe/CheckForNewAppVersionTask.java | 10 +--
.../org/schabi/newpipe/DownloaderImpl.java | 38 ++++-----
.../java/org/schabi/newpipe/ExitActivity.java | 2 +-
.../java/org/schabi/newpipe/MainActivity.java | 72 ++++++++--------
.../org/schabi/newpipe/NewPipeDatabase.java | 2 +-
.../newpipe/PanicResponderActivity.java | 2 +-
.../org/schabi/newpipe/ReCaptchaActivity.java | 20 ++---
.../org/schabi/newpipe/RouterActivity.java | 32 +++----
.../schabi/newpipe/about/AboutActivity.java | 20 ++---
.../schabi/newpipe/about/LicenseFragment.java | 4 +-
.../newpipe/about/LicenseFragmentHelper.java | 2 +-
.../schabi/newpipe/database/Converters.java | 2 +-
.../subscription/SubscriptionEntity.java | 4 +-
.../newpipe/download/DownloadActivity.java | 10 +--
.../newpipe/download/DownloadDialog.java | 56 ++++++------
.../newpipe/fragments/BaseStateFragment.java | 2 +-
.../newpipe/fragments/MainFragment.java | 8 +-
.../fragments/OnScrollBelowItemsListener.java | 8 +-
.../newpipe/fragments/detail/TabAdaptor.java | 2 +-
.../fragments/detail/VideoDetailFragment.java | 52 ++++++------
.../fragments/list/BaseListFragment.java | 10 +--
.../list/channel/ChannelFragment.java | 32 +++----
.../list/comments/CommentsFragment.java | 2 +-
.../list/kiosk/DefaultKioskFragment.java | 2 +-
.../fragments/list/kiosk/KioskFragment.java | 10 +--
.../list/playlist/PlaylistFragment.java | 8 +-
.../fragments/list/search/SearchFragment.java | 48 ++++++-----
.../list/search/SuggestionListAdapter.java | 6 +-
.../list/videos/RelatedVideosFragment.java | 8 +-
.../newpipe/info_list/InfoItemBuilder.java | 3 +-
.../newpipe/info_list/InfoItemDialog.java | 4 +-
.../newpipe/info_list/InfoListAdapter.java | 14 +--
.../holder/ChannelInfoItemHolder.java | 4 +-
.../holder/CommentsMiniInfoItemHolder.java | 15 ++--
.../holder/StreamMiniInfoItemHolder.java | 5 +-
.../newpipe/local/LocalItemListAdapter.java | 8 +-
.../local/bookmark/BookmarkFragment.java | 6 +-
.../local/dialog/PlaylistAppendDialog.java | 10 +--
.../local/dialog/PlaylistCreationDialog.java | 6 +-
.../local/history/HistoryRecordManager.java | 14 +--
.../history/StatisticsPlaylistFragment.java | 2 +-
.../holder/LocalPlaylistStreamItemHolder.java | 4 +-
.../LocalStatisticStreamItemHolder.java | 4 +-
.../local/playlist/LocalPlaylistFragment.java | 14 +--
.../local/playlist/LocalPlaylistManager.java | 6 +-
.../local/playlist/RemotePlaylistManager.java | 2 +-
.../SubscriptionsImportFragment.java | 6 +-
.../services/ImportExportJsonHelper.java | 16 ++--
.../services/SubscriptionsExportService.java | 4 +-
.../services/SubscriptionsImportService.java | 8 +-
.../org/schabi/newpipe/player/BasePlayer.java | 8 +-
.../newpipe/player/ServicePlayerActivity.java | 4 +-
.../schabi/newpipe/player/VideoPlayer.java | 24 +++---
.../newpipe/player/VideoPlayerImpl.java | 14 +--
.../player/event/PlayerGestureListener.java | 18 ++--
.../newpipe/player/helper/AudioReactor.java | 2 +-
.../newpipe/player/helper/CacheFactory.java | 4 +-
.../newpipe/player/helper/LoadController.java | 2 +-
.../player/helper/MediaSessionManager.java | 4 +-
.../helper/PlaybackParameterDialog.java | 20 ++---
.../newpipe/player/helper/PlayerHelper.java | 16 ++--
.../mediasession/PlayQueueNavigator.java | 10 +--
.../playback/BasePlayerMediaSession.java | 5 +-
.../player/playback/CustomTrackSelector.java | 8 +-
.../playqueue/AbstractInfoPlayQueue.java | 2 +-
.../player/playqueue/SinglePlayQueue.java | 2 +-
.../resolver/VideoPlaybackResolver.java | 2 +-
.../schabi/newpipe/report/ErrorActivity.java | 52 ++++++------
.../settings/AppearanceSettingsFragment.java | 4 +-
.../settings/BasePreferenceFragment.java | 2 +-
.../settings/ContentSettingsFragment.java | 58 ++++++-------
.../settings/DownloadSettingsFragment.java | 25 +++---
.../newpipe/settings/NewPipeSettings.java | 6 +-
.../PeertubeInstanceListFragment.java | 30 +++----
.../settings/SelectChannelFragment.java | 12 +--
.../newpipe/settings/SelectKioskFragment.java | 12 +--
.../settings/SelectPlaylistFragment.java | 2 +-
.../newpipe/settings/SettingsActivity.java | 8 +-
.../settings/UpdateSettingsFragment.java | 2 +-
.../settings/VideoAudioSettingsFragment.java | 8 +-
.../settings/tabs/ChooseTabsFragment.java | 12 +--
.../org/schabi/newpipe/settings/tabs/Tab.java | 4 +-
.../newpipe/settings/tabs/TabsJsonHelper.java | 6 +-
.../newpipe/settings/tabs/TabsManager.java | 2 +-
.../schabi/newpipe/streams/DataReader.java | 19 +++--
.../schabi/newpipe/streams/Mp4DashReader.java | 82 +++++++++---------
.../newpipe/streams/Mp4FromDashWriter.java | 85 ++++++++++---------
.../newpipe/streams/OggFromWebMWriter.java | 22 ++---
.../newpipe/streams/SrtFromTtmlWriter.java | 16 ++--
.../schabi/newpipe/streams/WebMReader.java | 38 ++++-----
.../schabi/newpipe/streams/WebMWriter.java | 71 ++++++++--------
.../schabi/newpipe/util/AnimationUtils.java | 12 +--
.../org/schabi/newpipe/util/BitmapUtils.java | 25 +++---
.../util/CommentTextOnTouchListener.java | 36 ++++----
.../org/schabi/newpipe/util/CookieUtils.java | 4 +-
.../org/schabi/newpipe/util/DeviceUtils.java | 5 +-
.../schabi/newpipe/util/ExtractorHelper.java | 12 +--
.../schabi/newpipe/util/FilenameUtils.java | 4 +-
.../org/schabi/newpipe/util/InfoCache.java | 2 +-
.../util/LayoutManagerSmoothScroller.java | 2 +-
.../org/schabi/newpipe/util/ListHelper.java | 77 +++++++++--------
.../org/schabi/newpipe/util/Localization.java | 30 +++----
.../schabi/newpipe/util/NavigationHelper.java | 44 +++++-----
.../schabi/newpipe/util/PeertubeHelper.java | 27 +++---
.../schabi/newpipe/util/PermissionHelper.java | 9 +-
.../newpipe/util/RelatedStreamInfo.java | 6 +-
.../newpipe/util/SecondaryStreamHelper.java | 6 +-
.../schabi/newpipe/util/ServiceHelper.java | 22 ++---
.../org/schabi/newpipe/util/ShareUtils.java | 2 +-
.../org/schabi/newpipe/util/StateSaver.java | 32 +++----
.../newpipe/util/StreamDialogEntry.java | 4 +-
.../newpipe/util/StreamItemAdapter.java | 11 +--
.../newpipe/util/TLSSocketFactoryCompat.java | 4 +-
.../org/schabi/newpipe/util/ThemeHelper.java | 28 +++---
.../org/schabi/newpipe/util/ZipHelper.java | 16 ++--
.../newpipe/views/AnimatedProgressBar.java | 2 +-
.../schabi/newpipe/views/CollapsibleView.java | 2 +-
.../newpipe/views/FocusAwareDrawerLayout.java | 10 ++-
.../newpipe/views/FocusOverlayView.java | 36 ++++----
.../views/LargeTextMovementMethod.java | 64 +++++++-------
.../newpipe/views/NewPipeRecyclerView.java | 12 +--
.../newpipe/views/ScrollableTabLayout.java | 2 +-
.../views/SuperScrollLayoutManager.java | 16 ++--
.../services/ImportExportJsonHelperTest.java | 18 ++--
.../schabi/newpipe/settings/tabs/TabTest.java | 2 +-
.../settings/tabs/TabsJsonHelperTest.java | 9 +-
.../schabi/newpipe/util/ListHelperTest.java | 8 +-
checkstyle-suppressions.xml | 2 +-
132 files changed, 1024 insertions(+), 1005 deletions(-)
diff --git a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java
index 55e747cd5..972737d25 100644
--- a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java
+++ b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java
@@ -21,13 +21,13 @@ public class ErrorInfoTest {
@Test
public void errorInfoTestParcelable() {
- ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
+ final ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request",
R.string.general_error);
// Obtain a Parcel object and write the parcelable object to it:
- Parcel parcel = Parcel.obtain();
+ final Parcel parcel = Parcel.obtain();
info.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
- ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
+ final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
assertEquals(UserAction.USER_REPORT, infoFromParcel.userAction);
assertEquals("youtube", infoFromParcel.serviceName);
diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java
index 11f457b6c..5840b0f7e 100644
--- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java
+++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java
@@ -150,7 +150,7 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
// from its saved state, where the fragment manager has already
// taken care of restoring the fragments we previously had instantiated.
if (mFragments.size() > position) {
- Fragment f = mFragments.get(position);
+ final Fragment f = mFragments.get(position);
if (f != null) {
return f;
}
@@ -160,12 +160,12 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
mCurTransaction = mFragmentManager.beginTransaction();
}
- Fragment fragment = getItem(position);
+ final Fragment fragment = getItem(position);
if (DEBUG) {
Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
}
if (mSavedState.size() > position) {
- Fragment.SavedState fss = mSavedState.get(position);
+ final Fragment.SavedState fss = mSavedState.get(position);
if (fss != null) {
fragment.setInitialSavedState(fss);
}
@@ -191,7 +191,7 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
@Override
public void destroyItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
- Fragment fragment = (Fragment) object;
+ final Fragment fragment = (Fragment) object;
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
@@ -217,7 +217,7 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
@SuppressWarnings({"ReferenceEquality", "deprecation"})
public void setPrimaryItem(@NonNull final ViewGroup container, final int position,
@NonNull final Object object) {
- Fragment fragment = (Fragment) object;
+ final Fragment fragment = (Fragment) object;
if (fragment != mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
mCurrentPrimaryItem.setMenuVisibility(false);
@@ -267,17 +267,17 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
Bundle state = null;
if (mSavedState.size() > 0) {
state = new Bundle();
- Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
+ final Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i = 0; i < mFragments.size(); i++) {
- Fragment f = mFragments.get(i);
+ final Fragment f = mFragments.get(i);
if (f != null && f.isAdded()) {
if (state == null) {
state = new Bundle();
}
- String key = "f" + i;
+ final String key = "f" + i;
mFragmentManager.putFragment(state, key, f);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -294,9 +294,9 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
@Override
public void restoreState(@Nullable final Parcelable state, @Nullable final ClassLoader loader) {
if (state != null) {
- Bundle bundle = (Bundle) state;
+ final Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
- Parcelable[] fss = bundle.getParcelableArray("states");
+ final Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
@@ -304,11 +304,11 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
mSavedState.add((Fragment.SavedState) fss[i]);
}
}
- Iterable keys = bundle.keySet();
- for (String key: keys) {
+ final Iterable keys = bundle.keySet();
+ for (final String key : keys) {
if (key.startsWith("f")) {
- int index = Integer.parseInt(key.substring(1));
- Fragment f = mFragmentManager.getFragment(bundle, key);
+ final int index = Integer.parseInt(key.substring(1));
+ final Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
diff --git a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java
index 90e5edcd3..174631fde 100644
--- a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java
+++ b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java
@@ -30,19 +30,18 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
public boolean onRequestChildRectangleOnScreen(
@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final AppBarLayout child,
@NonNull final Rect rectangle, final boolean immediate) {
-
focusScrollRect.set(rectangle);
coordinatorLayout.offsetDescendantRectToMyCoords(child, focusScrollRect);
- int height = coordinatorLayout.getHeight();
+ final int height = coordinatorLayout.getHeight();
if (focusScrollRect.top <= 0 && focusScrollRect.bottom >= height) {
// the child is too big to fit inside ourselves completely, ignore request
return false;
}
- int dy;
+ final int dy;
if (focusScrollRect.bottom > height) {
dy = focusScrollRect.top;
@@ -54,7 +53,7 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
return false;
}
- int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);
+ final int consumed = scroll(coordinatorLayout, child, dy, getMaxDragOffset(child), 0);
return consumed == dy;
}
@@ -106,14 +105,14 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
@Nullable
private OverScroller getScrollerField() {
try {
- Class> headerBehaviorType = this.getClass()
+ final Class> headerBehaviorType = this.getClass()
.getSuperclass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
- Field field = headerBehaviorType.getDeclaredField("scroller");
+ final Field field = headerBehaviorType.getDeclaredField("scroller");
field.setAccessible(true);
return ((OverScroller) field.get(this));
}
- } catch (NoSuchFieldException | IllegalAccessException e) {
+ } catch (final NoSuchFieldException | IllegalAccessException e) {
// ?
}
return null;
@@ -122,34 +121,35 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
@Nullable
private Field getLastNestedScrollingChildRefField() {
try {
- Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
+ final Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
if (headerBehaviorType != null) {
- Field field = headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
+ final Field field
+ = headerBehaviorType.getDeclaredField("lastNestedScrollingChildRef");
field.setAccessible(true);
return field;
}
- } catch (NoSuchFieldException e) {
+ } catch (final NoSuchFieldException e) {
// ?
}
return null;
}
private void resetNestedScrollingChild() {
- Field field = getLastNestedScrollingChildRefField();
+ final Field field = getLastNestedScrollingChildRefField();
if (field != null) {
try {
- Object value = field.get(this);
+ final Object value = field.get(this);
if (value != null) {
field.set(this, null);
}
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// ?
}
}
}
private void stopAppBarLayoutFling() {
- OverScroller scroller = getScrollerField();
+ final OverScroller scroller = getScrollerField();
if (scroller != null) {
scroller.forceFinished(true);
}
diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java
index 0071d2efe..00842ec46 100644
--- a/app/src/main/java/org/schabi/newpipe/App.java
+++ b/app/src/main/java/org/schabi/newpipe/App.java
@@ -104,7 +104,7 @@ public class App extends Application {
}
protected Downloader getDownloader() {
- DownloaderImpl downloader = DownloaderImpl.init(null);
+ final DownloaderImpl downloader = DownloaderImpl.init(null);
setCookiesToDownloader(downloader);
return downloader;
}
@@ -208,7 +208,7 @@ public class App extends Application {
.setBuildConfigClass(BuildConfig.class)
.build();
ACRA.init(this, acraConfig);
- } catch (ACRAConfigurationException ace) {
+ } catch (final ACRAConfigurationException ace) {
ace.printStackTrace();
ErrorActivity.reportError(this,
ace,
@@ -231,10 +231,10 @@ public class App extends Application {
// Keep this below DEFAULT to avoid making noise on every notification update
final int importance = NotificationManager.IMPORTANCE_LOW;
- NotificationChannel mChannel = new NotificationChannel(id, name, importance);
+ final NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription(description);
- NotificationManager mNotificationManager =
+ final NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(mChannel);
@@ -255,11 +255,11 @@ public class App extends Application {
final String appUpdateDescription
= getString(R.string.app_update_notification_channel_description);
- NotificationChannel appUpdateChannel
+ final NotificationChannel appUpdateChannel
= new NotificationChannel(appUpdateId, appUpdateName, importance);
appUpdateChannel.setDescription(appUpdateDescription);
- NotificationManager appUpdateNotificationManager
+ final NotificationManager appUpdateNotificationManager
= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
appUpdateNotificationManager.createNotificationChannel(appUpdateChannel);
}
diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java
index 625f514e9..0d211fdfd 100644
--- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java
+++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.java
@@ -62,7 +62,7 @@ public class CheckForNewAppVersionTask extends AsyncTask {
try {
packageInfo = pm.getPackageInfo(packageName, flags);
- } catch (PackageManager.NameNotFoundException e) {
+ } catch (final PackageManager.NameNotFoundException e) {
ErrorActivity.reportError(APP, e, null, null,
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
"Could not find package info", R.string.app_ui_crash));
@@ -77,7 +77,7 @@ public class CheckForNewAppVersionTask extends AsyncTask {
try {
final CertificateFactory cf = CertificateFactory.getInstance("X509");
c = (X509Certificate) cf.generateCertificate(input);
- } catch (CertificateException e) {
+ } catch (final CertificateException e) {
ErrorActivity.reportError(APP, e, null, null,
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
"Certificate error", R.string.app_ui_crash));
@@ -86,7 +86,7 @@ public class CheckForNewAppVersionTask extends AsyncTask {
String hexString = null;
try {
- MessageDigest md = MessageDigest.getInstance("SHA1");
+ final MessageDigest md = MessageDigest.getInstance("SHA1");
final byte[] publicKey = md.digest(c.getEncoded());
hexString = byte2HexFormatted(publicKey);
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
@@ -167,7 +167,7 @@ public class CheckForNewAppVersionTask extends AsyncTask {
compareAppVersionAndShowNotification(versionName, apkLocationUrl, versionCode);
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
// connectivity problems, do not alarm user and fail silently
if (DEBUG) {
Log.w(TAG, Log.getStackTraceString(e));
@@ -187,7 +187,7 @@ public class CheckForNewAppVersionTask extends AsyncTask {
private void compareAppVersionAndShowNotification(final String versionName,
final String apkLocationUrl,
final int versionCode) {
- int notificationId = 2000;
+ final int notificationId = 2000;
if (BuildConfig.VERSION_CODE < versionCode) {
diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
index 95d3c2b7c..9cba0667b 100644
--- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
+++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
@@ -94,18 +94,18 @@ public final class DownloaderImpl extends Downloader {
private static void enableModernTLS(final OkHttpClient.Builder builder) {
try {
// get the default TrustManager
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
+ final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
- TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
+ final TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:"
+ Arrays.toString(trustManagers));
}
- X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
+ final X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
// insert our own TLSSocketFactory
- SSLSocketFactory sslSocketFactory = TLSSocketFactoryCompat.getInstance();
+ final SSLSocketFactory sslSocketFactory = TLSSocketFactoryCompat.getInstance();
builder.sslSocketFactory(sslSocketFactory, trustManager);
@@ -114,16 +114,16 @@ public final class DownloaderImpl extends Downloader {
// Necessary because some servers (e.g. Framatube.org)
// don't support the old cipher suites.
// https://github.com/square/okhttp/issues/4053#issuecomment-402579554
- List cipherSuites = new ArrayList<>();
+ final List cipherSuites = new ArrayList<>();
cipherSuites.addAll(ConnectionSpec.MODERN_TLS.cipherSuites());
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA);
cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
- ConnectionSpec legacyTLS = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
+ final ConnectionSpec legacyTLS = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.cipherSuites(cipherSuites.toArray(new CipherSuite[0]))
.build();
builder.connectionSpecs(Arrays.asList(legacyTLS, ConnectionSpec.CLEARTEXT));
- } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
+ } catch (final KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
if (DEBUG) {
e.printStackTrace();
}
@@ -131,15 +131,15 @@ public final class DownloaderImpl extends Downloader {
}
public String getCookies(final String url) {
- List resultCookies = new ArrayList<>();
+ final List resultCookies = new ArrayList<>();
if (url.contains(YOUTUBE_DOMAIN)) {
- String youtubeCookie = getCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY);
+ final String youtubeCookie = getCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY);
if (youtubeCookie != null) {
resultCookies.add(youtubeCookie);
}
}
// Recaptcha cookie is always added TODO: not sure if this is necessary
- String recaptchaCookie = getCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY);
+ final String recaptchaCookie = getCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY);
if (recaptchaCookie != null) {
resultCookies.add(recaptchaCookie);
}
@@ -159,9 +159,9 @@ public final class DownloaderImpl extends Downloader {
}
public void updateYoutubeRestrictedModeCookies(final Context context) {
- String restrictedModeEnabledKey =
+ final String restrictedModeEnabledKey =
context.getString(R.string.youtube_restricted_mode_enabled);
- boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context)
+ final boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(restrictedModeEnabledKey, false);
updateYoutubeRestrictedModeCookies(restrictedModeEnabled);
}
@@ -186,9 +186,9 @@ public final class DownloaderImpl extends Downloader {
try {
final Response response = head(url);
return Long.parseLong(response.getHeader("Content-Length"));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
throw new IOException("Invalid content length", e);
- } catch (ReCaptchaException e) {
+ } catch (final ReCaptchaException e) {
throw new IOException(e);
}
}
@@ -199,7 +199,7 @@ public final class DownloaderImpl extends Downloader {
.method("GET", null).url(siteUrl)
.addHeader("User-Agent", USER_AGENT);
- String cookies = getCookies(siteUrl);
+ final String cookies = getCookies(siteUrl);
if (!cookies.isEmpty()) {
requestBuilder.addHeader("Cookie", cookies);
}
@@ -218,7 +218,7 @@ public final class DownloaderImpl extends Downloader {
}
return body.byteStream();
- } catch (ReCaptchaException e) {
+ } catch (final ReCaptchaException e) {
throw new IOException(e.getMessage(), e.getCause());
}
}
@@ -240,18 +240,18 @@ public final class DownloaderImpl extends Downloader {
.method(httpMethod, requestBody).url(url)
.addHeader("User-Agent", USER_AGENT);
- String cookies = getCookies(url);
+ final String cookies = getCookies(url);
if (!cookies.isEmpty()) {
requestBuilder.addHeader("Cookie", cookies);
}
- for (Map.Entry> pair : headers.entrySet()) {
+ for (final Map.Entry> pair : headers.entrySet()) {
final String headerName = pair.getKey();
final List headerValueList = pair.getValue();
if (headerValueList.size() > 1) {
requestBuilder.removeHeader(headerName);
- for (String headerValue : headerValueList) {
+ for (final String headerValue : headerValueList) {
requestBuilder.addHeader(headerName, headerValue);
}
} else if (headerValueList.size() == 1) {
diff --git a/app/src/main/java/org/schabi/newpipe/ExitActivity.java b/app/src/main/java/org/schabi/newpipe/ExitActivity.java
index 94eff9560..d4a4e3125 100644
--- a/app/src/main/java/org/schabi/newpipe/ExitActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/ExitActivity.java
@@ -27,7 +27,7 @@ import android.os.Bundle;
public class ExitActivity extends Activity {
public static void exitAndRemoveFromRecentApps(final Activity activity) {
- Intent intent = new Intent(activity, ExitActivity.class);
+ final Intent intent = new Intent(activity, ExitActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java
index fb1ca2342..c3086d02c 100644
--- a/app/src/main/java/org/schabi/newpipe/MainActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java
@@ -140,7 +140,7 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(findViewById(R.id.toolbar));
try {
setupDrawer();
- } catch (Exception e) {
+ } catch (final Exception e) {
ErrorActivity.reportUiError(this, e);
}
@@ -155,8 +155,8 @@ public class MainActivity extends AppCompatActivity {
drawerItems = findViewById(R.id.navigation);
//Tabs
- int currentServiceId = ServiceHelper.getSelectedServiceId(this);
- StreamingService service = NewPipe.getService(currentServiceId);
+ final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
+ final StreamingService service = NewPipe.getService(currentServiceId);
int kioskId = 0;
@@ -228,7 +228,7 @@ public class MainActivity extends AppCompatActivity {
case R.id.menu_tabs_group:
try {
tabSelected(item);
- } catch (Exception e) {
+ } catch (final Exception e) {
ErrorActivity.reportUiError(this, e);
}
break;
@@ -269,8 +269,8 @@ public class MainActivity extends AppCompatActivity {
NavigationHelper.openStatisticFragment(getSupportFragmentManager());
break;
default:
- int currentServiceId = ServiceHelper.getSelectedServiceId(this);
- StreamingService service = NewPipe.getService(currentServiceId);
+ final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
+ final StreamingService service = NewPipe.getService(currentServiceId);
String serviceName = "";
int kioskId = 0;
@@ -299,8 +299,8 @@ public class MainActivity extends AppCompatActivity {
}
private void setupDrawerHeader() {
- NavigationView navigationView = findViewById(R.id.navigation);
- View hView = navigationView.getHeaderView(0);
+ final NavigationView navigationView = findViewById(R.id.navigation);
+ final View hView = navigationView.getHeaderView(0);
serviceArrow = hView.findViewById(R.id.drawer_arrow);
headerServiceIcon = hView.findViewById(R.id.drawer_header_service_icon);
@@ -335,7 +335,7 @@ public class MainActivity extends AppCompatActivity {
} else {
try {
showTabs();
- } catch (Exception e) {
+ } catch (final Exception e) {
ErrorActivity.reportUiError(this, e);
}
}
@@ -344,11 +344,11 @@ public class MainActivity extends AppCompatActivity {
private void showServices() {
serviceArrow.setImageResource(R.drawable.ic_arrow_drop_up_white_24dp);
- for (StreamingService s : NewPipe.getServices()) {
+ for (final StreamingService s : NewPipe.getServices()) {
final String title = s.getServiceInfo().getName()
+ (ServiceHelper.isBeta(s) ? " (beta)" : "");
- MenuItem menuItem = drawerItems.getMenu()
+ final MenuItem menuItem = drawerItems.getMenu()
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId()));
@@ -362,20 +362,20 @@ public class MainActivity extends AppCompatActivity {
}
private void enhancePeertubeMenu(final StreamingService s, final MenuItem menuItem) {
- PeertubeInstance currentInstace = PeertubeHelper.getCurrentInstance();
+ final PeertubeInstance currentInstace = PeertubeHelper.getCurrentInstance();
menuItem.setTitle(currentInstace.getName() + (ServiceHelper.isBeta(s) ? " (beta)" : ""));
- Spinner spinner = (Spinner) LayoutInflater.from(this)
+ final Spinner spinner = (Spinner) LayoutInflater.from(this)
.inflate(R.layout.instance_spinner_layout, null);
- List instances = PeertubeHelper.getInstanceList(this);
- List items = new ArrayList<>();
+ final List instances = PeertubeHelper.getInstanceList(this);
+ final List items = new ArrayList<>();
int defaultSelect = 0;
- for (PeertubeInstance instance : instances) {
+ for (final PeertubeInstance instance : instances) {
items.add(instance.getName());
if (instance.getUrl().equals(currentInstace.getUrl())) {
defaultSelect = items.size() - 1;
}
}
- ArrayAdapter adapter = new ArrayAdapter<>(this,
+ final ArrayAdapter adapter = new ArrayAdapter<>(this,
R.layout.instance_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
@@ -384,7 +384,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onItemSelected(final AdapterView> parent, final View view,
final int position, final long id) {
- PeertubeInstance newInstance = instances.get(position);
+ final PeertubeInstance newInstance = instances.get(position);
if (newInstance.getUrl().equals(PeertubeHelper.getCurrentInstance().getUrl())) {
return;
}
@@ -410,8 +410,8 @@ public class MainActivity extends AppCompatActivity {
serviceArrow.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
//Tabs
- int currentServiceId = ServiceHelper.getSelectedServiceId(this);
- StreamingService service = NewPipe.getService(currentServiceId);
+ final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
+ final StreamingService service = NewPipe.getService(currentServiceId);
int kioskId = 0;
@@ -476,11 +476,12 @@ public class MainActivity extends AppCompatActivity {
headerServiceView.post(() -> headerServiceView.setSelected(true));
toggleServiceButton.setContentDescription(
getString(R.string.drawer_header_description) + selectedServiceName);
- } catch (Exception e) {
+ } catch (final Exception e) {
ErrorActivity.reportUiError(this, e);
}
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ final SharedPreferences sharedPreferences
+ = PreferenceManager.getDefaultSharedPreferences(this);
if (sharedPreferences.getBoolean(Constants.KEY_THEME_CHANGE, false)) {
if (DEBUG) {
Log.d(TAG, "Theme has changed, recreating activity...");
@@ -513,7 +514,7 @@ public class MainActivity extends AppCompatActivity {
if (intent != null) {
// Return if launched from a launcher (e.g. Nova Launcher, Pixel Launcher ...)
// to not destroy the already created backstack
- String action = intent.getAction();
+ final String action = intent.getAction();
if ((action != null && action.equals(Intent.ACTION_MAIN))
&& intent.hasCategory(Intent.CATEGORY_LAUNCHER)) {
return;
@@ -546,7 +547,7 @@ public class MainActivity extends AppCompatActivity {
}
if (DeviceUtils.isTv(this)) {
- View drawerPanel = findViewById(R.id.navigation);
+ final View drawerPanel = findViewById(R.id.navigation);
if (drawer.isDrawerOpen(drawerPanel)) {
drawer.closeDrawers();
return;
@@ -594,7 +595,7 @@ public class MainActivity extends AppCompatActivity {
public void onRequestPermissionsResult(final int requestCode,
@NonNull final String[] permissions,
@NonNull final int[] grantResults) {
- for (int i : grantResults) {
+ for (final int i : grantResults) {
if (i == PackageManager.PERMISSION_DENIED) {
return;
}
@@ -604,7 +605,7 @@ public class MainActivity extends AppCompatActivity {
NavigationHelper.openDownloads(this);
break;
case PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE:
- Fragment fragment = getSupportFragmentManager()
+ final Fragment fragment = getSupportFragmentManager()
.findFragmentById(R.id.fragment_player_holder);
if (fragment instanceof VideoDetailFragment) {
((VideoDetailFragment) fragment).openDownloadDialog();
@@ -656,13 +657,14 @@ public class MainActivity extends AppCompatActivity {
}
super.onCreateOptionsMenu(menu);
- Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
+ final Fragment fragment
+ = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
if (!(fragment instanceof SearchFragment)) {
findViewById(R.id.toolbar).findViewById(R.id.toolbar_search_container)
.setVisibility(View.GONE);
}
- ActionBar actionBar = getSupportActionBar();
+ final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
}
@@ -677,7 +679,7 @@ public class MainActivity extends AppCompatActivity {
if (DEBUG) {
Log.d(TAG, "onOptionsItemSelected() called with: item = [" + item + "]");
}
- int id = item.getItemId();
+ final int id = item.getItemId();
switch (id) {
case android.R.id.home:
@@ -745,13 +747,13 @@ public class MainActivity extends AppCompatActivity {
}
if (intent.hasExtra(Constants.KEY_LINK_TYPE)) {
- String url = intent.getStringExtra(Constants.KEY_URL);
- int serviceId = intent.getIntExtra(Constants.KEY_SERVICE_ID, 0);
- String title = intent.getStringExtra(Constants.KEY_TITLE);
+ final String url = intent.getStringExtra(Constants.KEY_URL);
+ final int serviceId = intent.getIntExtra(Constants.KEY_SERVICE_ID, 0);
+ final String title = intent.getStringExtra(Constants.KEY_TITLE);
switch (((StreamingService.LinkType) intent
.getSerializableExtra(Constants.KEY_LINK_TYPE))) {
case STREAM:
- boolean autoPlay = intent
+ final boolean autoPlay = intent
.getBooleanExtra(VideoDetailFragment.AUTO_PLAY, false);
final String intentCacheKey = intent
.getStringExtra(VideoPlayer.PLAY_QUEUE_KEY);
@@ -780,7 +782,7 @@ public class MainActivity extends AppCompatActivity {
if (searchString == null) {
searchString = "";
}
- int serviceId = intent.getIntExtra(Constants.KEY_SERVICE_ID, 0);
+ final int serviceId = intent.getIntExtra(Constants.KEY_SERVICE_ID, 0);
NavigationHelper.openSearchFragment(
getSupportFragmentManager(),
serviceId,
@@ -789,7 +791,7 @@ public class MainActivity extends AppCompatActivity {
} else {
NavigationHelper.gotoMainFragment(getSupportFragmentManager());
}
- } catch (Exception e) {
+ } catch (final Exception e) {
ErrorActivity.reportUiError(this, e);
}
}
diff --git a/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java b/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java
index c59c48367..988a5ed98 100644
--- a/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java
+++ b/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java
@@ -46,7 +46,7 @@ public final class NewPipeDatabase {
if (databaseInstance == null) {
throw new IllegalStateException("database is not initialized");
}
- Cursor c = databaseInstance.query("pragma wal_checkpoint(full)", null);
+ final Cursor c = databaseInstance.query("pragma wal_checkpoint(full)", null);
if (c.moveToFirst() && c.getInt(0) == 1) {
throw new RuntimeException("Checkpoint was blocked from completing");
}
diff --git a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java
index 2e1abd598..75304a2b9 100644
--- a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java
@@ -31,7 +31,7 @@ public class PanicResponderActivity extends Activity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Intent intent = getIntent();
+ final Intent intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
// TODO: Explicitly clear the search results
// once they are restored when the app restarts
diff --git a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
index 40ea4fd58..c962ed99d 100644
--- a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
@@ -61,7 +61,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
ThemeHelper.setTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recaptcha);
- Toolbar toolbar = findViewById(R.id.toolbar);
+ final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
String url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
@@ -76,7 +76,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
webView = findViewById(R.id.reCaptchaWebView);
// enable Javascript
- WebSettings webSettings = webView.getSettings();
+ final WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@@ -84,7 +84,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
@Override
public boolean shouldOverrideUrlLoading(final WebView view,
final WebResourceRequest request) {
- String url = request.getUrl().toString();
+ final String url = request.getUrl().toString();
if (MainActivity.DEBUG) {
Log.d(TAG, "shouldOverrideUrlLoading: request.url=" + url);
}
@@ -113,7 +113,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
// cleaning cache, history and cookies from webView
webView.clearCache(true);
webView.clearHistory();
- android.webkit.CookieManager cookieManager = CookieManager.getInstance();
+ final android.webkit.CookieManager cookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(aBoolean -> {
});
@@ -128,7 +128,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_recaptcha, menu);
- ActionBar actionBar = getSupportActionBar();
+ final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setTitle(R.string.title_activity_recaptcha);
@@ -145,7 +145,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
- int id = item.getItemId();
+ final int id = item.getItemId();
switch (id) {
case R.id.menu_item_done:
saveCookiesAndFinish();
@@ -173,7 +173,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
setResult(RESULT_OK);
}
- Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
+ final Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
NavUtils.navigateUpTo(this, intent);
}
@@ -188,13 +188,13 @@ public class ReCaptchaActivity extends AppCompatActivity {
return;
}
- String cookies = CookieManager.getInstance().getCookie(url);
+ final String cookies = CookieManager.getInstance().getCookie(url);
handleCookies(cookies);
// sometimes cookies are inside the url
- int abuseStart = url.indexOf("google_abuse=");
+ final int abuseStart = url.indexOf("google_abuse=");
if (abuseStart != -1) {
- int abuseEnd = url.indexOf("+path");
+ final int abuseEnd = url.indexOf("+path");
try {
String abuseCookie = url.substring(abuseStart + 13, abuseEnd);
diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java
index e9e166c22..70fceaf07 100644
--- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java
@@ -310,7 +310,7 @@ public class RouterActivity extends AppCompatActivity {
};
int id = 12345;
- for (AdapterChoiceItem item : choices) {
+ for (final AdapterChoiceItem item : choices) {
final RadioButton radioButton
= (RadioButton) inflater.inflate(R.layout.list_radio_icon_item, null);
radioButton.setText(item.description);
@@ -330,7 +330,7 @@ public class RouterActivity extends AppCompatActivity {
getString(R.string.preferred_open_action_last_selected_key), null);
if (!TextUtils.isEmpty(lastSelectedPlayer)) {
for (int i = 0; i < choices.size(); i++) {
- AdapterChoiceItem c = choices.get(i);
+ final AdapterChoiceItem c = choices.get(i);
if (lastSelectedPlayer.equals(c.key)) {
selectedRadioPosition = i;
break;
@@ -362,9 +362,9 @@ public class RouterActivity extends AppCompatActivity {
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
- boolean isExtVideoEnabled = preferences.getBoolean(
+ final boolean isExtVideoEnabled = preferences.getBoolean(
getString(R.string.use_external_video_player_key), false);
- boolean isExtAudioEnabled = preferences.getBoolean(
+ final boolean isExtAudioEnabled = preferences.getBoolean(
getString(R.string.use_external_audio_player_key), false);
returnList.add(new AdapterChoiceItem(getString(R.string.show_info_key),
@@ -410,9 +410,9 @@ public class RouterActivity extends AppCompatActivity {
}
private void handleText() {
- String searchString = getIntent().getStringExtra(Intent.EXTRA_TEXT);
- int serviceId = getIntent().getIntExtra(Constants.KEY_SERVICE_ID, 0);
- Intent intent = new Intent(getThemeWrapperContext(), MainActivity.class);
+ final String searchString = getIntent().getStringExtra(Intent.EXTRA_TEXT);
+ final int serviceId = getIntent().getIntExtra(Constants.KEY_SERVICE_ID, 0);
+ final Intent intent = new Intent(getThemeWrapperContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
NavigationHelper.openSearch(getThemeWrapperContext(), serviceId, searchString);
@@ -479,14 +479,14 @@ public class RouterActivity extends AppCompatActivity {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((@NonNull StreamInfo result) -> {
- List sortedVideoStreams = ListHelper
+ final List sortedVideoStreams = ListHelper
.getSortedStreamVideosList(this, result.getVideoStreams(),
result.getVideoOnlyStreams(), false);
- int selectedVideoStreamIndex = ListHelper
+ final int selectedVideoStreamIndex = ListHelper
.getDefaultResolutionIndex(this, sortedVideoStreams);
- FragmentManager fm = getSupportFragmentManager();
- DownloadDialog downloadDialog = DownloadDialog.newInstance(result);
+ final FragmentManager fm = getSupportFragmentManager();
+ final DownloadDialog downloadDialog = DownloadDialog.newInstance(result);
downloadDialog.setVideoStreams(sortedVideoStreams);
downloadDialog.setAudioStreams(result.getAudioStreams());
downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex);
@@ -504,7 +504,7 @@ public class RouterActivity extends AppCompatActivity {
public void onRequestPermissionsResult(final int requestCode,
@NonNull final String[] permissions,
@NonNull final int[] grantResults) {
- for (int i : grantResults) {
+ for (final int i : grantResults) {
if (i == PackageManager.PERMISSION_DENIED) {
finish();
return;
@@ -634,7 +634,7 @@ public class RouterActivity extends AppCompatActivity {
if (!(serializable instanceof Choice)) {
return;
}
- Choice playerChoice = (Choice) serializable;
+ final Choice playerChoice = (Choice) serializable;
handleChoice(playerChoice);
}
@@ -682,13 +682,13 @@ public class RouterActivity extends AppCompatActivity {
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(this);
- boolean isExtVideoEnabled = preferences.getBoolean(
+ final boolean isExtVideoEnabled = preferences.getBoolean(
getString(R.string.use_external_video_player_key), false);
- boolean isExtAudioEnabled = preferences.getBoolean(
+ final boolean isExtAudioEnabled = preferences.getBoolean(
getString(R.string.use_external_audio_player_key), false);
PlayQueue playQueue;
- String playerChoice = choice.playerChoice;
+ final String playerChoice = choice.playerChoice;
if (info instanceof StreamInfo) {
if (playerChoice.equals(backgroundPlayerKey) && isExtAudioEnabled) {
diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
index b5be2dde6..3041c3d6c 100644
--- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
+++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java
@@ -88,7 +88,7 @@ public class AboutActivity extends AppCompatActivity {
setContentView(R.layout.activity_about);
- Toolbar toolbar = findViewById(R.id.toolbar);
+ final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Create the adapter that will return a fragment for each of the three
@@ -99,13 +99,13 @@ public class AboutActivity extends AppCompatActivity {
mViewPager = findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
- TabLayout tabLayout = findViewById(R.id.tabs);
+ final TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
- int id = item.getItemId();
+ final int id = item.getItemId();
switch (id) {
case android.R.id.home:
@@ -134,25 +134,25 @@ public class AboutActivity extends AppCompatActivity {
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_about, container, false);
- Context context = this.getContext();
+ final View rootView = inflater.inflate(R.layout.fragment_about, container, false);
+ final Context context = this.getContext();
- TextView version = rootView.findViewById(R.id.app_version);
+ final TextView version = rootView.findViewById(R.id.app_version);
version.setText(BuildConfig.VERSION_NAME);
- View githubLink = rootView.findViewById(R.id.github_link);
+ final View githubLink = rootView.findViewById(R.id.github_link);
githubLink.setOnClickListener(nv ->
openUrlInBrowser(context, context.getString(R.string.github_url)));
- View donationLink = rootView.findViewById(R.id.donation_link);
+ final View donationLink = rootView.findViewById(R.id.donation_link);
donationLink.setOnClickListener(v ->
openUrlInBrowser(context, context.getString(R.string.donation_url)));
- View websiteLink = rootView.findViewById(R.id.website_link);
+ final View websiteLink = rootView.findViewById(R.id.website_link);
websiteLink.setOnClickListener(nv ->
openUrlInBrowser(context, context.getString(R.string.website_url)));
- View privacyPolicyLink = rootView.findViewById(R.id.privacy_policy_link);
+ final View privacyPolicyLink = rootView.findViewById(R.id.privacy_policy_link);
privacyPolicyLink.setOnClickListener(v ->
openUrlInBrowser(context, context.getString(R.string.privacy_policy_url)));
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
index bc6310601..404f12602 100644
--- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.java
@@ -31,8 +31,8 @@ public class LicenseFragment extends Fragment {
if (softwareComponents == null) {
throw new NullPointerException("softwareComponents is null");
}
- LicenseFragment fragment = new LicenseFragment();
- Bundle bundle = new Bundle();
+ final LicenseFragment fragment = new LicenseFragment();
+ final Bundle bundle = new Bundle();
bundle.putParcelableArray(ARG_COMPONENTS, softwareComponents);
fragment.setArguments(bundle);
return fragment;
diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
index 1c425567f..01a01bc88 100644
--- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java
@@ -51,7 +51,7 @@ public class LicenseFragmentHelper extends AsyncTask