From fda5405e48f7cb1f4f4b9df89052d55c90e8b167 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Tue, 31 Mar 2020 19:20:15 +0200 Subject: [PATCH] Improve code style to be more consistent --- .../newpipe/database/AppDatabaseTest.kt | 7 +- .../schabi/newpipe/report/ErrorInfoTest.java | 12 +- .../java/org/schabi/newpipe/DebugApp.java | 3 +- ...agmentStatePagerAdapterMenuWorkaround.java | 67 +- .../material/appbar/FlingBehavior.java | 26 +- .../schabi/newpipe/ActivityCommunicator.java | 14 +- app/src/main/java/org/schabi/newpipe/App.java | 71 +- .../java/org/schabi/newpipe/BaseFragment.java | 65 +- .../newpipe/CheckForNewAppVersionTask.java | 242 +++--- .../org/schabi/newpipe/DownloaderImpl.java | 127 +-- .../java/org/schabi/newpipe/ExitActivity.java | 25 +- .../org/schabi/newpipe/ImageDownloader.java | 7 +- .../java/org/schabi/newpipe/MainActivity.java | 235 +++--- .../org/schabi/newpipe/NewPipeDatabase.java | 8 +- .../newpipe/PanicResponderActivity.java | 10 +- .../org/schabi/newpipe/ReCaptchaActivity.java | 43 +- .../org/schabi/newpipe/RouterActivity.java | 282 +++++-- .../schabi/newpipe/about/AboutActivity.java | 109 +-- .../org/schabi/newpipe/about/License.java | 27 +- .../schabi/newpipe/about/LicenseFragment.java | 47 +- .../newpipe/about/LicenseFragmentHelper.java | 159 ++-- .../newpipe/about/SoftwareComponent.java | 58 +- .../newpipe/about/StandardLicenses.java | 19 +- .../schabi/newpipe/database/AppDatabase.java | 6 + .../org/schabi/newpipe/database/BasicDAO.java | 14 +- .../schabi/newpipe/database/Converters.java | 25 +- .../schabi/newpipe/database/LocalItem.java | 4 +- .../schabi/newpipe/database/Migrations.java | 166 ++-- .../history/dao/SearchHistoryDAO.java | 16 +- .../history/dao/StreamHistoryDAO.java | 49 +- .../history/model/SearchHistoryEntry.java | 17 +- .../history/model/StreamHistoryEntity.java | 23 +- .../playlist/PlaylistMetadataEntry.java | 13 +- .../database/playlist/dao/PlaylistDAO.java | 6 +- .../playlist/dao/PlaylistRemoteDAO.java | 23 +- .../playlist/dao/PlaylistStreamDAO.java | 56 +- .../playlist/model/PlaylistEntity.java | 16 +- .../playlist/model/PlaylistRemoteEntity.java | 38 +- .../playlist/model/PlaylistStreamEntity.java | 27 +- .../database/stream/dao/StreamStateDAO.java | 10 +- .../database/stream/model/StreamEntity.kt | 3 +- .../stream/model/StreamStateEntity.java | 32 +- .../database/subscription/SubscriptionDAO.kt | 2 +- .../subscription/SubscriptionEntity.java | 65 +- .../newpipe/download/DownloadActivity.java | 17 +- .../newpipe/download/DownloadDialog.java | 357 ++++---- .../newpipe/fragments/BackPressable.java | 4 +- .../newpipe/fragments/BaseStateFragment.java | 151 ++-- .../newpipe/fragments/BlankFragment.java | 8 +- .../newpipe/fragments/EmptyFragment.java | 6 +- .../newpipe/fragments/MainFragment.java | 65 +- .../fragments/OnScrollBelowItemsListener.java | 17 +- .../newpipe/fragments/ViewContract.java | 3 + .../newpipe/fragments/detail/StackItem.java | 12 +- .../newpipe/fragments/detail/TabAdaptor.java | 35 +- .../fragments/detail/VideoDetailFragment.java | 570 +++++++------ .../fragments/list/BaseListFragment.java | 130 +-- .../fragments/list/BaseListInfoFragment.java | 52 +- .../list/channel/ChannelFragment.java | 234 +++--- .../list/comments/CommentsFragment.java | 65 +- .../list/kiosk/DefaultKioskFragment.java | 10 +- .../fragments/list/kiosk/KioskFragment.java | 67 +- .../list/playlist/PlaylistFragment.java | 173 ++-- .../fragments/list/search/SearchFragment.java | 433 ++++++---- .../fragments/list/search/SuggestionItem.java | 4 +- .../list/search/SuggestionListAdapter.java | 70 +- .../list/videos/RelatedVideosFragment.java | 141 ++-- .../newpipe/info_list/InfoItemBuilder.java | 45 +- .../newpipe/info_list/InfoItemDialog.java | 5 +- .../newpipe/info_list/InfoListAdapter.java | 178 ++-- .../holder/ChannelGridInfoItemHolder.java | 8 +- .../holder/ChannelInfoItemHolder.java | 14 +- .../holder/ChannelMiniInfoItemHolder.java | 15 +- .../holder/CommentsInfoItemHolder.java | 11 +- .../holder/CommentsMiniInfoItemHolder.java | 72 +- .../info_list/holder/InfoItemHolder.java | 13 +- .../holder/PlaylistGridInfoItemHolder.java | 10 +- .../holder/PlaylistInfoItemHolder.java | 3 +- .../holder/PlaylistMiniInfoItemHolder.java | 17 +- .../holder/StreamGridInfoItemHolder.java | 7 +- .../holder/StreamInfoItemHolder.java | 34 +- .../holder/StreamMiniInfoItemHolder.java | 38 +- .../newpipe/local/BaseLocalListFragment.java | 114 ++- .../newpipe/local/HeaderFooterHolder.java | 7 +- .../newpipe/local/LocalItemBuilder.java | 6 +- .../newpipe/local/LocalItemListAdapter.java | 153 ++-- .../local/bookmark/BookmarkFragment.java | 208 ++--- .../local/dialog/PlaylistAppendDialog.java | 28 +- .../local/dialog/PlaylistCreationDialog.java | 13 +- .../newpipe/local/dialog/PlaylistDialog.java | 14 +- .../schabi/newpipe/local/feed/FeedFragment.kt | 13 +- .../local/history/HistoryEntryAdapter.java | 27 +- .../local/history/HistoryListener.java | 34 - .../local/history/HistoryRecordManager.java | 28 +- .../history/StatisticsPlaylistFragment.java | 212 ++--- .../newpipe/local/holder/LocalItemHolder.java | 16 +- .../holder/LocalPlaylistGridItemHolder.java | 8 +- .../local/holder/LocalPlaylistItemHolder.java | 14 +- .../LocalPlaylistStreamGridItemHolder.java | 8 +- .../holder/LocalPlaylistStreamItemHolder.java | 62 +- .../LocalStatisticStreamGridItemHolder.java | 8 +- .../LocalStatisticStreamItemHolder.java | 55 +- .../local/holder/PlaylistItemHolder.java | 12 +- .../holder/RemotePlaylistGridItemHolder.java | 8 +- .../holder/RemotePlaylistItemHolder.java | 19 +- .../local/playlist/LocalPlaylistFragment.java | 270 +++--- .../local/playlist/LocalPlaylistManager.java | 13 +- .../ImportConfirmationDialog.java | 26 +- .../subscription/SubscriptionFragment.kt | 12 +- .../SubscriptionsImportFragment.java | 84 +- .../subscription/dialog/FeedGroupDialog.kt | 20 +- .../dialog/FeedGroupReorderDialog.kt | 7 +- .../local/subscription/item/ChannelItem.kt | 2 +- .../subscription/item/EmptyPlaceholderItem.kt | 2 +- .../subscription/item/FeedGroupAddItem.kt | 2 +- .../subscription/item/FeedGroupCardItem.kt | 2 +- .../item/FeedGroupCarouselItem.kt | 2 +- .../local/subscription/item/HeaderItem.kt | 2 +- .../local/subscription/item/PickerIconItem.kt | 5 +- .../item/PickerSubscriptionItem.kt | 2 +- .../services/BaseImportExportService.java | 118 +-- .../services/ImportExportEventListener.java | 2 +- .../services/ImportExportJsonHelper.java | 42 +- .../services/SubscriptionsExportService.java | 51 +- .../services/SubscriptionsImportService.java | 95 ++- .../newpipe/player/AudioServiceLeakFix.java | 29 +- .../newpipe/player/BackgroundPlayer.java | 265 +++--- .../player/BackgroundPlayerActivity.java | 6 +- .../org/schabi/newpipe/player/BasePlayer.java | 787 +++++++++++------- .../newpipe/player/MainVideoPlayer.java | 478 ++++++----- .../newpipe/player/PlayerServiceBinder.java | 1 + .../schabi/newpipe/player/PlayerState.java | 6 +- .../newpipe/player/PopupVideoPlayer.java | 520 ++++++++---- .../player/PopupVideoPlayerActivity.java | 6 +- .../newpipe/player/ServicePlayerActivity.java | 185 ++-- .../schabi/newpipe/player/VideoPlayer.java | 479 ++++++----- .../player/event/PlayerEventListener.java | 6 +- .../newpipe/player/helper/AudioReactor.java | 28 +- .../newpipe/player/helper/CacheFactory.java | 30 +- .../newpipe/player/helper/LoadController.java | 29 +- .../newpipe/player/helper/LockManager.java | 26 +- .../player/helper/MediaSessionManager.java | 7 +- .../helper/PlaybackParameterDialog.java | 268 +++--- .../player/helper/PlayerDataSource.java | 21 +- .../newpipe/player/helper/PlayerHelper.java | 241 +++--- .../mediasession/MediaSessionCallback.java | 9 +- .../mediasession/PlayQueueNavigator.java | 19 +- .../PlayQueuePlaybackController.java | 2 +- .../player/mediasource/FailedMediaSource.java | 66 +- .../player/mediasource/LoadedMediaSource.java | 26 +- .../mediasource/ManagedMediaSource.java | 19 +- .../ManagedMediaSourcePlaylist.java | 69 +- .../mediasource/PlaceholderMediaSource.java | 26 +- .../playback/BasePlayerMediaSession.java | 26 +- .../player/playback/CustomTrackSelector.java | 41 +- .../player/playback/MediaSourceManager.java | 326 +++++--- .../player/playback/PlaybackListener.java | 49 +- .../playqueue/AbstractInfoPlayQueue.java | 176 ++-- .../newpipe/player/playqueue/PlayQueue.java | 260 +++--- .../player/playqueue/PlayQueueAdapter.java | 73 +- .../player/playqueue/PlayQueueItem.java | 39 +- .../playqueue/PlayQueueItemBuilder.java | 25 +- .../player/playqueue/PlayQueueItemHolder.java | 19 +- .../playqueue/PlayQueueItemTouchCallback.java | 16 +- .../player/playqueue/SinglePlayQueue.java | 5 +- .../player/playqueue/events/AppendEvent.java | 11 +- .../player/playqueue/events/ErrorEvent.java | 17 +- .../player/playqueue/events/MoveEvent.java | 14 +- .../playqueue/events/RecoveryEvent.java | 15 +- .../player/playqueue/events/RemoveEvent.java | 15 +- .../player/playqueue/events/ReorderEvent.java | 10 +- .../player/playqueue/events/SelectEvent.java | 15 +- .../resolver/AudioPlaybackResolver.java | 18 +- .../player/resolver/MediaSourceTag.java | 12 +- .../player/resolver/PlaybackResolver.java | 7 +- .../newpipe/player/resolver/Resolver.java | 3 +- .../resolver/VideoPlaybackResolver.java | 52 +- .../newpipe/report/AcraReportSender.java | 5 +- .../report/AcraReportSenderFactory.java | 6 +- .../schabi/newpipe/report/ErrorActivity.java | 152 ++-- .../org/schabi/newpipe/report/UserAction.java | 2 +- .../settings/AppearanceSettingsFragment.java | 73 +- .../settings/BasePreferenceFragment.java | 13 +- .../settings/ContentSettingsFragment.java | 112 +-- .../settings/DebugSettingsFragment.java | 2 +- .../settings/DownloadSettingsFragment.java | 123 +-- .../settings/HistorySettingsFragment.java | 18 +- .../settings/MainSettingsFragment.java | 3 +- .../newpipe/settings/NewPipeSettings.java | 71 +- .../PeertubeInstanceListFragment.java | 237 +++--- .../settings/SelectChannelFragment.java | 171 ++-- .../newpipe/settings/SelectKioskFragment.java | 168 ++-- .../newpipe/settings/SettingsActivity.java | 37 +- .../settings/UpdateSettingsFragment.java | 20 +- .../settings/VideoAudioSettingsFragment.java | 62 +- .../newpipe/settings/tabs/AddTabDialog.java | 36 +- .../settings/tabs/ChooseTabsFragment.java | 240 +++--- .../org/schabi/newpipe/settings/tabs/Tab.java | 203 ++--- .../newpipe/settings/tabs/TabsJsonHelper.java | 66 +- .../newpipe/settings/tabs/TabsManager.java | 43 +- .../schabi/newpipe/util/AnimationUtils.java | 327 +++++--- .../org/schabi/newpipe/util/BitmapUtils.java | 6 +- .../util/CommentTextOnTouchListener.java | 32 +- .../org/schabi/newpipe/util/Constants.java | 4 +- .../schabi/newpipe/util/ExtractorHelper.java | 187 +++-- .../newpipe/util/FallbackViewHolder.java | 5 +- .../util/FilePickerActivityHelper.java | 110 ++- .../schabi/newpipe/util/FilenameUtils.java | 45 +- .../org/schabi/newpipe/util/FireTvUtils.java | 9 +- .../newpipe/util/ImageDisplayConstants.java | 6 +- .../org/schabi/newpipe/util/InfoCache.java | 144 ++-- .../schabi/newpipe/util/KioskTranslator.java | 24 +- .../org/schabi/newpipe/util/KoreUtil.java | 12 +- .../util/LayoutManagerSmoothScroller.java | 19 +- .../org/schabi/newpipe/util/ListHelper.java | 256 ++++-- .../org/schabi/newpipe/util/Localization.java | 152 ++-- .../schabi/newpipe/util/NavigationHelper.java | 272 +++--- .../schabi/newpipe/util/OnClickGesture.java | 4 +- .../schabi/newpipe/util/PeertubeHelper.java | 16 +- .../schabi/newpipe/util/PermissionHelper.java | 58 +- .../newpipe/util/RelatedStreamInfo.java | 15 +- .../newpipe/util/SecondaryStreamHelper.java | 31 +- .../schabi/newpipe/util/SerializedCache.java | 64 +- .../schabi/newpipe/util/ServiceHelper.java | 79 +- .../org/schabi/newpipe/util/ShareUtils.java | 14 +- .../schabi/newpipe/util/SliderStrategy.java | 44 +- .../schabi/newpipe/util/SparseArrayUtils.java | 30 - .../org/schabi/newpipe/util/StateSaver.java | 252 +++--- .../newpipe/util/StreamDialogEntry.java | 80 +- .../newpipe/util/StreamItemAdapter.java | 84 +- .../newpipe/util/TLSSocketFactoryCompat.java | 50 +- .../org/schabi/newpipe/util/ThemeHelper.java | 92 +- .../org/schabi/newpipe/util/ZipHelper.java | 38 +- .../util/urlfinder/PatternsCompat.java | 339 ++++---- .../newpipe/views/AnimatedProgressBar.java | 90 +- .../schabi/newpipe/views/CollapsibleView.java | 148 ++-- .../newpipe/views/ScrollableTabLayout.java | 44 +- .../services/ImportExportJsonHelperTest.java | 39 +- .../newpipe/report/ErrorActivityTest.java | 7 +- .../schabi/newpipe/settings/tabs/TabTest.java | 2 +- .../settings/tabs/TabsJsonHelperTest.java | 38 +- .../schabi/newpipe/util/ListHelperTest.java | 97 ++- .../util/QuadraticSliderStrategyTest.java | 6 +- checkstyle-suppressions.xml | 12 + 244 files changed, 10116 insertions(+), 7222 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/local/history/HistoryListener.java delete mode 100644 app/src/main/java/org/schabi/newpipe/util/SparseArrayUtils.java create mode 100644 checkstyle-suppressions.xml diff --git a/app/src/androidTest/java/org/schabi/newpipe/database/AppDatabaseTest.kt b/app/src/androidTest/java/org/schabi/newpipe/database/AppDatabaseTest.kt index 2b7dcdf7c..917a83bf2 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/database/AppDatabaseTest.kt +++ b/app/src/androidTest/java/org/schabi/newpipe/database/AppDatabaseTest.kt @@ -30,8 +30,9 @@ class AppDatabaseTest { private const val DEFAULT_SECOND_URL = "https://www.youtube.com/watch?v=ncQU6iBn5Fc" } - @get:Rule val testHelper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(), - AppDatabase::class.java.canonicalName, FrameworkSQLiteOpenHelperFactory()); + @get:Rule + val testHelper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(), + AppDatabase::class.java.canonicalName, FrameworkSQLiteOpenHelperFactory()) @Test fun migrateDatabaseFrom2to3() { @@ -72,7 +73,7 @@ class AppDatabaseTest { } testHelper.runMigrationsAndValidate(AppDatabase.DATABASE_NAME, Migrations.DB_VER_3, - true, Migrations.MIGRATION_2_3); + true, Migrations.MIGRATION_2_3) val migratedDatabaseV3 = getMigratedDatabase() val listFromDB = migratedDatabaseV3.streamDAO().all.blockingFirst() 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 6e51136c0..ab20d2ff3 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java @@ -1,8 +1,9 @@ package org.schabi.newpipe.report; import android.os.Parcel; -import androidx.test.filters.LargeTest; + import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,15 +13,16 @@ import org.schabi.newpipe.report.ErrorActivity.ErrorInfo; import static org.junit.Assert.assertEquals; /** - * Instrumented tests for {@link ErrorInfo} + * Instrumented tests for {@link ErrorInfo}. */ @RunWith(AndroidJUnit4.class) @LargeTest public class ErrorInfoTest { @Test - public void errorInfo_testParcelable() { - ErrorInfo info = ErrorInfo.make(UserAction.USER_REPORT, "youtube", "request", R.string.general_error); + public void errorInfoTestParcelable() { + 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(); info.writeToParcel(parcel, 0); @@ -34,4 +36,4 @@ public class ErrorInfoTest { parcel.recycle(); } -} \ No newline at end of file +} diff --git a/app/src/debug/java/org/schabi/newpipe/DebugApp.java b/app/src/debug/java/org/schabi/newpipe/DebugApp.java index 66f73d1e9..4d763aeb1 100644 --- a/app/src/debug/java/org/schabi/newpipe/DebugApp.java +++ b/app/src/debug/java/org/schabi/newpipe/DebugApp.java @@ -3,6 +3,7 @@ package org.schabi.newpipe; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; + import androidx.annotation.NonNull; import androidx.multidex.MultiDex; @@ -26,7 +27,7 @@ public class DebugApp extends App { private static final String TAG = DebugApp.class.toString(); @Override - protected void attachBaseContext(Context base) { + protected void attachBaseContext(final Context base) { super.attachBaseContext(base); MultiDex.install(this); } diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java index 9fd32b735..11f457b6c 100644 --- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java +++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java @@ -38,12 +38,15 @@ import java.util.ArrayList; * This is a copy from {@link androidx.fragment.app.FragmentStatePagerAdapter}. *

* It includes a workaround to fix the menu visibility when the adapter is restored. + *

*

* When restoring the state of this adapter, all the fragments' menu visibility were set to false, - * effectively disabling the menu from the user until he switched pages or another event that triggered the - * menu to be visible again happened. + * effectively disabling the menu from the user until he switched pages or another event + * that triggered the menu to be visible again happened. + *

*

- *
Check out the changes in: + * Check out the changes in: + *

*