From a441576bf61386ca631351af509548723ee68b83 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Sat, 2 Sep 2023 23:16:29 +0200 Subject: [PATCH] style: Require trailing comma, and break lines Requiring trailing commas on multi-line lists of items (declarations and call sites) reduces future repository churn when those lines are changed, but introduces additional churn now. Bite the bullet and make the change, as well as adjusting lines that were too long / indented incorrectly. The changes were performed automatically, using the `ktlintFormat` task. Based on https://github.com/tuskyapp/Tusky/pull/3968 by https://github.com/tinsukE --- .editorconfig | 5 +- app/lint-baseline.xml | 634 +++++++++--------- .../com/keylesspalace/tusky/MigrationsTest.kt | 6 +- .../com/keylesspalace/tusky/AboutActivity.kt | 4 +- .../tusky/AccountsInListFragment.kt | 28 +- .../tusky/BottomSheetActivity.kt | 22 +- .../tusky/EditProfileActivity.kt | 18 +- .../com/keylesspalace/tusky/ListsActivity.kt | 10 +- .../com/keylesspalace/tusky/MainActivity.kt | 166 ++--- .../keylesspalace/tusky/StatusListActivity.kt | 24 +- .../java/com/keylesspalace/tusky/TabData.kt | 26 +- .../tusky/TabPreferenceActivity.kt | 78 +-- .../keylesspalace/tusky/TuskyApplication.kt | 4 +- .../keylesspalace/tusky/ViewMediaActivity.kt | 47 +- .../tusky/adapter/AccountViewHolder.kt | 10 +- .../tusky/adapter/EmojiAdapter.kt | 2 +- .../tusky/adapter/FollowRequestViewHolder.kt | 14 +- .../tusky/adapter/PollAdapter.kt | 2 +- .../adapter/ReportNotificationViewHolder.kt | 24 +- .../keylesspalace/tusky/adapter/TabAdapter.kt | 4 +- .../tusky/appstore/CacheUpdater.kt | 2 +- .../components/account/AccountActivity.kt | 118 ++-- .../components/account/AccountFieldAdapter.kt | 2 +- .../components/account/AccountPagerAdapter.kt | 2 +- .../components/account/AccountViewModel.kt | 20 +- .../account/list/ListsForAccountFragment.kt | 10 +- .../account/list/ListsForAccountViewModel.kt | 18 +- .../account/media/AccountMediaFragment.kt | 5 +- .../account/media/AccountMediaGridAdapter.kt | 4 +- .../account/media/AccountMediaPagingSource.kt | 2 +- .../media/AccountMediaRemoteMediator.kt | 4 +- .../account/media/AccountMediaViewModel.kt | 8 +- .../media/GridSpacingItemDecoration.kt | 4 +- .../accountlist/AccountListActivity.kt | 2 +- .../accountlist/AccountListFragment.kt | 8 +- .../accountlist/adapter/AccountAdapter.kt | 6 +- .../accountlist/adapter/BlocksAdapter.kt | 4 +- .../accountlist/adapter/FollowAdapter.kt | 6 +- .../adapter/FollowRequestsAdapter.kt | 10 +- .../adapter/FollowRequestsHeaderAdapter.kt | 2 +- .../accountlist/adapter/MutesAdapter.kt | 8 +- .../announcements/AnnouncementAdapter.kt | 2 +- .../announcements/AnnouncementsViewModel.kt | 32 +- .../components/compose/ComposeActivity.kt | 50 +- .../compose/ComposeAutoCompleteAdapter.kt | 4 +- .../components/compose/ComposeViewModel.kt | 26 +- .../components/compose/ImageDownsizer.kt | 2 +- .../components/compose/MediaPreviewAdapter.kt | 4 +- .../tusky/components/compose/MediaUploader.kt | 14 +- .../compose/dialog/AddPollDialog.kt | 8 +- .../compose/dialog/AddPollOptionsAdapter.kt | 2 +- .../compose/dialog/CaptionDialog.kt | 32 +- .../components/compose/dialog/FocusDialog.kt | 54 +- .../compose/view/ComposeScheduleView.kt | 10 +- .../components/compose/view/EditTextTyped.kt | 4 +- .../compose/view/FocusIndicatorView.kt | 2 +- .../compose/view/PollPreviewView.kt | 2 +- .../compose/view/ProgressImageView.kt | 6 +- .../components/compose/view/TootButton.kt | 5 +- .../conversation/ConversationAdapter.kt | 6 +- .../conversation/ConversationEntity.kt | 26 +- .../ConversationLoadStateAdapter.kt | 4 +- .../conversation/ConversationViewData.kt | 12 +- .../conversation/ConversationsFragment.kt | 50 +- .../ConversationsRemoteMediator.kt | 8 +- .../conversation/ConversationsViewModel.kt | 28 +- .../tusky/components/drafts/DraftHelper.kt | 10 +- .../components/drafts/DraftMediaAdapter.kt | 4 +- .../tusky/components/drafts/DraftsActivity.kt | 6 +- .../tusky/components/drafts/DraftsAdapter.kt | 4 +- .../components/drafts/DraftsViewModel.kt | 4 +- .../components/filters/EditFilterActivity.kt | 22 +- .../components/filters/EditFilterViewModel.kt | 12 +- .../components/filters/FiltersActivity.kt | 2 +- .../components/filters/FiltersAdapter.kt | 4 +- .../components/filters/FiltersViewModel.kt | 12 +- .../followedtags/FollowedTagsActivity.kt | 36 +- .../followedtags/FollowedTagsAdapter.kt | 2 +- .../FollowedTagsRemoteMediator.kt | 4 +- .../followedtags/FollowedTagsViewModel.kt | 8 +- .../components/instanceinfo/InstanceInfo.kt | 2 +- .../instanceinfo/InstanceInfoRepository.kt | 8 +- .../adapter/DomainMutesAdapter.kt | 2 +- .../fragment/InstanceListFragment.kt | 8 +- .../tusky/components/login/LoginActivity.kt | 18 +- .../components/login/LoginWebViewActivity.kt | 8 +- .../components/login/LoginWebViewViewModel.kt | 4 +- .../notifications/FollowViewHolder.kt | 20 +- .../notifications/NotificationFetcher.kt | 12 +- .../notifications/NotificationsFragment.kt | 97 +-- .../NotificationsPagingAdapter.kt | 38 +- .../NotificationsPagingSource.kt | 12 +- .../notifications/NotificationsRepository.kt | 6 +- .../notifications/NotificationsViewModel.kt | 62 +- .../notifications/PushNotificationHelper.kt | 8 +- .../StatusNotificationViewHolder.kt | 54 +- .../notifications/StatusViewHolder.kt | 6 +- .../preference/AccountPreferencesFragment.kt | 50 +- .../preference/PreferencesActivity.kt | 11 +- .../preference/ProxyPreferencesFragment.kt | 2 +- .../components/report/ReportViewModel.kt | 14 +- .../tusky/components/report/Screen.kt | 2 +- .../report/adapter/StatusViewHolder.kt | 8 +- .../report/adapter/StatusesAdapter.kt | 4 +- .../report/adapter/StatusesPagingSource.kt | 6 +- .../report/fragments/ReportDoneFragment.kt | 4 +- .../fragments/ReportStatusesFragment.kt | 2 +- .../scheduled/ScheduledStatusActivity.kt | 4 +- .../scheduled/ScheduledStatusAdapter.kt | 4 +- .../scheduled/ScheduledStatusPagingSource.kt | 10 +- .../scheduled/ScheduledStatusViewModel.kt | 6 +- .../tusky/components/search/SearchType.kt | 2 +- .../components/search/SearchViewModel.kt | 16 +- .../search/adapter/SearchAccountsAdapter.kt | 2 +- .../search/adapter/SearchPagingSource.kt | 10 +- .../adapter/SearchPagingSourceFactory.kt | 4 +- .../search/adapter/SearchStatusesAdapter.kt | 2 +- .../fragments/SearchAccountsFragment.kt | 6 +- .../fragments/SearchHashtagsFragment.kt | 4 +- .../fragments/SearchStatusesFragment.kt | 30 +- .../timeline/CachedTimelineRepository.kt | 8 +- .../components/timeline/FiltersRepository.kt | 4 +- .../timeline/NetworkTimelineRepository.kt | 8 +- .../components/timeline/TimelineFragment.kt | 75 ++- .../timeline/TimelineLoadStateAdapter.kt | 4 +- .../timeline/TimelineLoadStateViewHolder.kt | 4 +- .../timeline/TimelinePagingAdapter.kt | 14 +- .../timeline/TimelineTypeMappers.kt | 16 +- .../components/timeline/util/TimelineUtils.kt | 2 +- .../viewmodel/CachedTimelineRemoteMediator.kt | 28 +- .../viewmodel/CachedTimelineViewModel.kt | 6 +- .../viewmodel/NetworkTimelinePagingSource.kt | 4 +- .../NetworkTimelineRemoteMediator.kt | 12 +- .../viewmodel/NetworkTimelineViewModel.kt | 16 +- .../timeline/viewmodel/PageCache.kt | 8 +- .../timeline/viewmodel/TimelineViewModel.kt | 46 +- .../components/trending/TrendingActivity.kt | 2 +- .../trending/TrendingDateViewHolder.kt | 4 +- .../trending/TrendingLinkViewHolder.kt | 2 +- .../trending/TrendingLinksAdapter.kt | 4 +- .../trending/TrendingLinksFragment.kt | 6 +- .../trending/TrendingLinksRepository.kt | 2 +- .../trending/TrendingTagViewHolder.kt | 6 +- .../trending/TrendingTagsAdapter.kt | 6 +- .../trending/TrendingTagsFragment.kt | 36 +- .../viewmodel/TrendingLinksViewModel.kt | 6 +- .../viewmodel/TrendingTagsViewModel.kt | 6 +- .../components/viewthread/ThreadAdapter.kt | 8 +- .../viewthread/ViewThreadFragment.kt | 16 +- .../viewthread/ViewThreadViewModel.kt | 44 +- .../viewthread/edits/ViewEditsAdapter.kt | 12 +- .../viewthread/edits/ViewEditsFragment.kt | 4 +- .../viewthread/edits/ViewEditsViewModel.kt | 8 +- .../keylesspalace/tusky/db/AccountEntity.kt | 8 +- .../keylesspalace/tusky/db/AccountManager.kt | 6 +- .../com/keylesspalace/tusky/db/Converters.kt | 2 +- .../com/keylesspalace/tusky/db/DraftEntity.kt | 4 +- .../com/keylesspalace/tusky/db/DraftsAlert.kt | 2 +- .../keylesspalace/tusky/db/InstanceEntity.kt | 6 +- .../keylesspalace/tusky/db/RemoteKeyEntity.kt | 6 +- .../com/keylesspalace/tusky/db/TimelineDao.kt | 34 +- .../tusky/db/TimelineStatusEntity.kt | 14 +- .../keylesspalace/tusky/di/AppComponent.kt | 4 +- .../com/keylesspalace/tusky/di/AppInjector.kt | 38 +- .../com/keylesspalace/tusky/di/AppModule.kt | 2 +- .../keylesspalace/tusky/di/NetworkModule.kt | 6 +- .../keylesspalace/tusky/entity/AccessToken.kt | 2 +- .../com/keylesspalace/tusky/entity/Account.kt | 8 +- .../tusky/entity/Announcement.kt | 4 +- .../tusky/entity/AppCredentials.kt | 2 +- .../keylesspalace/tusky/entity/Attachment.kt | 10 +- .../com/keylesspalace/tusky/entity/Card.kt | 2 +- .../tusky/entity/Conversation.kt | 2 +- .../tusky/entity/DeletedStatus.kt | 2 +- .../com/keylesspalace/tusky/entity/Emoji.kt | 2 +- .../com/keylesspalace/tusky/entity/Error.kt | 2 +- .../com/keylesspalace/tusky/entity/Filter.kt | 11 +- .../tusky/entity/FilterKeyword.kt | 2 +- .../tusky/entity/FilterResult.kt | 2 +- .../keylesspalace/tusky/entity/FilterV1.kt | 8 +- .../keylesspalace/tusky/entity/Instance.kt | 18 +- .../com/keylesspalace/tusky/entity/Marker.kt | 2 +- .../keylesspalace/tusky/entity/MastoList.kt | 2 +- .../tusky/entity/MediaUploadResult.kt | 2 +- .../keylesspalace/tusky/entity/NewStatus.kt | 6 +- .../tusky/entity/Notification.kt | 7 +- .../entity/NotificationSubscribeResult.kt | 2 +- .../com/keylesspalace/tusky/entity/Poll.kt | 8 +- .../tusky/entity/Relationship.kt | 2 +- .../com/keylesspalace/tusky/entity/Report.kt | 2 +- .../tusky/entity/ScheduledStatus.kt | 2 +- .../tusky/entity/SearchResult.kt | 2 +- .../com/keylesspalace/tusky/entity/Status.kt | 11 +- .../tusky/entity/StatusContext.kt | 2 +- .../keylesspalace/tusky/entity/StatusEdit.kt | 2 +- .../tusky/entity/StatusParams.kt | 2 +- .../tusky/entity/StatusSource.kt | 2 +- .../tusky/entity/TimelineAccount.kt | 2 +- .../tusky/entity/TrendingTagsResult.kt | 4 +- .../keylesspalace/tusky/entity/TrendsLink.kt | 6 +- .../keylesspalace/tusky/fragment/SFragment.kt | 34 +- .../tusky/fragment/ViewImageFragment.kt | 208 +++--- .../tusky/fragment/ViewMediaFragment.kt | 5 +- .../tusky/fragment/ViewVideoFragment.kt | 58 +- .../keylesspalace/tusky/json/Iso8601Utils.kt | 4 +- .../tusky/network/MastodonApi.kt | 198 +++--- .../tusky/network/MediaUploadApi.kt | 2 +- .../tusky/pager/ImagePagerAdapter.kt | 4 +- .../tusky/pager/SingleImagePagerAdapter.kt | 2 +- .../receiver/SendStatusBroadcastReceiver.kt | 4 +- .../tusky/service/SendStatusService.kt | 32 +- .../settings/AccountPreferenceDataStore.kt | 2 +- .../tusky/settings/ProxyConfiguration.kt | 4 +- .../tusky/settings/SettingsConstants.kt | 3 +- .../tusky/settings/SettingsDSL.kt | 12 +- .../tusky/usecase/DeveloperToolsUseCase.kt | 2 +- .../tusky/usecase/LogoutUsecase.kt | 4 +- .../tusky/usecase/TimelineCases.kt | 4 +- .../tusky/util/AlertDialogExtensions.kt | 6 +- .../keylesspalace/tusky/util/AsciiFolding.kt | 2 +- .../keylesspalace/tusky/util/BindingHolder.kt | 2 +- .../tusky/util/BlurHashDecoder.kt | 6 +- .../keylesspalace/tusky/util/CardViewMode.kt | 2 +- .../util/CombinedLoadStatesExtensions.kt | 8 +- .../util/CompositeWithOpaqueBackground.kt | 8 +- .../tusky/util/CustomFragmentStateAdapter.kt | 2 +- .../tusky/util/EmbeddedFontFamily.kt | 3 +- .../tusky/util/FlowExtensions.kt | 2 +- .../tusky/util/FocalPointUtil.kt | 8 +- .../tusky/util/HttpHeaderLink.kt | 4 +- .../com/keylesspalace/tusky/util/IOUtils.kt | 2 +- .../tusky/util/ImageLoadingHelper.kt | 4 +- .../keylesspalace/tusky/util/LinkHelper.kt | 2 +- .../util/ListStatusAccessibilityDelegate.kt | 62 +- .../tusky/util/LocaleExtensions.kt | 2 +- .../keylesspalace/tusky/util/LocaleManager.kt | 2 +- .../keylesspalace/tusky/util/MediaUtils.kt | 2 +- .../com/keylesspalace/tusky/util/Resource.kt | 2 +- .../com/keylesspalace/tusky/util/SpanUtils.kt | 6 +- .../tusky/util/StatusDisplayOptions.kt | 34 +- .../tusky/util/StatusViewHelper.kt | 14 +- .../keylesspalace/tusky/util/ThemeUtils.kt | 8 +- .../tusky/util/TouchDelegateHelper.kt | 2 +- .../tusky/util/ViewBindingExtensions.kt | 42 +- .../keylesspalace/tusky/util/ViewDataUtils.kt | 12 +- .../tusky/view/BackgroundMessageView.kt | 6 +- .../tusky/view/BezelImageView.kt | 4 +- .../tusky/view/ClickableSpanTextView.kt | 4 +- .../keylesspalace/tusky/view/EmojiPicker.kt | 2 +- .../tusky/view/FontFamilyDialogFragment.kt | 2 +- .../com/keylesspalace/tusky/view/GraphView.kt | 40 +- .../keylesspalace/tusky/view/LicenseCard.kt | 6 +- .../tusky/view/MediaPreviewImageView.kt | 4 +- .../tusky/view/MediaPreviewLayout.kt | 14 +- .../tusky/view/MuteAccountDialog.kt | 2 +- .../tusky/view/SliderPreference.kt | 2 +- .../tusky/viewdata/AttachmentViewData.kt | 4 +- .../tusky/viewdata/NotificationViewData.kt | 2 +- .../tusky/viewdata/PollViewData.kt | 8 +- .../tusky/viewdata/StatusViewData.kt | 2 +- .../tusky/viewdata/TrendingViewData.kt | 4 +- .../viewmodel/AccountsInListViewModel.kt | 14 +- .../tusky/viewmodel/EditProfileViewModel.kt | 18 +- .../tusky/viewmodel/ListsViewModel.kt | 12 +- .../tusky/worker/NotificationWorker.kt | 4 +- .../tusky/worker/PruneCacheWorker.kt | 4 +- .../tusky/worker/WorkerFactory.kt | 4 +- .../tusky/BottomSheetActivityTest.kt | 4 +- .../com/keylesspalace/tusky/FilterV1Test.kt | 88 +-- .../keylesspalace/tusky/FocalPointUtilTest.kt | 40 +- .../keylesspalace/tusky/MainActivityTest.kt | 10 +- .../com/keylesspalace/tusky/SpanUtilsTest.kt | 6 +- .../tusky/StatusComparisonTest.kt | 14 +- .../keylesspalace/tusky/StringUtilsTest.kt | 6 +- .../ComposeActivity/ComposeActivityTest.kt | 10 +- .../ComposeActivity/StatusLengthTest.kt | 10 +- .../ComposeTokenizer/ComposeTokenizerTest.kt | 4 +- .../NotificationsPagingSourceTest.kt | 8 +- .../NotificationsViewModelTestBase.kt | 6 +- ...icationsViewModelTestNotificationAction.kt | 2 +- .../NotificationsViewModelTestStatusAction.kt | 4 +- ...ationsViewModelTestStatusDisplayOptions.kt | 4 +- .../NotificationsViewModelTestUiState.kt | 2 +- .../CachedTimelineRemoteMediatorTest.kt | 122 ++-- .../CachedTimelineViewModelTestBase.kt | 8 +- ...CachedTimelineViewModelTestStatusAction.kt | 4 +- ...melineViewModelTestStatusDisplayOptions.kt | 4 +- .../CachedTimelineViewModelTestUiState.kt | 2 +- .../NetworkTimelinePagingSourceTest.kt | 28 +- .../NetworkTimelineRemoteMediatorTest.kt | 74 +- .../NetworkTimelineViewModelTestBase.kt | 8 +- ...etworkTimelineViewModelTestStatusAction.kt | 4 +- ...melineViewModelTestStatusDisplayOptions.kt | 4 +- .../NetworkTimelineViewModelTestUiState.kt | 2 +- .../tusky/components/timeline/StatusMocker.kt | 20 +- .../viewthread/ViewThreadViewModelTest.kt | 80 +-- .../keylesspalace/tusky/db/TimelineDaoTest.kt | 38 +- .../tusky/json/GuardedBooleanAdapterTest.kt | 12 +- .../InstanceSwitchAuthInterceptorTest.kt | 4 +- .../tusky/usecase/TimelineCasesTest.kt | 10 +- .../tusky/util/HttpHeaderLinkTest.kt | 22 +- .../tusky/util/LinkHelperTest.kt | 20 +- .../tusky/util/LocaleUtilsTest.kt | 8 +- .../tusky/util/NumberUtilsTest.kt | 2 +- .../tusky/util/SmartLengthInputFilterTest.kt | 24 +- .../kotlin/app/pachli/mklanguages/Main.kt | 4 +- .../app/pachli/mklanguages/ValuesParser.kt | 4 +- .../pachli/mklanguages/ValuesParserTest.kt | 2 +- 308 files changed, 2485 insertions(+), 2404 deletions(-) diff --git a/.editorconfig b/.editorconfig index 47d830da0..2fe7f0b70 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,10 +8,13 @@ insert_final_newline = true trim_trailing_whitespace = true # Disable wildcard imports -[*.{java, kt}] +[*.{java,kt}] ij_kotlin_name_count_to_use_star_import = 999 ij_kotlin_name_count_to_use_star_import_for_members = 999 ij_java_class_count_to_use_import_on_demand = 999 +# Require trailing comma +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true [*.{yml,yaml}] indent_size = 2 diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 5fb8a21bf..79667af0d 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -19,7 +19,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -30,7 +30,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -153,12 +153,12 @@ + errorLine1=" return ctx.getDrawable(R.drawable.avatar_default)!!" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + line="535" + column="32"/> @@ -1521,7 +1521,7 @@ errorLine2="^"> @@ -1576,7 +1576,7 @@ errorLine2="^"> @@ -2221,67 +2221,67 @@ - - - - + errorLine1=" binding.accountFloatingActionButton.show()" + errorLine2=" ~~~~~~~"> + column="29"/> + errorLine1=" binding.accountFloatingActionButton.hide()" + errorLine2=" ~~~~~~~"> + line="370" + column="29"/> - - - - + errorLine1=" binding.accountAvatarImageView.scaleX = scaledAvatarSize" + errorLine2=" ~~~~~~~"> + column="21"/> + errorLine1=" binding.accountAvatarImageView.scaleY = scaledAvatarSize" + errorLine2=" ~~~~~~~"> + line="377" + column="21"/> + + + + + + + + + errorLine1=" showErrorSnackbar(visibility, sensitive)" + errorLine2=" ~~~~~~~~~~~~~~~~~"> + line="311" + column="29"/> + errorLine1=" showErrorSnackbar(visibility, sensitive)" + errorLine2=" ~~~~~~~~~~~~~~~~~"> + line="317" + column="25"/> - - - - + + + + @@ -2357,7 +2357,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2368,7 +2368,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2379,7 +2379,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2390,7 +2390,7 @@ errorLine2=" ~~~~~~"> @@ -2401,7 +2401,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> @@ -2412,7 +2412,7 @@ errorLine2=" ~~~~~~~~~~~"> @@ -2423,7 +2423,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2434,7 +2434,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2445,7 +2445,7 @@ errorLine2=" ~~~~~~~~~~~~~"> @@ -2456,19 +2456,19 @@ errorLine2=" ~~~~~~"> + errorLine1=" handleActivity(activity)" + errorLine2=" ~~~~~~~~~~~~~~"> + line="42" + column="21"/> + errorLine1=" binding.recyclerView.post {" + errorLine2=" ~~~~~~~"> + line="154" + column="25"/> + errorLine1=" binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30))" + errorLine2=" ~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + errorLine1=" } else if (dy < 0 && !binding.fab.isShown) {" + errorLine2=" ~~~~~~~"> + column="47"/> + + + + @@ -2716,7 +2716,7 @@ @@ -3149,7 +3149,7 @@ errorLine2=" ~~~~~~~"> @@ -3160,7 +3160,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3171,7 +3171,7 @@ errorLine2=" ~~~~~~~"> @@ -3182,7 +3182,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3193,7 +3193,7 @@ errorLine2=" ~~~~~~~"> @@ -3204,7 +3204,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3215,7 +3215,7 @@ errorLine2=" ~~~~~~~"> @@ -3226,7 +3226,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3237,7 +3237,7 @@ errorLine2=" ~~~~~~~"> @@ -3248,7 +3248,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3259,7 +3259,7 @@ errorLine2=" ~~~~~~~"> @@ -3270,7 +3270,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3281,7 +3281,7 @@ errorLine2=" ~~~~~~~"> @@ -3292,7 +3292,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3303,7 +3303,7 @@ errorLine2=" ~~~~~~~"> @@ -3314,7 +3314,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3325,7 +3325,7 @@ errorLine2=" ~~~~~~~"> @@ -3336,7 +3336,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3347,7 +3347,7 @@ errorLine2=" ~~~~~~~"> @@ -3358,7 +3358,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3369,7 +3369,7 @@ errorLine2=" ~~~~~~~"> @@ -3380,7 +3380,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3391,7 +3391,7 @@ errorLine2=" ~~~~~~~"> @@ -3402,7 +3402,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3413,7 +3413,7 @@ errorLine2=" ~~~~~~~"> @@ -3424,7 +3424,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -3435,7 +3435,7 @@ errorLine2=" ~~~~~~~"> @@ -3446,7 +3446,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3457,7 +3457,7 @@ errorLine2=" ~~~~~~~"> @@ -3466,17 +3466,6 @@ message="Access to `private` method `getBinding` of class `MainActivity` requires synthetic accessor" errorLine1=" binding.mainToolbar.title = tab.contentDescription" errorLine2=" ~~~~~~~"> - - - - + + + + @@ -3717,12 +3717,12 @@ + errorLine1=" if (!viewModel.uiState.value.showFabWhileScrolling) {" + errorLine2=" ~~~~~~~~~"> + line="176" + column="30"/> + errorLine1=" saveTabs()" + errorLine2=" ~~~~~~~~"> + line="138" + column="21"/> + errorLine1=" viewHolder?.itemView?.elevation = selectedItemElevation" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~"> + line="148" + column="59"/> + errorLine1=" viewHolder?.itemView?.elevation = selectedItemElevation" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~"> + line="148" + column="59"/> + errorLine1=" if (!viewModel.uiState.value.showFabWhileScrolling) {" + errorLine2=" ~~~~~~~~~"> + line="174" + column="34"/> + errorLine1=" binding.captionSheet.visible(isDescriptionVisible)" + errorLine2=" ~~~~~~~"> + line="236" + column="25"/> @@ -3842,7 +3842,7 @@ errorLine2=" ~~~~~~~"> @@ -3853,65 +3853,65 @@ errorLine2=" ~~~~~~~"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -5983,7 +5983,7 @@ errorLine2=" ~~~~~~"> @@ -5994,7 +5994,7 @@ errorLine2=" ~~~~~~~~~~~"> @@ -6005,7 +6005,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6016,7 +6016,7 @@ errorLine2=" ~~~~~~"> @@ -6027,7 +6027,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6038,7 +6038,7 @@ errorLine2=" ~~~~~~~~~~~~~~"> @@ -6049,7 +6049,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6060,7 +6060,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6071,7 +6071,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> @@ -6082,7 +6082,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6093,7 +6093,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> @@ -6104,7 +6104,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6115,7 +6115,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6126,7 +6126,7 @@ errorLine2=" ~~~~~~"> @@ -6137,7 +6137,7 @@ errorLine2=" ~~~~~~"> @@ -6148,7 +6148,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6159,7 +6159,7 @@ errorLine2=" ~~~~~~~~~~~~~~"> @@ -6170,7 +6170,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6181,7 +6181,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6192,7 +6192,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~"> @@ -6203,7 +6203,7 @@ errorLine2=" ~~~~~~~~~~~~"> @@ -6214,7 +6214,7 @@ errorLine2=" ~~~~~~~"> @@ -6225,7 +6225,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~"> @@ -6236,7 +6236,7 @@ errorLine2=" ~~~~~~~~~~~~"> @@ -6247,7 +6247,7 @@ errorLine2=" ~~~~~~~"> @@ -6258,7 +6258,7 @@ errorLine2=" ~~~~~~~~~~~~"> @@ -6269,7 +6269,7 @@ errorLine2=" ~~~~~~~"> @@ -6280,7 +6280,7 @@ errorLine2=" ~~~~~~~~~~~~~~"> @@ -6291,7 +6291,7 @@ errorLine2=" ~~~~~~~~~~~~"> @@ -6302,7 +6302,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> @@ -6313,7 +6313,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> diff --git a/app/src/androidTest/java/com/keylesspalace/tusky/MigrationsTest.kt b/app/src/androidTest/java/com/keylesspalace/tusky/MigrationsTest.kt index 69641cc41..a6246251e 100644 --- a/app/src/androidTest/java/com/keylesspalace/tusky/MigrationsTest.kt +++ b/app/src/androidTest/java/com/keylesspalace/tusky/MigrationsTest.kt @@ -20,7 +20,7 @@ class MigrationsTest { var helper: MigrationTestHelper = MigrationTestHelper( InstrumentationRegistry.getInstrumentation(), AppDatabase::class.java.canonicalName, - FrameworkSQLiteOpenHelperFactory() + FrameworkSQLiteOpenHelperFactory(), ) @Test @@ -37,7 +37,7 @@ class MigrationsTest { id, domain, token, active, accountId, username, "Display Name", "https://picture.url", true, true, true, true, true, true, true, true, "1000", "[]", "[{\"shortcode\": \"emoji\", \"url\": \"yes\"}]", 0, false, - false, true + false, true, ) db.execSQL( @@ -49,7 +49,7 @@ class MigrationsTest { "`defaultPostPrivacy`,`defaultMediaSensitivity`,`alwaysShowSensitiveMedia`," + "`mediaPreviewEnabled`) " + "VALUES (nullif(?, 0),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", - values + values, ) db.close() diff --git a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt index b8b64692e..8b614484c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt @@ -49,7 +49,7 @@ class AboutActivity : BottomSheetActivity(), Injectable { Build.MANUFACTURER, Build.MODEL, Build.VERSION.RELEASE, - Build.VERSION.SDK_INT + Build.VERSION.SDK_INT, ) lifecycleScope.launch { @@ -59,7 +59,7 @@ class AboutActivity : BottomSheetActivity(), Injectable { R.string.about_account_info, account.username, account.domain, - instanceInfo.version + instanceInfo.version, ) binding.accountInfoTitle.show() binding.accountInfo.show() diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt index a20526e95..adacb06bf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt @@ -111,20 +111,22 @@ class AccountsInListFragment : DialogFragment(), Injectable { } binding.searchView.isSubmitButtonEnabled = true - binding.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { - override fun onQueryTextSubmit(query: String?): Boolean { - viewModel.search(query.orEmpty()) - return true - } - - override fun onQueryTextChange(newText: String?): Boolean { - // Close event is not sent so we use this instead - if (newText.isNullOrBlank()) { - viewModel.search("") + binding.searchView.setOnQueryTextListener( + object : SearchView.OnQueryTextListener { + override fun onQueryTextSubmit(query: String?): Boolean { + viewModel.search(query.orEmpty()) + return true } - return true - } - }) + + override fun onQueryTextChange(newText: String?): Boolean { + // Close event is not sent so we use this instead + if (newText.isNullOrBlank()) { + viewModel.search("") + } + return true + } + }, + ) } private fun setupSearchView(state: State) { diff --git a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt index e09bd4df8..28363add2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt @@ -53,15 +53,17 @@ abstract class BottomSheetActivity : BaseActivity() { val bottomSheetLayout: LinearLayout = findViewById(R.id.item_status_bottom_sheet) bottomSheet = BottomSheetBehavior.from(bottomSheetLayout) bottomSheet.state = BottomSheetBehavior.STATE_HIDDEN - bottomSheet.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { - override fun onStateChanged(bottomSheet: View, newState: Int) { - if (newState == BottomSheetBehavior.STATE_HIDDEN) { - cancelActiveSearch() + bottomSheet.addBottomSheetCallback( + object : BottomSheetBehavior.BottomSheetCallback() { + override fun onStateChanged(bottomSheet: View, newState: Int) { + if (newState == BottomSheetBehavior.STATE_HIDDEN) { + cancelActiveSearch() + } } - } - override fun onSlide(bottomSheet: View, slideOffset: Float) {} - }) + override fun onSlide(bottomSheet: View, slideOffset: Float) {} + }, + ) } open fun viewUrl(url: String, lookupFallbackBehavior: PostLookupFallbackBehavior = PostLookupFallbackBehavior.OPEN_IN_BROWSER) { @@ -72,7 +74,7 @@ abstract class BottomSheetActivity : BaseActivity() { mastodonApi.searchObservable( query = url, - resolve = true + resolve = true, ).observeOn(AndroidSchedulers.mainThread()) .autoDispose(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY)) .subscribe( @@ -101,7 +103,7 @@ abstract class BottomSheetActivity : BaseActivity() { onEndSearch(url) performUrlFallbackAction(url, lookupFallbackBehavior) } - } + }, ) onBeginSearch(url) @@ -177,5 +179,5 @@ abstract class BottomSheetActivity : BaseActivity() { enum class PostLookupFallbackBehavior { OPEN_IN_BROWSER, - DISPLAY_ERROR + DISPLAY_ERROR, } diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index 94c160f74..d5b85d0ce 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -81,7 +81,7 @@ class EditProfileActivity : BaseActivity(), Injectable { private enum class PickType { AVATAR, - HEADER + HEADER, } private val cropImage = registerForActivityResult(CropImageContract()) { result -> @@ -105,7 +105,7 @@ class EditProfileActivity : BaseActivity(), Injectable { displayName = binding.displayNameEditText.text.toString(), note = binding.noteEditText.text.toString(), locked = binding.lockedCheckBox.isChecked, - fields = accountFieldEditAdapter.getFieldData() + fields = accountFieldEditAdapter.getFieldData(), ) override fun onCreate(savedInstanceState: Bundle?) { @@ -162,7 +162,7 @@ class EditProfileActivity : BaseActivity(), Injectable { .placeholder(R.drawable.avatar_default) .transform( FitCenter(), - RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_80dp)) + RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_80dp)), ) .into(binding.avatarPreview) } @@ -198,7 +198,7 @@ class EditProfileActivity : BaseActivity(), Injectable { observeImage(viewModel.headerData, binding.headerPreview, false) viewModel.saveData.observe( - this + this, ) { when (it) { is Success -> { @@ -238,10 +238,10 @@ class EditProfileActivity : BaseActivity(), Injectable { private fun observeImage( liveData: LiveData, imageView: ImageView, - roundedCorners: Boolean + roundedCorners: Boolean, ) { liveData.observe( - this + this, ) { imageUri -> // skipping all caches so we can always reuse the same uri @@ -253,7 +253,7 @@ class EditProfileActivity : BaseActivity(), Injectable { if (roundedCorners) { glide.transform( FitCenter(), - RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_80dp)) + RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_80dp)), ).into(imageView) } else { glide.into(imageView) @@ -276,7 +276,7 @@ class EditProfileActivity : BaseActivity(), Injectable { setImageSource(includeGallery = true, includeCamera = false) setOutputUri(viewModel.getAvatarUri()) setOutputCompressFormat(Bitmap.CompressFormat.PNG) - } + }, ) } PickType.HEADER -> { @@ -287,7 +287,7 @@ class EditProfileActivity : BaseActivity(), Injectable { setImageSource(includeGallery = true, includeCamera = false) setOutputUri(viewModel.getHeaderUri()) setOutputCompressFormat(Bitmap.CompressFormat.PNG) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt index 89b442a3a..e7c68444c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt @@ -96,7 +96,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { binding.listsRecycler.adapter = adapter binding.listsRecycler.layoutManager = LinearLayoutManager(this) binding.listsRecycler.addItemDecoration( - DividerItemDecoration(this, DividerItemDecoration.VERTICAL) + DividerItemDecoration(this, DividerItemDecoration.VERTICAL), ) binding.swipeRefreshLayout.setOnRefreshListener { viewModel.retryLoading() } @@ -132,7 +132,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { R.string.action_create_list } else { R.string.action_rename_list - } + }, ) { _, _ -> onPickedDialogName(binding.nameText.text.toString(), list?.id, binding.exclusiveCheckbox.isChecked) } @@ -190,7 +190,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) } else { binding.messageView.hide() @@ -202,13 +202,13 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { Snackbar.make( binding.listsRecycler, messageId, - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ).show() } private fun onListSelected(listId: String, listTitle: String) { startActivityWithSlideInAnimation( - StatusListActivity.newListIntent(this, listId, listTitle) + StatusListActivity.newListIntent(this, listId, listTitle), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index 049c22dd3..7a952c73c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -242,7 +242,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje changeAccount(requestedId, intent) } } - } + }, ) } } else if (openDrafts) { @@ -293,7 +293,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje setupDrawer( savedInstanceState, - addSearchButton = hideTopToolbar + addSearchButton = hideTopToolbar, ) /* Fetch user info while we're doing other things. This has to be done after setting up the @@ -317,7 +317,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData) is MainTabsChangedEvent -> { refreshMainDrawerItems( - addSearchButton = hideTopToolbar + addSearchButton = hideTopToolbar, ) setupTabs(false) @@ -354,14 +354,14 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje } } } - } + }, ) if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), - 1 + 1, ) } @@ -404,7 +404,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje Log.d( TAG, "onResume: EmojiPack has been changed from %s to %s" - .format(selectedEmojiPack, currentEmojiPack) + .format(selectedEmojiPack, currentEmojiPack), ) selectedEmojiPack = currentEmojiPack recreate() @@ -478,7 +478,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje private fun setupDrawer( savedInstanceState: Bundle?, - addSearchButton: Boolean + addSearchButton: Boolean, ) { val drawerOpenClickListener = View.OnClickListener { binding.mainDrawerLayout.open() } @@ -497,7 +497,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje descriptionRes = R.string.add_account_description iconicsIcon = GoogleMaterial.Icon.gmd_add }, - 0 + 0, ) attachToSliderView(binding.mainDrawer) dividerBelowHeader = false @@ -511,32 +511,34 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje header.accountHeaderBackground.setBackgroundColor(MaterialColors.getColor(header, R.attr.colorBackgroundAccent)) val animateAvatars = preferences.getBoolean("animateGifAvatars", false) - DrawerImageLoader.init(object : AbstractDrawerImageLoader() { - override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { - if (animateAvatars) { - glide.load(uri) - .placeholder(placeholder) - .into(imageView) - } else { - glide.asBitmap() - .load(uri) - .placeholder(placeholder) - .into(imageView) - } - } - - override fun cancel(imageView: ImageView) { - glide.clear(imageView) - } - - override fun placeholder(ctx: Context, tag: String?): Drawable { - if (tag == DrawerImageLoader.Tags.PROFILE.name || tag == DrawerImageLoader.Tags.PROFILE_DRAWER_ITEM.name) { - return ctx.getDrawable(R.drawable.avatar_default)!! + DrawerImageLoader.init( + object : AbstractDrawerImageLoader() { + override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { + if (animateAvatars) { + glide.load(uri) + .placeholder(placeholder) + .into(imageView) + } else { + glide.asBitmap() + .load(uri) + .placeholder(placeholder) + .into(imageView) + } } - return super.placeholder(ctx, tag) - } - }) + override fun cancel(imageView: ImageView) { + glide.clear(imageView) + } + + override fun placeholder(ctx: Context, tag: String?): Drawable { + if (tag == DrawerImageLoader.Tags.PROFILE.name || tag == DrawerImageLoader.Tags.PROFILE_DRAWER_ITEM.name) { + return ctx.getDrawable(R.drawable.avatar_default)!! + } + + return super.placeholder(ctx, tag) + } + }, + ) binding.mainDrawer.apply { refreshMainDrawerItems(addSearchButton) @@ -645,7 +647,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje nameRes = R.string.action_logout iconRes = R.drawable.ic_logout onClick = ::logout - } + }, ) if (addSearchButton) { @@ -657,7 +659,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje onClick = { startActivityWithSlideInAnimation(SearchActivity.getIntent(context)) } - } + }, ) } @@ -669,7 +671,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje onClick = { startActivityWithSlideInAnimation(TrendingActivity.getIntent(context)) } - } + }, ) } @@ -686,7 +688,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje onClick = { buildDeveloperToolsDialog().show() } - } + }, ) } @@ -699,8 +701,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje .setItems( arrayOf( "Clear home timeline cache", - "Remove first 40 statuses" - ) + "Remove first 40 statuses", + ), ) { _, which -> Log.d(TAG, "Developer tools: $which") when (which) { @@ -912,7 +914,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje }, { throwable -> Log.e(TAG, "Failed to fetch user info. " + throwable.message) - } + }, ) } @@ -962,57 +964,61 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje .apply { if (showPlaceholder) placeholder(R.drawable.avatar_default) } - .into(object : CustomTarget(navIconSize, navIconSize) { + .into( + object : CustomTarget(navIconSize, navIconSize) { - override fun onLoadStarted(placeholder: Drawable?) { - placeholder?.let { - activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + override fun onLoadStarted(placeholder: Drawable?) { + placeholder?.let { + activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + } } - } - override fun onResourceReady( - resource: Drawable, - transition: Transition? - ) { - if (resource is Animatable) resource.start() - activeToolbar.navigationIcon = FixedSizeDrawable(resource, navIconSize, navIconSize) - } - - override fun onLoadCleared(placeholder: Drawable?) { - placeholder?.let { - activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + override fun onResourceReady( + resource: Drawable, + transition: Transition?, + ) { + if (resource is Animatable) resource.start() + activeToolbar.navigationIcon = FixedSizeDrawable(resource, navIconSize, navIconSize) } - } - }) + + override fun onLoadCleared(placeholder: Drawable?) { + placeholder?.let { + activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + } + } + }, + ) } else { glide.asBitmap().load(avatarUrl).transform(RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_36dp))) .apply { if (showPlaceholder) placeholder(R.drawable.avatar_default) } - .into(object : CustomTarget(navIconSize, navIconSize) { - override fun onLoadStarted(placeholder: Drawable?) { - placeholder?.let { - activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + .into( + object : CustomTarget(navIconSize, navIconSize) { + override fun onLoadStarted(placeholder: Drawable?) { + placeholder?.let { + activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + } } - } - override fun onResourceReady( - resource: Bitmap, - transition: Transition? - ) { - activeToolbar.navigationIcon = FixedSizeDrawable( - BitmapDrawable(resources, resource), - navIconSize, - navIconSize - ) - } - - override fun onLoadCleared(placeholder: Drawable?) { - placeholder?.let { - activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + override fun onResourceReady( + resource: Bitmap, + transition: Transition?, + ) { + activeToolbar.navigationIcon = FixedSizeDrawable( + BitmapDrawable(resources, resource), + navIconSize, + navIconSize, + ) } - } - }) + + override fun onLoadCleared(placeholder: Drawable?) { + placeholder?.let { + activeToolbar.navigationIcon = FixedSizeDrawable(it, navIconSize, navIconSize) + } + } + }, + ) } } @@ -1026,7 +1032,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje }, { throwable -> Log.w(TAG, "Failed to fetch announcements.", throwable) - } + }, ) } } @@ -1114,7 +1120,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje options: ComposeActivity.ComposeOptions, tuskyAccountId: Long = -1, notificationTag: String? = null, - notificationId: Int = -1 + notificationId: Int = -1, ): Intent { return accountSwitchIntent(context, tuskyAccountId).apply { action = Intent.ACTION_SEND // so it can be opened via shortcuts diff --git a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt index f8f3b930c..c6507413f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt @@ -114,7 +114,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { }, { Log.w(TAG, "Failed to query tag #$tag", it) - } + }, ) } } @@ -134,7 +134,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { { Snackbar.make(binding.root, getString(R.string.error_following_hashtag_format, tag), Snackbar.LENGTH_SHORT).show() Log.e(TAG, "Failed to follow #$tag", it) - } + }, ) } } @@ -154,7 +154,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { { Snackbar.make(binding.root, getString(R.string.error_unfollowing_hashtag_format, tag), Snackbar.LENGTH_SHORT).show() Log.e(TAG, "Failed to unfollow #$tag", it) - } + }, ) } } @@ -193,12 +193,12 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { }, { throwable -> Log.e(TAG, "Error getting filters: $throwable") - } + }, ) } else { Log.e(TAG, "Error getting filters: $throwable") } - } + }, ) } } @@ -223,7 +223,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { title = "#$tag", context = listOf(FilterV1.HOME), filterAction = Filter.Action.WARN.action, - expiresInSeconds = null + expiresInSeconds = null, ).fold( { filter -> if (mastodonApi.addFilterKeyword(filterId = filter.id, keyword = tag, wholeWord = true).isSuccess) { @@ -242,7 +242,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { listOf(FilterV1.HOME), irreversible = false, wholeWord = true, - expiresInSeconds = null + expiresInSeconds = null, ).fold( { filter -> mutedFilterV1 = filter @@ -252,13 +252,13 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { { throwable -> Snackbar.make(binding.root, getString(R.string.error_muting_hashtag_format, tag), Snackbar.LENGTH_SHORT).show() Log.e(TAG, "Failed to mute #$tag", throwable) - } + }, ) } else { Snackbar.make(binding.root, getString(R.string.error_muting_hashtag_format, tag), Snackbar.LENGTH_SHORT).show() Log.e(TAG, "Failed to mute #$tag", throwable) } - } + }, ) } @@ -274,7 +274,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { // This filter exists in multiple contexts, just remove the home context mastodonApi.updateFilter( id = filter.id, - context = filter.context.filter { it != Filter.Kind.HOME.kind } + context = filter.context.filter { it != Filter.Kind.HOME.kind }, ) } else { mastodonApi.deleteFilter(filter.id) @@ -289,7 +289,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { context = filter.context.filter { it != FilterV1.HOME }, irreversible = null, wholeWord = null, - expiresInSeconds = null + expiresInSeconds = null, ) } else { mastodonApi.deleteFilterV1(filter.id) @@ -309,7 +309,7 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector { { throwable -> Snackbar.make(binding.root, getString(R.string.error_unmuting_hashtag_format, tag), Snackbar.LENGTH_SHORT).show() Log.e(TAG, "Failed to unmute #$tag", throwable) - } + }, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/TabData.kt b/app/src/main/java/com/keylesspalace/tusky/TabData.kt index 4fa801392..424b6d837 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabData.kt @@ -47,7 +47,7 @@ data class TabData( @DrawableRes val icon: Int, val fragment: (List) -> Fragment, val arguments: List = emptyList(), - val title: (Context) -> String = { context -> context.getString(text) } + val title: (Context) -> String = { context -> context.getString(text) }, ) { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -70,49 +70,49 @@ fun createTabDataFromId(id: String, arguments: List = emptyList()): TabD id = HOME, text = R.string.title_home, icon = R.drawable.ic_home_24dp, - fragment = { TimelineFragment.newInstance(TimelineKind.Home) } + fragment = { TimelineFragment.newInstance(TimelineKind.Home) }, ) NOTIFICATIONS -> TabData( id = NOTIFICATIONS, text = R.string.title_notifications, icon = R.drawable.ic_notifications_24dp, - fragment = { NotificationsFragment.newInstance() } + fragment = { NotificationsFragment.newInstance() }, ) LOCAL -> TabData( id = LOCAL, text = R.string.title_public_local, icon = R.drawable.ic_local_24dp, - fragment = { TimelineFragment.newInstance(TimelineKind.PublicLocal) } + fragment = { TimelineFragment.newInstance(TimelineKind.PublicLocal) }, ) FEDERATED -> TabData( id = FEDERATED, text = R.string.title_public_federated, icon = R.drawable.ic_public_24dp, - fragment = { TimelineFragment.newInstance(TimelineKind.PublicFederated) } + fragment = { TimelineFragment.newInstance(TimelineKind.PublicFederated) }, ) DIRECT -> TabData( id = DIRECT, text = R.string.title_direct_messages, icon = R.drawable.ic_reblog_direct_24dp, - fragment = { ConversationsFragment.newInstance() } + fragment = { ConversationsFragment.newInstance() }, ) TRENDING_TAGS -> TabData( id = TRENDING_TAGS, text = R.string.title_public_trending_hashtags, icon = R.drawable.ic_trending_up_24px, - fragment = { TrendingTagsFragment.newInstance() } + fragment = { TrendingTagsFragment.newInstance() }, ) TRENDING_LINKS -> TabData( id = TRENDING_LINKS, text = R.string.title_public_trending_links, icon = R.drawable.ic_trending_up_24px, - fragment = { TrendingLinksFragment.newInstance() } + fragment = { TrendingLinksFragment.newInstance() }, ) TRENDING_STATUSES -> TabData( id = TRENDING_STATUSES, text = R.string.title_public_trending_statuses, icon = R.drawable.ic_trending_up_24px, - fragment = { TimelineFragment.newInstance(TimelineKind.TrendingStatuses) } + fragment = { TimelineFragment.newInstance(TimelineKind.TrendingStatuses) }, ) HASHTAG -> TabData( id = HASHTAG, @@ -120,7 +120,7 @@ fun createTabDataFromId(id: String, arguments: List = emptyList()): TabD icon = R.drawable.ic_hashtag, fragment = { args -> TimelineFragment.newInstance(TimelineKind.Tag(args)) }, arguments = arguments, - title = { context -> arguments.joinToString(separator = " ") { context.getString(R.string.title_tag, it) } } + title = { context -> arguments.joinToString(separator = " ") { context.getString(R.string.title_tag, it) } }, ) LIST -> TabData( id = LIST, @@ -128,13 +128,13 @@ fun createTabDataFromId(id: String, arguments: List = emptyList()): TabD icon = R.drawable.ic_list, fragment = { args -> TimelineFragment.newInstance(TimelineKind.UserList(args.first(), args.last())) }, arguments = arguments, - title = { arguments.getOrNull(1).orEmpty() } + title = { arguments.getOrNull(1).orEmpty() }, ) BOOKMARKS -> TabData( id = BOOKMARKS, text = R.string.title_bookmarks, icon = R.drawable.ic_bookmark_active_24dp, - fragment = { TimelineFragment.newInstance(TimelineKind.Bookmarks) } + fragment = { TimelineFragment.newInstance(TimelineKind.Bookmarks) }, ) else -> throw IllegalArgumentException("unknown tab type") } @@ -145,6 +145,6 @@ fun defaultTabs(): List { createTabDataFromId(HOME), createTabDataFromId(NOTIFICATIONS), createTabDataFromId(LOCAL), - createTabDataFromId(DIRECT) + createTabDataFromId(DIRECT), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt index 20304b89c..03d4448e5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt @@ -115,44 +115,46 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene binding.addTabRecyclerView.adapter = addTabAdapter binding.addTabRecyclerView.layoutManager = LinearLayoutManager(this) - touchHelper = ItemTouchHelper(object : ItemTouchHelper.Callback() { - override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int { - return makeMovementFlags(ItemTouchHelper.UP or ItemTouchHelper.DOWN, ItemTouchHelper.END) - } - - override fun isLongPressDragEnabled(): Boolean { - return true - } - - override fun isItemViewSwipeEnabled(): Boolean { - return MIN_TAB_COUNT < currentTabs.size - } - - override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { - val temp = currentTabs[viewHolder.bindingAdapterPosition] - currentTabs[viewHolder.bindingAdapterPosition] = currentTabs[target.bindingAdapterPosition] - currentTabs[target.bindingAdapterPosition] = temp - - currentTabsAdapter.notifyItemMoved(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition) - saveTabs() - return true - } - - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { - onTabRemoved(viewHolder.bindingAdapterPosition) - } - - override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) { - if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { - viewHolder?.itemView?.elevation = selectedItemElevation + touchHelper = ItemTouchHelper( + object : ItemTouchHelper.Callback() { + override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int { + return makeMovementFlags(ItemTouchHelper.UP or ItemTouchHelper.DOWN, ItemTouchHelper.END) } - } - override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { - super.clearView(recyclerView, viewHolder) - viewHolder.itemView.elevation = 0f - } - }) + override fun isLongPressDragEnabled(): Boolean { + return true + } + + override fun isItemViewSwipeEnabled(): Boolean { + return MIN_TAB_COUNT < currentTabs.size + } + + override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { + val temp = currentTabs[viewHolder.bindingAdapterPosition] + currentTabs[viewHolder.bindingAdapterPosition] = currentTabs[target.bindingAdapterPosition] + currentTabs[target.bindingAdapterPosition] = temp + + currentTabsAdapter.notifyItemMoved(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition) + saveTabs() + return true + } + + override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { + onTabRemoved(viewHolder.bindingAdapterPosition) + } + + override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) { + if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { + viewHolder?.itemView?.elevation = selectedItemElevation + } + } + + override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { + super.clearView(recyclerView, viewHolder) + viewHolder.itemView.elevation = 0f + } + }, + ) touchHelper.attachToRecyclerView(binding.currentTabsRecyclerView) @@ -327,13 +329,13 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene dialog.hide() Log.e("TabPreferenceActivity", "failed to load lists", throwable) Snackbar.make(binding.root, R.string.error_list_load, Snackbar.LENGTH_LONG).show() - } + }, ) } } private fun getProgressBarJob(progressView: View, delayMs: Long) = this.lifecycleScope.launch( - start = CoroutineStart.LAZY + start = CoroutineStart.LAZY, ) { try { delay(delayMs) diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt index c2dfc2f15..fb3dc8e33 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt @@ -105,7 +105,7 @@ class TuskyApplication : Application(), HasAndroidInjector { this, androidx.work.Configuration.Builder() .setWorkerFactory(workerFactory) - .build() + .build(), ) // Prune the database every ~ 12 hours when the device is idle. @@ -115,7 +115,7 @@ class TuskyApplication : Application(), HasAndroidInjector { WorkManager.getInstance(this).enqueueUniquePeriodicWork( PruneCacheWorker.PERIODIC_WORK_TAG, ExistingPeriodicWorkPolicy.KEEP, - pruneCacheWorker + pruneCacheWorker, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index 88b330c84..8fa07d91c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -121,11 +121,13 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. binding.viewPager.adapter = adapter binding.viewPager.setCurrentItem(initialPosition, false) - binding.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { - override fun onPageSelected(position: Int) { - binding.toolbar.title = getPageTitle(position) - } - }) + binding.viewPager.registerOnPageChangeCallback( + object : ViewPager2.OnPageChangeCallback() { + override fun onPageSelected(position: Int) { + binding.toolbar.title = getPageTitle(position) + } + }, + ) // Setup the toolbar. setSupportActionBar(binding.toolbar) @@ -149,12 +151,14 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE window.statusBarColor = Color.BLACK - window.sharedElementEnterTransition.addListener(object : NoopTransitionListener { - override fun onTransitionEnd(transition: Transition) { - adapter.onTransitionEnd(binding.viewPager.currentItem) - window.sharedElementEnterTransition.removeListener(this) - } - }) + window.sharedElementEnterTransition.addListener( + object : NoopTransitionListener { + override fun onTransitionEnd(transition: Transition) { + adapter.onTransitionEnd(binding.viewPager.currentItem) + window.sharedElementEnterTransition.removeListener(this) + } + }, + ) } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -192,12 +196,14 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. } binding.toolbar.animate().alpha(alpha) - .setListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator) { - binding.toolbar.visibility = visibility - animation.removeListener(this) - } - }) + .setListener( + object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + binding.toolbar.visibility = visibility + animation.removeListener(this) + } + }, + ) .start() } @@ -228,7 +234,7 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. showErrorDialog( binding.toolbar, R.string.error_media_download_permission, - R.string.action_retry + R.string.action_retry, ) { requestDownloadMedia() } } } @@ -263,7 +269,8 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. Attachment.Type.IMAGE -> shareImage(directory, attachment.url) Attachment.Type.AUDIO, Attachment.Type.VIDEO, - Attachment.Type.GIFV -> shareMediaFile(directory, attachment.url) + Attachment.Type.GIFV, + -> shareMediaFile(directory, attachment.url) else -> Log.e(TAG, "Unknown media format for sharing.") } } @@ -321,7 +328,7 @@ class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment. invalidateOptionsMenu() binding.progressBarShare.visibility = View.GONE Log.e(TAG, "Failed to download image", error) - } + }, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.kt index a793cc64d..aff31bf1f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountViewHolder.kt @@ -28,7 +28,7 @@ import com.keylesspalace.tusky.util.loadAvatar import com.keylesspalace.tusky.util.visible class AccountViewHolder( - private val binding: ItemAccountBinding + private val binding: ItemAccountBinding, ) : RecyclerView.ViewHolder(binding.root) { private lateinit var accountId: String @@ -36,19 +36,19 @@ class AccountViewHolder( account: TimelineAccount, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) { accountId = account.id binding.accountUsername.text = binding.accountUsername.context.getString( R.string.post_username_format, - account.username + account.username, ) val emojifiedName = account.name.emojify( account.emojis, binding.accountDisplayName, - animateEmojis + animateEmojis, ) binding.accountDisplayName.text = emojifiedName @@ -66,7 +66,7 @@ class AccountViewHolder( fun setupLinkListener(listener: LinkListener) { itemView.setOnClickListener { listener.onViewAccount( - accountId + accountId, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt index 51aa43f73..2d07ffecd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt @@ -28,7 +28,7 @@ import java.util.Locale class EmojiAdapter( emojiList: List, private val onEmojiSelectedListener: OnEmojiSelectedListener, - private val animate: Boolean + private val animate: Boolean, ) : RecyclerView.Adapter>() { private val emojiList: List = emojiList.filter { emoji -> emoji.visibleInPicker == null || emoji.visibleInPicker } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestViewHolder.kt index 9efb1b96b..5b2bf8fa6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/FollowRequestViewHolder.kt @@ -43,13 +43,13 @@ class FollowRequestViewHolder( private val binding: ItemFollowRequestBinding, private val accountActionListener: AccountActionListener, private val linkListener: LinkListener, - private val showHeader: Boolean + private val showHeader: Boolean, ) : NotificationsPagingAdapter.ViewHolder, RecyclerView.ViewHolder(binding.root) { override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { // Skip updates with payloads. That indicates a timestamp update, and // this view does not have timestamps. @@ -59,7 +59,7 @@ class FollowRequestViewHolder( viewData.account, statusDisplayOptions.animateAvatars, statusDisplayOptions.animateEmojis, - statusDisplayOptions.showBotOverlay + statusDisplayOptions.showBotOverlay, ) setupActionListener(accountActionListener, viewData.account.id) @@ -69,26 +69,26 @@ class FollowRequestViewHolder( account: TimelineAccount, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) { val wrappedName = account.name.unicodeWrap() val emojifiedName: CharSequence = wrappedName.emojify( account.emojis, itemView, - animateEmojis + animateEmojis, ) binding.displayNameTextView.text = emojifiedName if (showHeader) { val wholeMessage: String = itemView.context.getString( R.string.notification_follow_request_format, - wrappedName + wrappedName, ) binding.notificationTextView.text = SpannableStringBuilder(wholeMessage).apply { setSpan( StyleSpan(Typeface.BOLD), 0, wrappedName.length, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE, ) }.emojify(account.emojis, itemView, animateEmojis) } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt index 3e4e1dad9..3986ea54e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt @@ -49,7 +49,7 @@ class PollAdapter : RecyclerView.Adapter>() { mode: Int, resultClickListener: View.OnClickListener?, animateEmojis: Boolean, - enabled: Boolean = true + enabled: Boolean = true, ) { this.pollOptions = options this.voteCount = voteCount diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt index 22b093913..cf3a7dc0f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt @@ -37,13 +37,13 @@ import java.util.Date class ReportNotificationViewHolder( private val binding: ItemReportNotificationBinding, - private val notificationActionListener: NotificationActionListener + private val notificationActionListener: NotificationActionListener, ) : NotificationsPagingAdapter.ViewHolder, RecyclerView.ViewHolder(binding.root) { override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { // Skip updates with payloads. That indicates a timestamp update, and // this view does not have timestamps. @@ -53,13 +53,13 @@ class ReportNotificationViewHolder( viewData.account, viewData.report!!, statusDisplayOptions.animateAvatars, - statusDisplayOptions.animateEmojis + statusDisplayOptions.animateEmojis, ) setupActionListener( notificationActionListener, viewData.report.targetAccount.id, viewData.account.id, - viewData.report.id + viewData.report.id, ) } @@ -67,17 +67,17 @@ class ReportNotificationViewHolder( reporter: TimelineAccount, report: Report, animateAvatar: Boolean, - animateEmojis: Boolean + animateEmojis: Boolean, ) { val reporterName = reporter.name.unicodeWrap().emojify( reporter.emojis, binding.root, - animateEmojis + animateEmojis, ) val reporteeName = report.targetAccount.name.unicodeWrap().emojify( report.targetAccount.emojis, itemView, - animateEmojis + animateEmojis, ) val icon = ContextCompat.getDrawable(binding.root.context, R.drawable.ic_flag_24dp) @@ -85,12 +85,12 @@ class ReportNotificationViewHolder( binding.notificationTopText.text = itemView.context.getString( R.string.notification_header_report_format, reporterName, - reporteeName + reporteeName, ) binding.notificationSummary.text = itemView.context.getString( R.string.notification_summary_report_format, getRelativeTimeSpanString(itemView.context, report.createdAt.time, Date().time), - report.status_ids?.size ?: 0 + report.status_ids?.size ?: 0, ) binding.notificationCategory.text = getTranslatedCategory(itemView.context, report.category) @@ -102,13 +102,13 @@ class ReportNotificationViewHolder( report.targetAccount.avatar, binding.notificationReporteeAvatar, itemView.context.resources.getDimensionPixelSize(R.dimen.avatar_radius_36dp), - animateAvatar + animateAvatar, ) loadAvatar( reporter.avatar, binding.notificationReporterAvatar, itemView.context.resources.getDimensionPixelSize(R.dimen.avatar_radius_24dp), - animateAvatar + animateAvatar, ) } @@ -116,7 +116,7 @@ class ReportNotificationViewHolder( listener: NotificationActionListener, reporteeId: String, reporterId: String, - reportId: String + reportId: String, ) { binding.notificationReporteeAvatar.setOnClickListener { val position = bindingAdapterPosition diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt index e3e4f27e8..d92cc90e4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt @@ -46,7 +46,7 @@ class TabAdapter( private var data: List, private val small: Boolean, private val listener: ItemInteractionListener, - private var removeButtonEnabled: Boolean = false + private var removeButtonEnabled: Boolean = false, ) : RecyclerView.Adapter>() { fun updateData(newData: List) { @@ -103,7 +103,7 @@ class TabAdapter( setDrawableTint( holder.itemView.context, binding.removeButton.drawable, - (if (removeButtonEnabled) android.R.attr.textColorTertiary else R.attr.textColorDisabled) + (if (removeButtonEnabled) android.R.attr.textColorTertiary else R.attr.textColorDisabled), ) if (tab.id == HASHTAG) { diff --git a/app/src/main/java/com/keylesspalace/tusky/appstore/CacheUpdater.kt b/app/src/main/java/com/keylesspalace/tusky/appstore/CacheUpdater.kt index 9515457b3..959295c23 100644 --- a/app/src/main/java/com/keylesspalace/tusky/appstore/CacheUpdater.kt +++ b/app/src/main/java/com/keylesspalace/tusky/appstore/CacheUpdater.kt @@ -14,7 +14,7 @@ class CacheUpdater @Inject constructor( eventHub: EventHub, accountManager: AccountManager, appDatabase: AppDatabase, - gson: Gson + gson: Gson, ) { private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt index f5e962d8e..0d52d0e1a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt @@ -155,7 +155,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide private enum class FollowState { NOT_FOLLOWING, FOLLOWING, - REQUESTED + REQUESTED, } private lateinit var adapter: AccountPagerAdapter @@ -273,17 +273,19 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide val enableSwipeForTabs = preferences.getBoolean(PrefKeys.ENABLE_SWIPE_FOR_TABS, true) binding.accountFragmentViewPager.isUserInputEnabled = enableSwipeForTabs - binding.accountTabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { - override fun onTabReselected(tab: TabLayout.Tab?) { - tab?.position?.let { position -> - (adapter.getFragment(position) as? ReselectableFragment)?.onReselect() + binding.accountTabLayout.addOnTabSelectedListener( + object : TabLayout.OnTabSelectedListener { + override fun onTabReselected(tab: TabLayout.Tab?) { + tab?.position?.let { position -> + (adapter.getFragment(position) as? ReselectableFragment)?.onReselect() + } } - } - override fun onTabUnselected(tab: TabLayout.Tab?) {} + override fun onTabUnselected(tab: TabLayout.Tab?) {} - override fun onTabSelected(tab: TabLayout.Tab?) {} - }) + override fun onTabSelected(tab: TabLayout.Tab?) {} + }, + ) } private fun handleWindowInsets() { @@ -323,14 +325,14 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide binding.accountToolbar.navigationIcon = LayerDrawable( arrayOf( backgroundCircle, - binding.accountToolbar.navigationIcon - ) + binding.accountToolbar.navigationIcon, + ), ) binding.accountToolbar.overflowIcon = LayerDrawable( arrayOf( backgroundCircle, - binding.accountToolbar.overflowIcon - ) + binding.accountToolbar.overflowIcon, + ), ) binding.accountHeaderInfoContainer.background = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation) @@ -345,47 +347,49 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide binding.accountAvatarImageView.background = avatarBackground // Add a listener to change the toolbar icon color when it enters/exits its collapsed state. - binding.accountAppBarLayout.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener { + binding.accountAppBarLayout.addOnOffsetChangedListener( + object : AppBarLayout.OnOffsetChangedListener { - override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) { - if (verticalOffset == oldOffset) { - return - } - oldOffset = verticalOffset - - if (titleVisibleHeight + verticalOffset < 0) { - supportActionBar?.setDisplayShowTitleEnabled(true) - } else { - supportActionBar?.setDisplayShowTitleEnabled(false) - } - - if (hideFab && !blocking) { - if (verticalOffset > oldOffset) { - binding.accountFloatingActionButton.show() + override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) { + if (verticalOffset == oldOffset) { + return } - if (verticalOffset < oldOffset) { - binding.accountFloatingActionButton.hide() + oldOffset = verticalOffset + + if (titleVisibleHeight + verticalOffset < 0) { + supportActionBar?.setDisplayShowTitleEnabled(true) + } else { + supportActionBar?.setDisplayShowTitleEnabled(false) } + + if (hideFab && !blocking) { + if (verticalOffset > oldOffset) { + binding.accountFloatingActionButton.show() + } + if (verticalOffset < oldOffset) { + binding.accountFloatingActionButton.hide() + } + } + + val scaledAvatarSize = (avatarSize + verticalOffset) / avatarSize + + binding.accountAvatarImageView.scaleX = scaledAvatarSize + binding.accountAvatarImageView.scaleY = scaledAvatarSize + + binding.accountAvatarImageView.visible(scaledAvatarSize > 0) + + val transparencyPercent = (abs(verticalOffset) / titleVisibleHeight.toFloat()).coerceAtMost(1f) + + window.statusBarColor = argbEvaluator.evaluate(transparencyPercent, statusBarColorTransparent, statusBarColorOpaque) as Int + + val evaluatedToolbarColor = argbEvaluator.evaluate(transparencyPercent, Color.TRANSPARENT, toolbarColor) as Int + + toolbarBackground.fillColor = ColorStateList.valueOf(evaluatedToolbarColor) + + binding.swipeToRefreshLayout.isEnabled = verticalOffset == 0 } - - val scaledAvatarSize = (avatarSize + verticalOffset) / avatarSize - - binding.accountAvatarImageView.scaleX = scaledAvatarSize - binding.accountAvatarImageView.scaleY = scaledAvatarSize - - binding.accountAvatarImageView.visible(scaledAvatarSize > 0) - - val transparencyPercent = (abs(verticalOffset) / titleVisibleHeight.toFloat()).coerceAtMost(1f) - - window.statusBarColor = argbEvaluator.evaluate(transparencyPercent, statusBarColorTransparent, statusBarColorOpaque) as Int - - val evaluatedToolbarColor = argbEvaluator.evaluate(transparencyPercent, Color.TRANSPARENT, toolbarColor) as Int - - toolbarBackground.fillColor = ColorStateList.valueOf(evaluatedToolbarColor) - - binding.swipeToRefreshLayout.isEnabled = verticalOffset == 0 - } - }) + }, + ) } private fun makeNotificationBarTransparent() { @@ -439,7 +443,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide private fun setupRefreshLayout() { binding.swipeToRefreshLayout.setOnRefreshListener { onRefresh() } viewModel.isRefreshing.observe( - this + this, ) { isRefreshing -> binding.swipeToRefreshLayout.isRefreshing = isRefreshing == true } @@ -496,7 +500,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide try { binding.accountDateJoined.text = resources.getString( R.string.account_date_joined, - SimpleDateFormat("MMMM, yyyy", Locale.getDefault()).format(account.createdAt) + SimpleDateFormat("MMMM, yyyy", Locale.getDefault()).format(account.createdAt), ) binding.accountDateJoined.visibility = View.VISIBLE } catch (e: ParseException) { @@ -515,7 +519,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide account.avatar, binding.accountAvatarImageView, resources.getDimensionPixelSize(R.dimen.avatar_radius_94dp), - animateAvatar + animateAvatar, ) Glide.with(this) @@ -537,7 +541,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide view.transitionName = uri startActivity( ViewMediaActivity.newSingleImageIntent(view.context, uri), - ActivityOptionsCompat.makeSceneTransitionAnimation(this, view, uri).toBundle() + ActivityOptionsCompat.makeSceneTransitionAnimation(this, view, uri).toBundle(), ) } @@ -863,7 +867,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide loadedAccount?.let { showMuteAccountDialog( this, - it.username + it.username, ) { notifications, duration -> viewModel.muteAccount(notifications, duration) } @@ -880,7 +884,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide } else { ComposeActivity.ComposeOptions( mentionedUsernames = setOf(it.username), - kind = ComposeActivity.ComposeKind.NEW + kind = ComposeActivity.ComposeKind.NEW, ) } val intent = ComposeActivity.startIntent(this, options) @@ -921,7 +925,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide override fun onAccountSelected(account: AccountEntity) { openAsAccount(loadedAccount.url, account) } - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt index 86acb8132..9358e6ce9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountFieldAdapter.kt @@ -30,7 +30,7 @@ import com.keylesspalace.tusky.util.setClickableText class AccountFieldAdapter( private val linkListener: LinkListener, - private val animateEmojis: Boolean + private val animateEmojis: Boolean, ) : RecyclerView.Adapter>() { var emojis: List = emptyList() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountPagerAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountPagerAdapter.kt index 5649c28b4..395e5f302 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountPagerAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountPagerAdapter.kt @@ -25,7 +25,7 @@ import com.keylesspalace.tusky.util.CustomFragmentStateAdapter class AccountPagerAdapter( activity: FragmentActivity, - private val accountId: String + private val accountId: String, ) : CustomFragmentStateAdapter(activity) { override fun getItemCount() = TAB_COUNT diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt index b12e3923d..ff282e897 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt @@ -28,7 +28,7 @@ import javax.inject.Inject class AccountViewModel @Inject constructor( private val mastodonApi: MastodonApi, private val eventHub: EventHub, - accountManager: AccountManager + accountManager: AccountManager, ) : ViewModel() { val accountData = MutableLiveData>() @@ -79,7 +79,7 @@ class AccountViewModel @Inject constructor( accountData.postValue(Error(cause = t)) isDataLoading = false isRefreshing.postValue(false) - } + }, ) } } @@ -98,7 +98,7 @@ class AccountViewModel @Inject constructor( { t -> Log.w(TAG, "failed obtaining relationships", t) relationshipData.postValue(Error(cause = t)) - } + }, ) } } @@ -150,7 +150,7 @@ class AccountViewModel @Inject constructor( } }, { e -> Log.e(TAG, "Error muting $instance", e) - }) + },) } } @@ -163,7 +163,7 @@ class AccountViewModel @Inject constructor( } }, { e -> Log.e(TAG, "Error unmuting $instance", e) - }) + },) } } @@ -181,7 +181,7 @@ class AccountViewModel @Inject constructor( private fun changeRelationship( relationshipAction: RelationShipAction, parameter: Boolean? = null, - duration: Int? = null + duration: Int? = null, ) = viewModelScope.launch { val relation = relationshipData.value?.data val account = accountData.value?.data @@ -224,7 +224,7 @@ class AccountViewModel @Inject constructor( val relationshipCall = when (relationshipAction) { RelationShipAction.FOLLOW -> mastodonApi.followAccount( accountId, - showReblogs = parameter ?: true + showReblogs = parameter ?: true, ) RelationShipAction.UNFOLLOW -> mastodonApi.unfollowAccount(accountId) RelationShipAction.BLOCK -> mastodonApi.blockAccount(accountId) @@ -232,7 +232,7 @@ class AccountViewModel @Inject constructor( RelationShipAction.MUTE -> mastodonApi.muteAccount( accountId, parameter ?: true, - duration + duration, ) RelationShipAction.UNMUTE -> mastodonApi.unmuteAccount(accountId) RelationShipAction.SUBSCRIBE -> { @@ -265,7 +265,7 @@ class AccountViewModel @Inject constructor( { t -> Log.w(TAG, "failed loading relationship", t) relationshipData.postValue(Error(relation, cause = t)) - } + }, ) } @@ -283,7 +283,7 @@ class AccountViewModel @Inject constructor( }, { t -> Log.w(TAG, "Error updating note", t) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountFragment.kt index 08c93756b..a0836705b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountFragment.kt @@ -64,7 +64,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable { dialog?.apply { window?.setLayout( LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT + LinearLayout.LayoutParams.MATCH_PARENT, ) } } @@ -72,7 +72,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { return inflater.inflate(R.layout.fragment_lists_for_account, container, false) } @@ -145,14 +145,14 @@ class ListsForAccountFragment : DialogFragment(), Injectable { private object Differ : DiffUtil.ItemCallback() { override fun areItemsTheSame( oldItem: AccountListState, - newItem: AccountListState + newItem: AccountListState, ): Boolean { return oldItem.list.id == newItem.list.id } override fun areContentsTheSame( oldItem: AccountListState, - newItem: AccountListState + newItem: AccountListState, ): Boolean { return oldItem == newItem } @@ -162,7 +162,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable { ListAdapter>(Differ) { override fun onCreateViewHolder( parent: ViewGroup, - viewType: Int + viewType: Int, ): BindingHolder { val binding = ItemAddOrRemoveFromListBinding.inflate(LayoutInflater.from(parent.context), parent, false) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt index 110096966..9de51c8d7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt @@ -35,23 +35,23 @@ import javax.inject.Inject data class AccountListState( val list: MastoList, - val includesAccount: Boolean + val includesAccount: Boolean, ) data class ActionError( val error: Throwable, val type: Type, - val listId: String + val listId: String, ) : Throwable(error) { enum class Type { ADD, - REMOVE + REMOVE, } } @OptIn(ExperimentalCoroutinesApi::class) class ListsForAccountViewModel @Inject constructor( - private val mastodonApi: MastodonApi + private val mastodonApi: MastodonApi, ) : ViewModel() { private lateinit var accountId: String @@ -75,16 +75,16 @@ class ListsForAccountViewModel @Inject constructor( runCatching { val (all, includes) = listOf( async { mastodonApi.getLists() }, - async { mastodonApi.getListsIncludesAccount(accountId) } + async { mastodonApi.getListsIncludesAccount(accountId) }, ).awaitAll() _states.emit( all.getOrThrow().map { list -> AccountListState( list = list, - includesAccount = includes.getOrThrow().any { it.id == list.id } + includesAccount = includes.getOrThrow().any { it.id == list.id }, ) - } + }, ) } .onFailure { @@ -105,7 +105,7 @@ class ListsForAccountViewModel @Inject constructor( } else { state } - } + }, ) } .onFailure { @@ -126,7 +126,7 @@ class ListsForAccountViewModel @Inject constructor( } else { state } - } + }, ) } .onFailure { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaFragment.kt index 5a81c418e..7382e8ac5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaFragment.kt @@ -88,7 +88,7 @@ class AccountMediaFragment : adapter = AccountMediaGridAdapter( useBlurhash = useBlurhash, context = view.context, - onAttachmentClickListener = ::onAttachmentClick + onAttachmentClickListener = ::onAttachmentClick, ) val columnCount = view.context.resources.getInteger(R.integer.profile_media_column_count) @@ -174,7 +174,8 @@ class AccountMediaFragment : Attachment.Type.IMAGE, Attachment.Type.GIFV, Attachment.Type.VIDEO, - Attachment.Type.AUDIO -> { + Attachment.Type.AUDIO, + -> { val intent = ViewMediaActivity.newIntent(context, attachmentsFromSameStatus, currentIndex) if (activity != null) { val url = selected.attachment.url diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaGridAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaGridAdapter.kt index aecbeb0bb..bf7570d37 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaGridAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaGridAdapter.kt @@ -26,7 +26,7 @@ import java.util.Random class AccountMediaGridAdapter( private val useBlurhash: Boolean, context: Context, - private val onAttachmentClickListener: (AttachmentViewData, View) -> Unit + private val onAttachmentClickListener: (AttachmentViewData, View) -> Unit, ) : PagingDataAdapter>( object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: AttachmentViewData, newItem: AttachmentViewData): Boolean { @@ -36,7 +36,7 @@ class AccountMediaGridAdapter( override fun areContentsTheSame(oldItem: AttachmentViewData, newItem: AttachmentViewData): Boolean { return oldItem == newItem } - } + }, ) { private val baseItemBackgroundColor = MaterialColors.getColor(context, com.google.android.material.R.attr.colorSurface, Color.BLACK) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaPagingSource.kt index 0ed67cf45..6c6fbe923 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaPagingSource.kt @@ -20,7 +20,7 @@ import androidx.paging.PagingState import com.keylesspalace.tusky.viewdata.AttachmentViewData class AccountMediaPagingSource( - private val viewModel: AccountMediaViewModel + private val viewModel: AccountMediaViewModel, ) : PagingSource() { override fun getRefreshKey(state: PagingState): String? = null diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaRemoteMediator.kt index 52535a6a5..8ea286031 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaRemoteMediator.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaRemoteMediator.kt @@ -29,11 +29,11 @@ import retrofit2.HttpException class AccountMediaRemoteMediator( private val api: MastodonApi, private val activeAccount: AccountEntity, - private val viewModel: AccountMediaViewModel + private val viewModel: AccountMediaViewModel, ) : RemoteMediator() { override suspend fun load( loadType: LoadType, - state: PagingState + state: PagingState, ): MediatorResult { try { val statusResponse = when (loadType) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaViewModel.kt index ee5ffd011..649028a63 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/AccountMediaViewModel.kt @@ -28,7 +28,7 @@ import javax.inject.Inject class AccountMediaViewModel @Inject constructor( private val accountManager: AccountManager, - api: MastodonApi + api: MastodonApi, ) : ViewModel() { lateinit var accountId: String @@ -43,16 +43,16 @@ class AccountMediaViewModel @Inject constructor( val media = Pager( config = PagingConfig( pageSize = LOAD_AT_ONCE, - prefetchDistance = LOAD_AT_ONCE * 2 + prefetchDistance = LOAD_AT_ONCE * 2, ), pagingSourceFactory = { AccountMediaPagingSource( - viewModel = this + viewModel = this, ).also { source -> currentSource = source } }, - remoteMediator = AccountMediaRemoteMediator(api, activeAccount, this) + remoteMediator = AccountMediaRemoteMediator(api, activeAccount, this), ).flow .cachedIn(viewModelScope) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/media/GridSpacingItemDecoration.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/media/GridSpacingItemDecoration.kt index 34ad159e8..92503a706 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/media/GridSpacingItemDecoration.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/media/GridSpacingItemDecoration.kt @@ -23,14 +23,14 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration class GridSpacingItemDecoration( private val spanCount: Int, private val spacing: Int, - private val topOffset: Int + private val topOffset: Int, ) : ItemDecoration() { override fun getItemOffsets( outRect: Rect, view: View, parent: RecyclerView, - state: RecyclerView.State + state: RecyclerView.State, ) { val position = parent.getChildAdapterPosition(view) // item position if (position < topOffset) return diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListActivity.kt index 2419dc915..4d0c8f416 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListActivity.kt @@ -38,7 +38,7 @@ class AccountListActivity : BottomSheetActivity(), HasAndroidInjector { MUTES, FOLLOW_REQUESTS, REBLOGGED, - FAVOURITED + FAVOURITED, } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt index 30d75402d..55e6f5871 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt @@ -115,7 +115,7 @@ class AccountListFragment : Type.FOLLOW_REQUESTS -> { val headerAdapter = FollowRequestsHeaderAdapter( instanceName = activeAccount.domain, - accountLocked = activeAccount.locked + accountLocked = activeAccount.locked, ) val followRequestsAdapter = FollowRequestsAdapter(this, this, animateAvatar, animateEmojis, showBotOverlay) binding.recyclerView.adapter = ConcatAdapter(headerAdapter, followRequestsAdapter) @@ -247,7 +247,7 @@ class AccountListFragment : override fun onRespondToFollowRequest( accept: Boolean, accountId: String, - position: Int + position: Int, ) { if (accept) { api.authorizeFollowRequest(accountId) @@ -266,7 +266,7 @@ class AccountListFragment : "reject" } Log.e(TAG, "Failed to $verb account id $accountId.", throwable) - } + }, ) } @@ -365,7 +365,7 @@ class AccountListFragment : binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) } else { binding.messageView.hide() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/AccountAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/AccountAdapter.kt index 7d050e7e4..1fa1db1b1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/AccountAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/AccountAdapter.kt @@ -28,7 +28,7 @@ abstract class AccountAdapter internal constructo protected val accountActionListener: AccountActionListener, protected val animateAvatar: Boolean, protected val animateEmojis: Boolean, - protected val showBotOverlay: Boolean + protected val showBotOverlay: Boolean, ) : RecyclerView.Adapter() { protected var accountList: MutableList = mutableListOf() @@ -51,7 +51,7 @@ abstract class AccountAdapter internal constructo final override fun onCreateViewHolder( parent: ViewGroup, - viewType: Int + viewType: Int, ): RecyclerView.ViewHolder { return when (viewType) { VIEW_TYPE_ACCOUNT -> this.createAccountViewHolder(parent) @@ -61,7 +61,7 @@ abstract class AccountAdapter internal constructo } private fun createFooterViewHolder( - parent: ViewGroup + parent: ViewGroup, ): RecyclerView.ViewHolder { val binding = ItemFooterBinding.inflate(LayoutInflater.from(parent.context), parent, false) return BindingHolder(binding) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/BlocksAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/BlocksAdapter.kt index 2ef520d5e..2b95112f0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/BlocksAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/BlocksAdapter.kt @@ -30,12 +30,12 @@ class BlocksAdapter( accountActionListener: AccountActionListener, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) : AccountAdapter>( accountActionListener = accountActionListener, animateAvatar = animateAvatar, animateEmojis = animateEmojis, - showBotOverlay = showBotOverlay + showBotOverlay = showBotOverlay, ) { override fun createAccountViewHolder(parent: ViewGroup): BindingHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowAdapter.kt index 87b62486d..2b867ca13 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowAdapter.kt @@ -26,12 +26,12 @@ class FollowAdapter( accountActionListener: AccountActionListener, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) : AccountAdapter( accountActionListener = accountActionListener, animateAvatar = animateAvatar, animateEmojis = animateEmojis, - showBotOverlay = showBotOverlay + showBotOverlay = showBotOverlay, ) { override fun createAccountViewHolder(parent: ViewGroup): AccountViewHolder { @@ -44,7 +44,7 @@ class FollowAdapter( accountList[position], animateAvatar, animateEmojis, - showBotOverlay + showBotOverlay, ) viewHolder.setupActionListener(accountActionListener) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsAdapter.kt index fc860e59e..8707aaa49 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsAdapter.kt @@ -28,25 +28,25 @@ class FollowRequestsAdapter( private val linkListener: LinkListener, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) : AccountAdapter( accountActionListener = accountActionListener, animateAvatar = animateAvatar, animateEmojis = animateEmojis, - showBotOverlay = showBotOverlay + showBotOverlay = showBotOverlay, ) { override fun createAccountViewHolder(parent: ViewGroup): FollowRequestViewHolder { val binding = ItemFollowRequestBinding.inflate( LayoutInflater.from(parent.context), parent, - false + false, ) return FollowRequestViewHolder( binding, accountActionListener, linkListener, - showHeader = false + showHeader = false, ) } @@ -55,7 +55,7 @@ class FollowRequestsAdapter( account = accountList[position], animateAvatar = animateAvatar, animateEmojis = animateEmojis, - showBotOverlay = showBotOverlay + showBotOverlay = showBotOverlay, ) viewHolder.setupActionListener(accountActionListener, accountList[position].id) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsHeaderAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsHeaderAdapter.kt index 85cf4e20a..1b22aa71d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsHeaderAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/FollowRequestsHeaderAdapter.kt @@ -24,7 +24,7 @@ import com.keylesspalace.tusky.util.BindingHolder class FollowRequestsHeaderAdapter( private val instanceName: String, - private val accountLocked: Boolean + private val accountLocked: Boolean, ) : RecyclerView.Adapter>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/MutesAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/MutesAdapter.kt index 288d13394..24677205e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/MutesAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/adapter/MutesAdapter.kt @@ -31,12 +31,12 @@ class MutesAdapter( accountActionListener: AccountActionListener, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean + showBotOverlay: Boolean, ) : AccountAdapter>( accountActionListener = accountActionListener, animateAvatar = animateAvatar, animateEmojis = animateEmojis, - showBotOverlay = showBotOverlay + showBotOverlay = showBotOverlay, ) { private val mutingNotificationsMap = HashMap() @@ -83,7 +83,7 @@ class MutesAdapter( false, account.id, viewHolder.bindingAdapterPosition, - false + false, ) } binding.mutedUserMuteNotifications.setOnCheckedChangeListener { _, isChecked -> @@ -91,7 +91,7 @@ class MutesAdapter( true, account.id, viewHolder.bindingAdapterPosition, - isChecked + isChecked, ) } binding.root.setOnClickListener { accountActionListener.onViewAccount(account.id) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementAdapter.kt index 8f30c5e49..5686413f6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementAdapter.kt @@ -47,7 +47,7 @@ class AnnouncementAdapter( private var items: List = emptyList(), private val listener: AnnouncementActionListener, private val wellbeingEnabled: Boolean = false, - private val animateEmojis: Boolean = false + private val animateEmojis: Boolean = false, ) : RecyclerView.Adapter>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt index 8abad91ac..3154a25e6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt @@ -37,7 +37,7 @@ import javax.inject.Inject class AnnouncementsViewModel @Inject constructor( private val instanceInfoRepo: InstanceInfoRepository, private val mastodonApi: MastodonApi, - private val eventHub: EventHub + private val eventHub: EventHub, ) : ViewModel() { private val announcementsMutable = MutableLiveData>>() @@ -70,15 +70,15 @@ class AnnouncementsViewModel @Inject constructor( Log.d( TAG, "Failed to mark announcement as read.", - throwable + throwable, ) - } + }, ) } }, { announcementsMutable.postValue(Error(cause = it)) - } + }, ) } } @@ -98,7 +98,7 @@ class AnnouncementsViewModel @Inject constructor( if (reaction.name == name) { reaction.copy( count = reaction.count + 1, - me = true + me = true, ) } else { reaction @@ -113,22 +113,22 @@ class AnnouncementsViewModel @Inject constructor( 1, true, url, - staticUrl + staticUrl, ) - } + }, ) - } + }, ) } else { announcement } - } - ) + }, + ), ) }, { Log.w(TAG, "Failed to add reaction to the announcement.", it) - } + }, ) } } @@ -148,7 +148,7 @@ class AnnouncementsViewModel @Inject constructor( if (reaction.count > 1) { reaction.copy( count = reaction.count - 1, - me = false + me = false, ) } else { null @@ -156,18 +156,18 @@ class AnnouncementsViewModel @Inject constructor( } else { reaction } - } + }, ) } else { announcement } - } - ) + }, + ), ) }, { Log.w(TAG, "Failed to remove reaction from the announcement.", it) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index 14f9b947e..4b06ae299 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -191,7 +191,7 @@ class ComposeActivity : size, itemOld.description, null, // Intentionally reset focus when cropping - itemOld + itemOld, ) } } @@ -230,7 +230,7 @@ class ComposeActivity : // TODO this is inconsistent to CaptionDialog (device rotation)? }, onEditImage = this::editImageInQueue, - onRemove = this::removeMediaFromQueue + onRemove = this::removeMediaFromQueue, ) binding.composeMediaPreviewBar.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) @@ -248,7 +248,7 @@ class ComposeActivity : if (accountManager.shouldDisplaySelfUsername(this)) { binding.composeUsernameView.text = getString( R.string.compose_active_account_description, - activeAccount.fullName + activeAccount.fullName, ) binding.composeUsernameView.show() } else { @@ -380,8 +380,8 @@ class ComposeActivity : this, preferences.getBoolean(PrefKeys.ANIMATE_GIF_AVATARS, false), preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), - preferences.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true) - ) + preferences.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true), + ), ) binding.composeEditField.setTokenizer(ComposeTokenizer()) @@ -473,8 +473,8 @@ class ComposeActivity : displayTransientMessage( getString( R.string.error_media_upload_sending_fmt, - throwable.message - ) + throwable.message, + ), ) } } @@ -542,7 +542,7 @@ class ComposeActivity : handleCloseButton() } - } + }, ) } @@ -583,11 +583,11 @@ class ComposeActivity : activeAccount.profilePictureUrl, binding.composeAvatar, avatarSize / 8, - animateAvatars + animateAvatars, ) binding.composeAvatar.contentDescription = getString( R.string.compose_active_account_description, - activeAccount.fullName + activeAccount.fullName, ) } @@ -821,7 +821,7 @@ class ComposeActivity : ActivityCompat.requestPermissions( this@ComposeActivity, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), - PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE + PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE, ) } else { pickMediaFile.launch(true) @@ -830,7 +830,7 @@ class ComposeActivity : } override fun onSlide(bottomSheet: View, slideOffset: Float) {} - } + }, ) addMediaBehavior.state = BottomSheetBehavior.STATE_COLLAPSED } @@ -845,7 +845,7 @@ class ComposeActivity : maxOptionLength = instanceParams.pollMaxLength, minDuration = instanceParams.pollMinDuration, maxDuration = instanceParams.pollMaxDuration, - onUpdatePoll = viewModel::updatePoll + onUpdatePoll = viewModel::updatePoll, ) } @@ -889,7 +889,7 @@ class ComposeActivity : return statusLength( binding.composeEditField.text, binding.composeContentWarningField.text, - charactersReservedPerUrl + charactersReservedPerUrl, ) } @@ -935,7 +935,7 @@ class ComposeActivity : for (i in 0 until content.clip.itemCount) { pickMedia( content.clip.getItemAt(i).uri, - contentInfo.clip.description.label as String? + contentInfo.clip.description.label as String?, ) } } @@ -976,7 +976,7 @@ class ComposeActivity : Snackbar.make( binding.activityCompose, R.string.error_media_upload_permission, - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ).apply { setAction(R.string.action_retry) { onMediaPick() } // necessary so snackbar is shown over everything @@ -1001,7 +1001,7 @@ class ComposeActivity : photoUploadUri = FileProvider.getUriForFile( this, BuildConfig.APPLICATION_ID + ".fileprovider", - photoFile + photoFile, ) takePicture.launch(photoUploadUri) } @@ -1015,7 +1015,7 @@ class ComposeActivity : android.R.attr.textColorTertiary } else { R.attr.textColorDisabled - } + }, ) } @@ -1027,7 +1027,7 @@ class ComposeActivity : android.R.attr.textColorTertiary } else { R.attr.textColorDisabled - } + }, ) binding.addPollTextActionTextView.setTextColor(textColor) binding.addPollTextActionTextView.compoundDrawablesRelative[0].colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) @@ -1049,7 +1049,7 @@ class ComposeActivity : options(uri = item.uri) { setOutputUri(uriNew) setOutputCompressFormat(if (isPng) Bitmap.CompressFormat.PNG else Bitmap.CompressFormat.JPEG) - } + }, ) } @@ -1227,7 +1227,7 @@ class ComposeActivity : null, getString(R.string.saving_draft), true, - false + false, ) } else { null @@ -1263,7 +1263,7 @@ class ComposeActivity : val id: String? = null, val description: String? = null, val focus: Attachment.Focus? = null, - val state: State + val state: State, ) { enum class Type { IMAGE, VIDEO, AUDIO; @@ -1306,7 +1306,7 @@ class ComposeActivity : EDIT_DRAFT, /** Editing an an existing scheduled status */ - EDIT_SCHEDULED + EDIT_SCHEDULED, } @Parcelize @@ -1332,7 +1332,7 @@ class ComposeActivity : var modifiedInitialState: Boolean? = null, var language: String? = null, var statusId: String? = null, - var kind: ComposeKind? = null + var kind: ComposeKind? = null, ) : Parcelable companion object { @@ -1352,7 +1352,7 @@ class ComposeActivity : @JvmStatic fun startIntent( context: Context, - options: ComposeOptions + options: ComposeOptions, ): Intent { return Intent(context, ComposeActivity::class.java).apply { putExtra(COMPOSE_OPTIONS_EXTRA, options) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeAutoCompleteAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeAutoCompleteAdapter.kt index e825798cf..1fea71745 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeAutoCompleteAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeAutoCompleteAdapter.kt @@ -37,7 +37,7 @@ class ComposeAutoCompleteAdapter( private val autocompletionProvider: AutocompletionProvider, private val animateAvatar: Boolean, private val animateEmojis: Boolean, - private val showBotBadge: Boolean + private val showBotBadge: Boolean, ) : BaseAdapter(), Filterable { private var resultList: List = emptyList() @@ -113,7 +113,7 @@ class ComposeAutoCompleteAdapter( account.avatar, binding.avatar, avatarRadius, - animateAvatar + animateAvatar, ) binding.avatarBadge.visible(showBotBadge && account.bot) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt index 0919d29d0..01d038d16 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt @@ -58,7 +58,7 @@ class ComposeViewModel @Inject constructor( private val mediaUploader: MediaUploader, private val serviceClient: ServiceClient, private val draftHelper: DraftHelper, - instanceInfoRepo: InstanceInfoRepository + instanceInfoRepo: InstanceInfoRepository, ) : ViewModel() { private var replyingStatusAuthor: String? = null @@ -124,7 +124,7 @@ class ComposeViewModel @Inject constructor( mediaSize: Long, description: String? = null, focus: Attachment.Focus? = null, - replaceItem: QueuedMedia? = null + replaceItem: QueuedMedia? = null, ): QueuedMedia { var stashMediaItem: QueuedMedia? = null @@ -136,7 +136,7 @@ class ComposeViewModel @Inject constructor( mediaSize = mediaSize, description = description, focus = focus, - state = QueuedMedia.State.UPLOADING + state = QueuedMedia.State.UPLOADING, ) stashMediaItem = mediaItem @@ -164,7 +164,7 @@ class ComposeViewModel @Inject constructor( item.copy( id = event.mediaId, uploadPercent = -1, - state = if (event.processed) { QueuedMedia.State.PROCESSED } else { QueuedMedia.State.UNPROCESSED } + state = if (event.processed) { QueuedMedia.State.PROCESSED } else { QueuedMedia.State.UNPROCESSED }, ) is UploadEvent.ErrorEvent -> { media.update { mediaList -> mediaList.filter { it.localId != mediaItem.localId } } @@ -197,7 +197,7 @@ class ComposeViewModel @Inject constructor( id = id, description = description, focus = focus, - state = QueuedMedia.State.PUBLISHED + state = QueuedMedia.State.PUBLISHED, ) mediaList + mediaItem } @@ -297,7 +297,7 @@ class ComposeViewModel @Inject constructor( failedToSendAlert = false, scheduledAt = scheduledAt.value, language = postLanguage, - statusId = originalStatusId + statusId = originalStatusId, ) } @@ -308,7 +308,7 @@ class ComposeViewModel @Inject constructor( suspend fun sendStatus( content: String, spoilerText: String, - accountId: Long + accountId: Long, ) { if (!scheduledTootId.isNullOrEmpty()) { api.deleteScheduledStatus(scheduledTootId!!) @@ -321,7 +321,7 @@ class ComposeViewModel @Inject constructor( uri = item.uri.toString(), description = item.description, focus = item.focus, - processed = item.state == QueuedMedia.State.PROCESSED || item.state == QueuedMedia.State.PUBLISHED + processed = item.state == QueuedMedia.State.PROCESSED || item.state == QueuedMedia.State.PUBLISHED, ) } val tootToSend = StatusToSend( @@ -340,7 +340,7 @@ class ComposeViewModel @Inject constructor( idempotencyKey = randomAlphanumericString(16), retries = 0, language = postLanguage, - statusId = originalStatusId + statusId = originalStatusId, ) serviceClient.sendToot(tootToSend) @@ -379,7 +379,7 @@ class ComposeViewModel @Inject constructor( }, { e -> Log.e(TAG, "Autocomplete search for $token failed.", e) emptyList() - }) + },) } '#' -> { return api.searchSync(query = token, type = SearchType.Hashtag.apiParameter, limit = 10) @@ -388,7 +388,7 @@ class ComposeViewModel @Inject constructor( }, { e -> Log.e(TAG, "Autocomplete search for $token failed.", e) emptyList() - }) + },) } ':' -> { val emojiList = emoji.replayCache.firstOrNull() ?: return emptyList() @@ -420,7 +420,7 @@ class ComposeViewModel @Inject constructor( val replyVisibility = composeOptions?.replyVisibility ?: Status.Visibility.UNKNOWN startingVisibility = Status.Visibility.byNum( - preferredVisibility.num.coerceAtLeast(replyVisibility.num) + preferredVisibility.num.coerceAtLeast(replyVisibility.num), ) inReplyToId = composeOptions?.inReplyToId @@ -516,7 +516,7 @@ class ComposeViewModel @Inject constructor( SAVE_OR_DISCARD, UPDATE_OR_DISCARD, CONTINUE_EDITING_OR_DISCARD_CHANGES, // editing post - CONTINUE_EDITING_OR_DISCARD_DRAFT // edit draft + CONTINUE_EDITING_OR_DISCARD_DRAFT, // edit draft } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ImageDownsizer.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ImageDownsizer.kt index 39b444688..7290685fa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ImageDownsizer.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ImageDownsizer.kt @@ -39,7 +39,7 @@ fun downsizeImage( uri: Uri, sizeLimit: Int, contentResolver: ContentResolver, - tempFile: File + tempFile: File, ): Boolean { val decodeBoundsInputStream = try { contentResolver.openInputStream(uri) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaPreviewAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaPreviewAdapter.kt index 6cd590d7e..2437ca18f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaPreviewAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaPreviewAdapter.kt @@ -34,7 +34,7 @@ class MediaPreviewAdapter( private val onAddCaption: (ComposeActivity.QueuedMedia) -> Unit, private val onAddFocus: (ComposeActivity.QueuedMedia) -> Unit, private val onEditImage: (ComposeActivity.QueuedMedia) -> Unit, - private val onRemove: (ComposeActivity.QueuedMedia) -> Unit + private val onRemove: (ComposeActivity.QueuedMedia) -> Unit, ) : RecyclerView.Adapter() { fun submitList(list: List) { @@ -120,7 +120,7 @@ class MediaPreviewAdapter( override fun areContentsTheSame(oldItem: ComposeActivity.QueuedMedia, newItem: ComposeActivity.QueuedMedia): Boolean { return oldItem == newItem } - } + }, ) inner class PreviewViewHolder(val progressImageView: ProgressImageView) : diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaUploader.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaUploader.kt index 58c3cf2a0..021dcb1af 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaUploader.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/MediaUploader.kt @@ -71,7 +71,7 @@ sealed class UploadEvent { data class UploadData( val flow: Flow, - val scope: CoroutineScope + val scope: CoroutineScope, ) fun createNewImageFile(context: Context, suffix: String = ".jpg"): File { @@ -82,7 +82,7 @@ fun createNewImageFile(context: Context, suffix: String = ".jpg"): File { return File.createTempFile( imageFileName, /* prefix */ suffix, /* suffix */ - storageDir /* directory */ + storageDir, /* directory */ ) } @@ -96,7 +96,7 @@ class UploadServerError(val errorMessage: String) : Exception() @Singleton class MediaUploader @Inject constructor( private val context: Context, - private val mediaUploadApi: MediaUploadApi + private val mediaUploadApi: MediaUploadApi, ) { private val uploads = mutableMapOf() @@ -175,7 +175,7 @@ class MediaUploader @Inject constructor( uri = FileProvider.getUriForFile( context, BuildConfig.APPLICATION_ID + ".fileprovider", - file + file, ) mediaSize = getMediaSize(contentResolver, uri) } @@ -198,7 +198,7 @@ class MediaUploader @Inject constructor( uri = FileProvider.getUriForFile( context, BuildConfig.APPLICATION_ID + ".fileprovider", - file + file, ) mediaSize = getMediaSize(contentResolver, uri) } @@ -268,7 +268,7 @@ class MediaUploader @Inject constructor( context.getString(R.string.app_name), Date().time.toString(), randomAlphanumericString(10), - fileExtension + fileExtension, ) val stream = contentResolver.openInputStream(media.uri) @@ -279,7 +279,7 @@ class MediaUploader @Inject constructor( val fileBody = ProgressRequestBody( stream!!, media.mediaSize, - mimeType.toMediaTypeOrNull()!! + mimeType.toMediaTypeOrNull()!!, ) { percentage -> if (percentage != lastProgress) { trySend(UploadEvent.ProgressEvent(percentage)) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollDialog.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollDialog.kt index 2d76e2d03..b1b0a2dbc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollDialog.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollDialog.kt @@ -33,7 +33,7 @@ fun showAddPollDialog( maxOptionLength: Int, minDuration: Int, maxDuration: Int, - onUpdatePoll: (NewPoll) -> Unit + onUpdatePoll: (NewPoll) -> Unit, ) { val binding = DialogAddPollBinding.inflate(LayoutInflater.from(context)) @@ -54,7 +54,7 @@ fun showAddPollDialog( }, onOptionChanged = { valid -> dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = valid - } + }, ) binding.pollChoices.adapter = adapter @@ -94,8 +94,8 @@ fun showAddPollDialog( NewPoll( options = adapter.pollOptions, expiresIn = durations[selectedPollDurationId], - multiple = binding.multipleChoicesCheckBox.isChecked - ) + multiple = binding.multipleChoicesCheckBox.isChecked, + ), ) dialog.dismiss() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollOptionsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollOptionsAdapter.kt index 4d7ecdca8..b9d93a7b1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollOptionsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/AddPollOptionsAdapter.kt @@ -30,7 +30,7 @@ class AddPollOptionsAdapter( private var options: MutableList, private val maxOptionLength: Int, private val onOptionRemoved: (Boolean) -> Unit, - private val onOptionChanged: (Boolean) -> Unit + private val onOptionChanged: (Boolean) -> Unit, ) : RecyclerView.Adapter>() { val pollOptions: List diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/CaptionDialog.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/CaptionDialog.kt index c066b3d9f..9ae8ebe53 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/CaptionDialog.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/CaptionDialog.kt @@ -56,7 +56,7 @@ class CaptionDialog : DialogFragment() { input.hint = resources.getQuantityString( R.plurals.hint_describe_for_visually_impaired, MEDIA_DESCRIPTION_CHARACTER_LIMIT, - MEDIA_DESCRIPTION_CHARACTER_LIMIT + MEDIA_DESCRIPTION_CHARACTER_LIMIT, ) input.filters = arrayOf(InputFilter.LengthFilter(MEDIA_DESCRIPTION_CHARACTER_LIMIT)) input.setText(arguments?.getString(EXISTING_DESCRIPTION_ARG)) @@ -79,18 +79,20 @@ class CaptionDialog : DialogFragment() { Glide.with(this) .load(previewUri) .downsample(DownsampleStrategy.CENTER_INSIDE) - .into(object : CustomTarget(4096, 4096) { - override fun onLoadCleared(placeholder: Drawable?) { - imageView.setImageDrawable(placeholder) - } + .into( + object : CustomTarget(4096, 4096) { + override fun onLoadCleared(placeholder: Drawable?) { + imageView.setImageDrawable(placeholder) + } - override fun onResourceReady( - resource: Drawable, - transition: Transition? - ) { - imageView.setImageDrawable(resource) - } - }) + override fun onResourceReady( + resource: Drawable, + transition: Transition?, + ) { + imageView.setImageDrawable(resource) + } + }, + ) return dialog } @@ -103,7 +105,7 @@ class CaptionDialog : DialogFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { savedInstanceState?.getString(DESCRIPTION_KEY)?.let { input.setText(it) @@ -124,12 +126,12 @@ class CaptionDialog : DialogFragment() { fun newInstance( localId: Int, existingDescription: String?, - previewUri: Uri + previewUri: Uri, ) = CaptionDialog().apply { arguments = bundleOf( LOCAL_ID_ARG to localId, EXISTING_DESCRIPTION_ARG to existingDescription, - PREVIEW_URI_ARG to previewUri + PREVIEW_URI_ARG to previewUri, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/FocusDialog.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/FocusDialog.kt index 93c99ee6f..08e04b243 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/FocusDialog.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/dialog/FocusDialog.kt @@ -37,7 +37,7 @@ import kotlinx.coroutines.launch fun T.makeFocusDialog( existingFocus: Focus?, previewUri: Uri, - onUpdateFocus: suspend (Focus) -> Unit + onUpdateFocus: suspend (Focus) -> Unit, ) where T : AppCompatActivity, T : LifecycleOwner { val focus = existingFocus ?: Focus(0.0f, 0.0f) // Default to center @@ -48,31 +48,33 @@ fun T.makeFocusDialog( Glide.with(this) .load(previewUri) .downsample(DownsampleStrategy.CENTER_INSIDE) - .listener(object : RequestListener { - override fun onLoadFailed(p0: GlideException?, p1: Any?, p2: Target?, p3: Boolean): Boolean { - return false - } - - override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { - val width = resource!!.intrinsicWidth - val height = resource.intrinsicHeight - - dialogBinding.focusIndicator.setImageSize(width, height) - - // We want the dialog to be a little taller than the image, so you can slide your thumb past the image border, - // but if it's *too* much taller that looks weird. See if a threshold has been crossed: - if (width > height) { - val maxHeight = dialogBinding.focusIndicator.maxAttractiveHeight() - - if (dialogBinding.imageView.height > maxHeight) { - val verticalShrinkLayout = FrameLayout.LayoutParams(width, maxHeight) - dialogBinding.imageView.layoutParams = verticalShrinkLayout - dialogBinding.focusIndicator.layoutParams = verticalShrinkLayout - } + .listener( + object : RequestListener { + override fun onLoadFailed(p0: GlideException?, p1: Any?, p2: Target?, p3: Boolean): Boolean { + return false } - return false // Pass through - } - }) + + override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { + val width = resource!!.intrinsicWidth + val height = resource.intrinsicHeight + + dialogBinding.focusIndicator.setImageSize(width, height) + + // We want the dialog to be a little taller than the image, so you can slide your thumb past the image border, + // but if it's *too* much taller that looks weird. See if a threshold has been crossed: + if (width > height) { + val maxHeight = dialogBinding.focusIndicator.maxAttractiveHeight() + + if (dialogBinding.imageView.height > maxHeight) { + val verticalShrinkLayout = FrameLayout.LayoutParams(width, maxHeight) + dialogBinding.imageView.layoutParams = verticalShrinkLayout + dialogBinding.focusIndicator.layoutParams = verticalShrinkLayout + } + } + return false // Pass through + } + }, + ) .into(dialogBinding.imageView) val okListener = { dialog: DialogInterface, _: Int -> @@ -90,7 +92,7 @@ fun T.makeFocusDialog( val window = dialog.window window?.setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE + WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE, ) dialog.show() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.kt index c7a5b0e03..f756bde4d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.kt @@ -40,7 +40,7 @@ class ComposeScheduleView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : ConstraintLayout(context, attrs, defStyleAttr) { interface OnTimeSetListener { fun onTimeSet(time: String?) @@ -48,14 +48,14 @@ class ComposeScheduleView private var binding = ViewComposeScheduleBinding.inflate( (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater), - this + this, ) private var listener: OnTimeSetListener? = null private var dateFormat = SimpleDateFormat.getDateInstance() private var timeFormat = SimpleDateFormat.getTimeInstance() private var iso8601 = SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", - Locale.getDefault() + Locale.getDefault(), ).apply { timeZone = TimeZone.getTimeZone("UTC") } @@ -85,7 +85,7 @@ class ComposeScheduleView binding.scheduledDateTime.text = String.format( "%s %s", dateFormat.format(scheduled), - timeFormat.format(scheduled) + timeFormat.format(scheduled), ) verifyScheduledTime(scheduled) } @@ -184,7 +184,7 @@ class ComposeScheduleView val minimumScheduledTime = calendar() minimumScheduledTime.add( Calendar.SECOND, - MINIMUM_SCHEDULED_SECONDS + MINIMUM_SCHEDULED_SECONDS, ) scheduledTime.after(minimumScheduledTime.time) } else { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt index 087a70359..306a7138c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt @@ -30,7 +30,7 @@ import androidx.emoji2.viewsintegration.EmojiEditTextHelper class EditTextTyped @JvmOverloads constructor( context: Context, - attributeSet: AttributeSet? = null + attributeSet: AttributeSet? = null, ) : AppCompatMultiAutoCompleteTextView(context, attributeSet) { @@ -60,7 +60,7 @@ class EditTextTyped @JvmOverloads constructor( EditorInfoCompat.setContentMimeTypes(editorInfo, arrayOf("image/*")) return emojiEditTextHelper.onCreateInputConnection( InputConnectionCompat.createWrapper(this, connection, editorInfo), - editorInfo + editorInfo, )!! } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt index 6e0b83dc5..c4a860e88 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt @@ -19,7 +19,7 @@ class FocusIndicatorView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : View(context, attrs, defStyleAttr) { private var focus: Attachment.Focus? = null private var imageSize: Point? = null diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/PollPreviewView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/PollPreviewView.kt index c55e8fce7..f6287b625 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/PollPreviewView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/PollPreviewView.kt @@ -27,7 +27,7 @@ import com.keylesspalace.tusky.entity.NewPoll class PollPreviewView @JvmOverloads constructor( context: Context?, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : LinearLayout(context, attrs, defStyleAttr) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressImageView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressImageView.kt index 686fcc458..be8e3cff1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressImageView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressImageView.kt @@ -33,7 +33,7 @@ class ProgressImageView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : MediaPreviewImageView(context, attrs, defStyleAttr) { private var progress = -1 private val progressRect = RectF() @@ -52,7 +52,7 @@ class ProgressImageView } private val captionDrawable = AppCompatResources.getDrawable( context, - R.drawable.spellcheck + R.drawable.spellcheck, )!!.apply { setTint(Color.WHITE) } @@ -98,7 +98,7 @@ class ProgressImageView width - circleMargin - circleRadius, height - circleMargin - circleRadius, width - circleMargin, - height - circleMargin + height - circleMargin, ) captionDrawable.draw(canvas) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/TootButton.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/TootButton.kt index 43e8f6ef9..bc2d56a6e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/TootButton.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/TootButton.kt @@ -30,7 +30,7 @@ class TootButton @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : MaterialButton(context, attrs, defStyleAttr) { private val smallStyle: Boolean = context.resources.getBoolean(R.bool.show_small_toot_button) @@ -58,7 +58,8 @@ class TootButton null } Status.Visibility.PRIVATE, - Status.Visibility.DIRECT -> { + Status.Visibility.DIRECT, + -> { setText(R.string.action_send) IconicsDrawable(context, GoogleMaterial.Icon.gmd_lock).apply { sizeDp = 18; colorInt = Color.WHITE } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationAdapter.kt index a5a8ed27d..0b966afb7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationAdapter.kt @@ -26,14 +26,14 @@ import com.keylesspalace.tusky.util.StatusDisplayOptions class ConversationAdapter( private var statusDisplayOptions: StatusDisplayOptions, - private val listener: StatusActionListener + private val listener: StatusActionListener, ) : PagingDataAdapter(CONVERSATION_COMPARATOR) { var mediaPreviewEnabled: Boolean get() = statusDisplayOptions.mediaPreviewEnabled set(mediaPreviewEnabled) { statusDisplayOptions = statusDisplayOptions.copy( - mediaPreviewEnabled = mediaPreviewEnabled + mediaPreviewEnabled = mediaPreviewEnabled, ) } @@ -49,7 +49,7 @@ class ConversationAdapter( override fun onBindViewHolder( holder: ConversationViewHolder, position: Int, - payloads: List + payloads: List, ) { getItem(position)?.let { conversationViewData -> holder.setupWithConversation(conversationViewData, payloads.firstOrNull()) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt index 009dcbcc1..29aa9355f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt @@ -37,7 +37,7 @@ data class ConversationEntity( val order: Int, val accounts: List, val unread: Boolean, - @Embedded(prefix = "s_") val lastStatus: ConversationStatusEntity + @Embedded(prefix = "s_") val lastStatus: ConversationStatusEntity, ) { fun toViewData(): ConversationViewData { return ConversationViewData( @@ -45,7 +45,7 @@ data class ConversationEntity( order = order, accounts = accounts, unread = unread, - lastStatus = lastStatus.toViewData() + lastStatus = lastStatus.toViewData(), ) } } @@ -56,7 +56,7 @@ data class ConversationAccountEntity( val username: String, val displayName: String, val avatar: String, - val emojis: List + val emojis: List, ) { fun toAccount(): TimelineAccount { return TimelineAccount( @@ -67,7 +67,7 @@ data class ConversationAccountEntity( note = "", url = "", avatar = avatar, - emojis = emojis + emojis = emojis, ) } } @@ -97,7 +97,7 @@ data class ConversationStatusEntity( val collapsed: Boolean, val muted: Boolean, val poll: Poll?, - val language: String? + val language: String?, ) { fun toViewData(): StatusViewData { @@ -131,11 +131,11 @@ data class ConversationStatusEntity( poll = poll, card = null, language = language, - filtered = null + filtered = null, ), isExpanded = expanded, isShowingContent = showingHiddenContent, - isCollapsed = collapsed + isCollapsed = collapsed, ) } } @@ -147,13 +147,13 @@ fun TimelineAccount.toEntity() = username = username, displayName = name, avatar = avatar, - emojis = emojis.orEmpty() + emojis = emojis.orEmpty(), ) fun Status.toEntity( expanded: Boolean, contentShowing: Boolean, - contentCollapsed: Boolean + contentCollapsed: Boolean, ) = ConversationStatusEntity( id = id, @@ -179,7 +179,7 @@ fun Status.toEntity( collapsed = contentCollapsed, muted = muted ?: false, poll = poll, - language = language + language = language, ) fun Conversation.toEntity( @@ -187,7 +187,7 @@ fun Conversation.toEntity( order: Int, expanded: Boolean, contentShowing: Boolean, - contentCollapsed: Boolean + contentCollapsed: Boolean, ) = ConversationEntity( accountId = accountId, @@ -198,6 +198,6 @@ fun Conversation.toEntity( lastStatus = lastStatus!!.toEntity( expanded = expanded, contentShowing = contentShowing, - contentCollapsed = contentCollapsed - ) + contentCollapsed = contentCollapsed, + ), ) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationLoadStateAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationLoadStateAdapter.kt index 7ff4daa74..d073bb359 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationLoadStateAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationLoadStateAdapter.kt @@ -24,7 +24,7 @@ import com.keylesspalace.tusky.util.BindingHolder import com.keylesspalace.tusky.util.visible class ConversationLoadStateAdapter( - private val retryCallback: () -> Unit + private val retryCallback: () -> Unit, ) : LoadStateAdapter>() { override fun onBindViewHolder(holder: BindingHolder, loadState: LoadState) { @@ -45,7 +45,7 @@ class ConversationLoadStateAdapter( override fun onCreateViewHolder( parent: ViewGroup, - loadState: LoadState + loadState: LoadState, ): BindingHolder { val binding = ItemNetworkStateBinding.inflate(LayoutInflater.from(parent.context), parent, false) return BindingHolder(binding) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationViewData.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationViewData.kt index ceae7c6f7..8e1e5e5ff 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationViewData.kt @@ -23,7 +23,7 @@ data class ConversationViewData( val order: Int, val accounts: List, val unread: Boolean, - val lastStatus: StatusViewData + val lastStatus: StatusViewData, ) { fun toEntity( accountId: Long, @@ -33,7 +33,7 @@ data class ConversationViewData( poll: Poll? = lastStatus.status.poll, expanded: Boolean = lastStatus.isExpanded, collapsed: Boolean = lastStatus.isCollapsed, - showingHiddenContent: Boolean = lastStatus.isShowingContent + showingHiddenContent: Boolean = lastStatus.isShowingContent, ): ConversationEntity { return ConversationEntity( accountId = accountId, @@ -48,8 +48,8 @@ data class ConversationViewData( poll = poll, expanded = expanded, collapsed = collapsed, - showingHiddenContent = showingHiddenContent - ) + showingHiddenContent = showingHiddenContent, + ), ) } } @@ -61,7 +61,7 @@ fun StatusViewData.toConversationStatusEntity( poll: Poll? = status.poll, expanded: Boolean = isExpanded, collapsed: Boolean = isCollapsed, - showingHiddenContent: Boolean = isShowingContent + showingHiddenContent: Boolean = isShowingContent, ): ConversationStatusEntity { return ConversationStatusEntity( id = id, @@ -87,6 +87,6 @@ fun StatusViewData.toConversationStatusEntity( collapsed = collapsed, muted = muted, poll = poll, - language = status.language + language = status.language, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt index 462e3808a..997ba3a2e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt @@ -111,7 +111,7 @@ class ConversationsFragment : animateEmojis = preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), showStatsInline = preferences.getBoolean(PrefKeys.SHOW_STATS_INLINE, false), showSensitiveMedia = accountManager.activeAccount!!.alwaysShowSensitiveMedia, - openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler + openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler, ) adapter = ConversationAdapter(statusDisplayOptions, this) @@ -147,35 +147,39 @@ class ConversationsFragment : } } - adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { - override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { - if (positionStart == 0 && adapter.itemCount != itemCount) { - binding.recyclerView.post { - if (getView() != null) { - binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) + adapter.registerAdapterDataObserver( + object : RecyclerView.AdapterDataObserver() { + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + if (positionStart == 0 && adapter.itemCount != itemCount) { + binding.recyclerView.post { + if (getView() != null) { + binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) + } } } } - } - }) + }, + ) hideFab = preferences.getBoolean(PrefKeys.FAB_HIDE, false) - binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { - val composeButton = (activity as ActionButtonActivity).actionButton - if (composeButton != null) { - if (hideFab) { - if (dy > 0 && composeButton.isShown) { - composeButton.hide() // hides the button if we're scrolling down - } else if (dy < 0 && !composeButton.isShown) { - composeButton.show() // shows it if we are scrolling up + binding.recyclerView.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { + val composeButton = (activity as ActionButtonActivity).actionButton + if (composeButton != null) { + if (hideFab) { + if (dy > 0 && composeButton.isShown) { + composeButton.hide() // hides the button if we're scrolling down + } else if (dy < 0 && !composeButton.isShown) { + composeButton.show() // shows it if we are scrolling up + } + } else if (!composeButton.isShown) { + composeButton.show() } - } else if (!composeButton.isShown) { - composeButton.show() } } - } - }) + }, + ) viewLifecycleOwner.lifecycleScope.launch { viewModel.conversationFlow.collectLatest { pagingData -> @@ -190,7 +194,7 @@ class ConversationsFragment : adapter.notifyItemRangeChanged( 0, adapter.itemCount, - listOf(StatusBaseViewHolder.Key.KEY_CREATED) + listOf(StatusBaseViewHolder.Key.KEY_CREATED), ) delay(1.toDuration(DurationUnit.MINUTES)) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRemoteMediator.kt index b00c99a95..7167e19af 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRemoteMediator.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRemoteMediator.kt @@ -15,7 +15,7 @@ import retrofit2.HttpException class ConversationsRemoteMediator( private val api: MastodonApi, private val db: AppDatabase, - accountManager: AccountManager + accountManager: AccountManager, ) : RemoteMediator() { private var nextKey: String? = null @@ -26,7 +26,7 @@ class ConversationsRemoteMediator( override suspend fun load( loadType: LoadType, - state: PagingState + state: PagingState, ): MediatorResult { if (loadType == LoadType.PREPEND) { return MediatorResult.Success(endOfPaginationReached = true) @@ -68,9 +68,9 @@ class ConversationsRemoteMediator( order = order++, expanded = expanded, contentShowing = contentShowing, - contentCollapsed = contentCollapsed + contentCollapsed = contentCollapsed, ) - } + }, ) } return MediatorResult.Success(endOfPaginationReached = nextKey == null) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt index 78bb7c8e5..e12ce2213 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt @@ -37,7 +37,7 @@ class ConversationsViewModel @Inject constructor( private val timelineCases: TimelineCases, private val database: AppDatabase, private val accountManager: AccountManager, - private val api: MastodonApi + private val api: MastodonApi, ) : ViewModel() { @OptIn(ExperimentalPagingApi::class) @@ -51,7 +51,7 @@ class ConversationsViewModel @Inject constructor( } else { database.conversationDao().conversationsForAccount(activeAccount.id) } - } + }, ) .flow .map { pagingData -> @@ -64,13 +64,13 @@ class ConversationsViewModel @Inject constructor( timelineCases.favourite(conversation.lastStatus.id, favourite).fold({ val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - favourited = favourite + favourited = favourite, ) saveConversationToDb(newConversation) }, { e -> Log.w(TAG, "failed to favourite status", e) - }) + },) } } @@ -79,13 +79,13 @@ class ConversationsViewModel @Inject constructor( timelineCases.bookmark(conversation.lastStatus.id, bookmark).fold({ val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - bookmarked = bookmark + bookmarked = bookmark, ) saveConversationToDb(newConversation) }, { e -> Log.w(TAG, "failed to bookmark status", e) - }) + },) } } @@ -95,13 +95,13 @@ class ConversationsViewModel @Inject constructor( .fold({ poll -> val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - poll = poll + poll = poll, ) saveConversationToDb(newConversation) }, { e -> Log.w(TAG, "failed to vote in poll", e) - }) + },) } } @@ -109,7 +109,7 @@ class ConversationsViewModel @Inject constructor( viewModelScope.launch { val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - expanded = expanded + expanded = expanded, ) saveConversationToDb(newConversation) } @@ -119,7 +119,7 @@ class ConversationsViewModel @Inject constructor( viewModelScope.launch { val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - collapsed = collapsed + collapsed = collapsed, ) saveConversationToDb(newConversation) } @@ -129,7 +129,7 @@ class ConversationsViewModel @Inject constructor( viewModelScope.launch { val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - showingHiddenContent = showing + showingHiddenContent = showing, ) saveConversationToDb(newConversation) } @@ -142,7 +142,7 @@ class ConversationsViewModel @Inject constructor( database.conversationDao().delete( id = conversation.id, - accountId = accountManager.activeAccount!!.id + accountId = accountManager.activeAccount!!.id, ) } catch (e: Exception) { Log.w(TAG, "failed to delete conversation", e) @@ -155,12 +155,12 @@ class ConversationsViewModel @Inject constructor( try { timelineCases.muteConversation( conversation.lastStatus.id, - !(conversation.lastStatus.status.muted ?: false) + !(conversation.lastStatus.status.muted ?: false), ) val newConversation = conversation.toEntity( accountId = accountManager.activeAccount!!.id, - muted = !(conversation.lastStatus.status.muted ?: false) + muted = !(conversation.lastStatus.status.muted ?: false), ) database.conversationDao().insert(newConversation) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt index 2dc802e6a..33efa8496 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftHelper.kt @@ -45,7 +45,7 @@ import javax.inject.Inject class DraftHelper @Inject constructor( val context: Context, private val okHttpClient: OkHttpClient, - db: AppDatabase + db: AppDatabase, ) { private val draftDao = db.draftDao() @@ -66,7 +66,7 @@ class DraftHelper @Inject constructor( failedToSendAlert: Boolean, scheduledAt: String?, language: String?, - statusId: String? + statusId: String?, ) = withContext(Dispatchers.IO) { val externalFilesDir = context.getExternalFilesDir("Tusky") @@ -108,8 +108,8 @@ class DraftHelper @Inject constructor( uriString = uris[i].toString(), description = mediaDescriptions[i], focus = mediaFocus[i], - type = types[i] - ) + type = types[i], + ), ) } @@ -127,7 +127,7 @@ class DraftHelper @Inject constructor( failedToSendNew = failedToSendAlert, scheduledAt = scheduledAt, language = language, - statusId = statusId + statusId = statusId, ) draftDao.insertOrReplace(draft) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftMediaAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftMediaAdapter.kt index 2165f7e0c..4f3c0c9bb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftMediaAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftMediaAdapter.kt @@ -28,7 +28,7 @@ import com.keylesspalace.tusky.db.DraftAttachment import com.keylesspalace.tusky.view.MediaPreviewImageView class DraftMediaAdapter( - private val attachmentClick: () -> Unit + private val attachmentClick: () -> Unit, ) : ListAdapter( object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: DraftAttachment, newItem: DraftAttachment): Boolean { @@ -38,7 +38,7 @@ class DraftMediaAdapter( override fun areContentsTheSame(oldItem: DraftAttachment, newItem: DraftAttachment): Boolean { return oldItem == newItem } - } + }, ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DraftMediaViewHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt index 6d9a2aa16..216daf42f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt @@ -119,7 +119,7 @@ class DraftsActivity : BaseActivity(), DraftActionListener { scheduledAt = draft.scheduledAt, language = draft.language, statusId = draft.statusId, - kind = ComposeActivity.ComposeKind.EDIT_DRAFT + kind = ComposeActivity.ComposeKind.EDIT_DRAFT, ) bottomSheet.state = BottomSheetBehavior.STATE_HIDDEN @@ -140,7 +140,7 @@ class DraftsActivity : BaseActivity(), DraftActionListener { Snackbar.make(binding.root, getString(R.string.drafts_failed_loading_reply), Snackbar.LENGTH_SHORT) .show() } - } + }, ) } } @@ -157,7 +157,7 @@ class DraftsActivity : BaseActivity(), DraftActionListener { scheduledAt = draft.scheduledAt, language = draft.language, statusId = draft.statusId, - kind = ComposeActivity.ComposeKind.EDIT_DRAFT + kind = ComposeActivity.ComposeKind.EDIT_DRAFT, ) startActivity(ComposeActivity.startIntent(this, composeOptions)) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsAdapter.kt index 1edf354d6..0ebdefd9b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsAdapter.kt @@ -34,7 +34,7 @@ interface DraftActionListener { } class DraftsAdapter( - private val listener: DraftActionListener + private val listener: DraftActionListener, ) : PagingDataAdapter>( object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: DraftEntity, newItem: DraftEntity): Boolean { @@ -44,7 +44,7 @@ class DraftsAdapter( override fun areContentsTheSame(oldItem: DraftEntity, newItem: DraftEntity): Boolean { return oldItem == newItem } - } + }, ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt index e748aebb9..93a3894c8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt @@ -33,12 +33,12 @@ class DraftsViewModel @Inject constructor( val database: AppDatabase, val accountManager: AccountManager, val api: MastodonApi, - private val draftHelper: DraftHelper + private val draftHelper: DraftHelper, ) : ViewModel() { val drafts = Pager( config = PagingConfig(pageSize = 20), - pagingSourceFactory = { database.draftDao().draftsPagingSource(accountManager.activeAccount?.id!!) } + pagingSourceFactory = { database.draftDao().draftsPagingSource(accountManager.activeAccount?.id!!) }, ).flow .cachedIn(viewModelScope) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt index f8a291c4b..3d005c24e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt @@ -60,7 +60,7 @@ class EditFilterActivity : BaseActivity() { filterContextNotifications to Filter.Kind.NOTIFICATIONS, filterContextPublic to Filter.Kind.PUBLIC, filterContextThread to Filter.Kind.THREAD, - filterContextAccount to Filter.Kind.ACCOUNT + filterContextAccount to Filter.Kind.ACCOUNT, ) } @@ -77,7 +77,7 @@ class EditFilterActivity : BaseActivity() { R.string.filter_addition_title } else { R.string.filter_edit_title - } + }, ) binding.actionChip.setOnClickListener { showAddKeywordDialog() } @@ -110,7 +110,7 @@ class EditFilterActivity : BaseActivity() { Filter.Action.WARN } else { Filter.Action.HIDE - } + }, ) } binding.filterDurationSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { @@ -120,7 +120,7 @@ class EditFilterActivity : BaseActivity() { position } else { position - 1 - } + }, ) } @@ -192,7 +192,7 @@ class EditFilterActivity : BaseActivity() { chip.text = if (filterKeyword.wholeWord) { binding.root.context.getString( R.string.filter_keyword_display_format, - filterKeyword.keyword + filterKeyword.keyword, ) } else { filterKeyword.keyword @@ -225,8 +225,8 @@ class EditFilterActivity : BaseActivity() { FilterKeyword( "", binding.phraseEditText.text.toString(), - binding.phraseWholeWord.isChecked - ) + binding.phraseWholeWord.isChecked, + ), ) } .setNegativeButton(android.R.string.cancel, null) @@ -246,8 +246,8 @@ class EditFilterActivity : BaseActivity() { keyword, keyword.copy( keyword = binding.phraseEditText.text.toString(), - wholeWord = binding.phraseWholeWord.isChecked - ) + wholeWord = binding.phraseWholeWord.isChecked, + ), ) } .setNegativeButton(android.R.string.cancel, null) @@ -285,12 +285,12 @@ class EditFilterActivity : BaseActivity() { }, { Snackbar.make(binding.root, "Error deleting filter '${filter.title}'", Snackbar.LENGTH_SHORT).show() - } + }, ) } else { Snackbar.make(binding.root, "Error deleting filter '${filter.title}'", Snackbar.LENGTH_SHORT).show() } - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt index d33031d65..abe0eb8fd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt @@ -98,7 +98,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub title = title, context = contexts, filterAction = action, - expiresInSeconds = expiresInSeconds + expiresInSeconds = expiresInSeconds, ).fold( { newFilter -> // This is _terrible_, but the all-in-one update filter api Just Doesn't Work @@ -112,7 +112,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub // Endpoint not found, fall back to v1 api createFilterV1(contexts, expiresInSeconds) ) - } + }, ) } @@ -123,7 +123,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub title = title, context = contexts, filterAction = action, - expiresInSeconds = expiresInSeconds + expiresInSeconds = expiresInSeconds, ).fold( { // This is _terrible_, but the all-in-one update filter api Just Doesn't Work @@ -148,7 +148,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub } } return false - } + }, ) } @@ -166,7 +166,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub context = context, irreversible = false, wholeWord = keyword.wholeWord, - expiresInSeconds = expiresInSeconds + expiresInSeconds = expiresInSeconds, ) } else { api.updateFilterV1( @@ -175,7 +175,7 @@ class EditFilterViewModel @Inject constructor(val api: MastodonApi, val eventHub context = context, irreversible = false, wholeWord = keyword.wholeWord, - expiresInSeconds = expiresInSeconds + expiresInSeconds = expiresInSeconds, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersActivity.kt index d66fb7ad2..3395033e6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersActivity.kt @@ -78,7 +78,7 @@ class FiltersActivity : BaseActivity(), FiltersListener { binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) binding.messageView.show() } else { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersAdapter.kt index f6e6791a7..4ba31c163 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersAdapter.kt @@ -32,13 +32,13 @@ class FiltersAdapter(val listener: FiltersListener, val filters: List) : context.getString( R.string.filter_expiration_format, filter.title, - getRelativeTimeSpanString(binding.root.context, filter.expiresAt.time, System.currentTimeMillis()) + getRelativeTimeSpanString(binding.root.context, filter.expiresAt.time, System.currentTimeMillis()), ) } binding.textSecondary.text = context.getString( R.string.filter_description_format, actions.getOrNull(filter.action.ordinal - 1), - filter.context.map { contexts.getOrNull(Filter.Kind.from(it).ordinal) }.joinToString("/") + filter.context.map { contexts.getOrNull(Filter.Kind.from(it).ordinal) }.joinToString("/"), ) binding.delete.setOnClickListener { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt index ed53840c3..03c9313bc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt @@ -18,7 +18,7 @@ import javax.inject.Inject class FiltersViewModel @Inject constructor( private val api: MastodonApi, - private val eventHub: EventHub + private val eventHub: EventHub, ) : ViewModel() { enum class LoadingState { @@ -49,13 +49,13 @@ class FiltersViewModel @Inject constructor( // TODO log errors (also below) this@FiltersViewModel._state.value = _state.value.copy(loadingState = LoadingState.ERROR_OTHER) - } + }, ) this@FiltersViewModel._state.value = _state.value.copy(loadingState = LoadingState.ERROR_OTHER) } else { this@FiltersViewModel._state.value = _state.value.copy(loadingState = LoadingState.ERROR_NETWORK) } - } + }, ) } } @@ -77,12 +77,12 @@ class FiltersViewModel @Inject constructor( }, { Snackbar.make(parent, "Error deleting filter '${filter.title}'", Snackbar.LENGTH_SHORT).show() - } + }, ) } else { Snackbar.make(parent, "Error deleting filter '${filter.title}'", Snackbar.LENGTH_SHORT).show() } - } + }, ) } } @@ -94,7 +94,7 @@ class FiltersViewModel @Inject constructor( FilterV1.NOTIFICATIONS, FilterV1.THREAD, FilterV1.PUBLIC, - FilterV1.ACCOUNT + FilterV1.ACCOUNT, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt index b6b56d4a3..5a34baf6d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt @@ -86,15 +86,17 @@ class FollowedTagsActivity : val hideFab = sharedPreferences.getBoolean(PrefKeys.FAB_HIDE, false) if (hideFab) { - binding.followedTagsView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { - if (dy > 0 && binding.fab.isShown) { - binding.fab.hide() - } else if (dy < 0 && !binding.fab.isShown) { - binding.fab.show() + binding.followedTagsView.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { + if (dy > 0 && binding.fab.isShown) { + binding.fab.hide() + } else if (dy < 0 && !binding.fab.isShown) { + binding.fab.show() + } } - } - }) + }, + ) } } @@ -133,10 +135,10 @@ class FollowedTagsActivity : this@FollowedTagsActivity, binding.followedTagsView, getString(R.string.error_following_hashtag_format, tagName), - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ) .show() - } + }, ) } } @@ -150,7 +152,7 @@ class FollowedTagsActivity : this@FollowedTagsActivity, binding.followedTagsView, getString(R.string.confirmation_hashtag_unfollowed, tagName), - Snackbar.LENGTH_LONG + Snackbar.LENGTH_LONG, ) .setAction(R.string.action_undo) { follow(tagName, position) @@ -164,12 +166,12 @@ class FollowedTagsActivity : binding.followedTagsView, getString( R.string.error_unfollowing_hashtag_format, - tagName + tagName, ), - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ) .show() - } + }, ) } } @@ -191,8 +193,8 @@ class FollowedTagsActivity : requireActivity() as FollowedTagsActivity, animateAvatar = false, animateEmojis = false, - showBotBadge = false - ) + showBotBadge = false, + ), ) return AlertDialog.Builder(requireActivity()) @@ -200,7 +202,7 @@ class FollowedTagsActivity : .setView(layout) .setPositiveButton(android.R.string.ok) { _, _ -> (requireActivity() as FollowedTagsActivity).follow( - autoCompleteTextView.text.toString().removePrefix("#") + autoCompleteTextView.text.toString().removePrefix("#"), ) } .setNegativeButton(android.R.string.cancel) { _: DialogInterface, _: Int -> } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsAdapter.kt index 4cdc9f97a..682d39a8a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsAdapter.kt @@ -13,7 +13,7 @@ import com.keylesspalace.tusky.util.BindingHolder class FollowedTagsAdapter( private val actionListener: HashtagActionListener, - private val viewModel: FollowedTagsViewModel + private val viewModel: FollowedTagsViewModel, ) : PagingDataAdapter>(STRING_COMPARATOR) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder = BindingHolder(ItemFollowedHashtagBinding.inflate(LayoutInflater.from(parent.context), parent, false)) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsRemoteMediator.kt index 00239a75f..50a9ab928 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsRemoteMediator.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsRemoteMediator.kt @@ -13,11 +13,11 @@ import retrofit2.Response @OptIn(ExperimentalPagingApi::class) class FollowedTagsRemoteMediator( private val api: MastodonApi, - private val viewModel: FollowedTagsViewModel + private val viewModel: FollowedTagsViewModel, ) : RemoteMediator() { override suspend fun load( loadType: LoadType, - state: PagingState + state: PagingState, ): MediatorResult { return try { val response = request(loadType) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt index 1a1b794bb..51e47eef7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt @@ -16,7 +16,7 @@ import com.keylesspalace.tusky.network.MastodonApi import javax.inject.Inject class FollowedTagsViewModel @Inject constructor( - private val api: MastodonApi + private val api: MastodonApi, ) : ViewModel(), Injectable { val tags: MutableList = mutableListOf() var nextKey: String? = null @@ -28,11 +28,11 @@ class FollowedTagsViewModel @Inject constructor( remoteMediator = FollowedTagsRemoteMediator(api, this), pagingSourceFactory = { FollowedTagsPagingSource( - viewModel = this + viewModel = this, ).also { source -> currentSource = source } - } + }, ).flow.cachedIn(viewModelScope) fun searchAutocompleteSuggestions(token: String): List { @@ -42,7 +42,7 @@ class FollowedTagsViewModel @Inject constructor( }, { e -> Log.e(TAG, "Autocomplete search for $token failed.", e) emptyList() - }) + },) } companion object { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfo.kt b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfo.kt index 582df02e8..fb21caaef 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfo.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfo.kt @@ -29,5 +29,5 @@ data class InstanceInfo( val maxFields: Int, val maxFieldNameLength: Int?, val maxFieldValueLength: Int?, - val version: String? + val version: String?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt index 1045fe480..c5d56d1bb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt @@ -32,7 +32,7 @@ import javax.inject.Inject class InstanceInfoRepository @Inject constructor( private val api: MastodonApi, db: AppDatabase, - accountManager: AccountManager + accountManager: AccountManager, ) { private val dao = db.instanceDao() @@ -76,7 +76,7 @@ class InstanceInfoRepository @Inject constructor( maxMediaAttachments = instance.configuration?.statuses?.maxMediaAttachments ?: instance.maxMediaAttachments, maxFields = instance.pleroma?.metadata?.fieldLimits?.maxFields, maxFieldNameLength = instance.pleroma?.metadata?.fieldLimits?.nameLength, - maxFieldValueLength = instance.pleroma?.metadata?.fieldLimits?.valueLength + maxFieldValueLength = instance.pleroma?.metadata?.fieldLimits?.valueLength, ) dao.upsert(instanceEntity) instanceEntity @@ -84,7 +84,7 @@ class InstanceInfoRepository @Inject constructor( { throwable -> Log.w(TAG, "failed to instance, falling back to cache and default values", throwable) dao.getInstanceInfo(instanceName) - } + }, ).let { instanceInfo: InstanceInfoEntity? -> InstanceInfo( maxChars = instanceInfo?.maximumTootCharacters ?: DEFAULT_CHARACTER_LIMIT, @@ -100,7 +100,7 @@ class InstanceInfoRepository @Inject constructor( maxFields = instanceInfo?.maxFields ?: DEFAULT_MAX_ACCOUNT_FIELDS, maxFieldNameLength = instanceInfo?.maxFieldNameLength, maxFieldValueLength = instanceInfo?.maxFieldValueLength, - version = instanceInfo?.version + version = instanceInfo?.version, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/instancemute/adapter/DomainMutesAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/instancemute/adapter/DomainMutesAdapter.kt index 13d8f2d83..8d20da495 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/instancemute/adapter/DomainMutesAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/instancemute/adapter/DomainMutesAdapter.kt @@ -8,7 +8,7 @@ import com.keylesspalace.tusky.databinding.ItemMutedDomainBinding import com.keylesspalace.tusky.util.BindingHolder class DomainMutesAdapter( - private val actionListener: InstanceActionListener + private val actionListener: InstanceActionListener, ) : RecyclerView.Adapter>() { var instances: MutableList = mutableListOf() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/instancemute/fragment/InstanceListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/instancemute/fragment/InstanceListFragment.kt index 1da0a2b7d..47e85d3c3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/instancemute/fragment/InstanceListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/instancemute/fragment/InstanceListFragment.kt @@ -69,7 +69,7 @@ class InstanceListFragment : Fragment(R.layout.fragment_instance_list), Injectab adapter.addItem(instance) }, { e -> Log.e(TAG, "Error muting domain $instance", e) - }) + },) } else { api.unblockDomain(instance).fold({ adapter.removeItem(position) @@ -80,7 +80,7 @@ class InstanceListFragment : Fragment(R.layout.fragment_instance_list), Injectab .show() }, { e -> Log.e(TAG, "Error unmuting domain $instance", e) - }) + },) } } } @@ -111,7 +111,7 @@ class InstanceListFragment : Fragment(R.layout.fragment_instance_list), Injectab }, { throwable -> onFetchInstancesFailure(throwable) - } + }, ) } @@ -131,7 +131,7 @@ class InstanceListFragment : Fragment(R.layout.fragment_instance_list), Injectab binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) } else { binding.messageView.hide() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt index 7e0476896..9ede2c4c0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt @@ -100,7 +100,7 @@ class LoginActivity : BaseActivity(), Injectable { preferences = getSharedPreferences( getString(R.string.preferences_file_key), - Context.MODE_PRIVATE + Context.MODE_PRIVATE, ) binding.loginButton.setOnClickListener { onLoginClick(true) } @@ -173,7 +173,7 @@ class LoginActivity : BaseActivity(), Injectable { getString(R.string.app_name), oauthRedirectUri, OAUTH_SCOPES, - getString(R.string.tusky_website) + getString(R.string.tusky_website), ).fold( { credentials -> // Before we open browser page we save the data. @@ -196,7 +196,7 @@ class LoginActivity : BaseActivity(), Injectable { setLoading(false) Log.e(TAG, Log.getStackTraceString(e)) return@launch - } + }, ) } } @@ -282,7 +282,7 @@ class LoginActivity : BaseActivity(), Injectable { clientSecret, oauthRedirectUri, code, - "authorization_code" + "authorization_code", ).fold( { accessToken -> fetchAccountDetails(accessToken, domain, clientId, clientSecret) @@ -292,7 +292,7 @@ class LoginActivity : BaseActivity(), Injectable { binding.domainTextInputLayout.error = getString(R.string.error_retrieving_oauth_token) Log.e(TAG, getString(R.string.error_retrieving_oauth_token), e) - } + }, ) } @@ -300,11 +300,11 @@ class LoginActivity : BaseActivity(), Injectable { accessToken: AccessToken, domain: String, clientId: String, - clientSecret: String + clientSecret: String, ) { mastodonApi.accountVerifyCredentials( domain = domain, - auth = "Bearer ${accessToken.accessToken}" + auth = "Bearer ${accessToken.accessToken}", ).fold({ newAccount -> accountManager.addAccount( accessToken = accessToken.accessToken, @@ -312,7 +312,7 @@ class LoginActivity : BaseActivity(), Injectable { clientId = clientId, clientSecret = clientSecret, oauthScopes = OAUTH_SCOPES, - newAccount = newAccount + newAccount = newAccount, ) val intent = Intent(this, MainActivity::class.java) @@ -325,7 +325,7 @@ class LoginActivity : BaseActivity(), Injectable { binding.domainTextInputLayout.error = getString(R.string.error_loading_account_details) Log.e(TAG, getString(R.string.error_loading_account_details), e) - }) + },) } private fun setLoading(loadingState: Boolean) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt index ed5744165..29c518f59 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewActivity.kt @@ -88,7 +88,7 @@ class OauthLogin : ActivityResultContract() { data class LoginData( val domain: String, val url: Uri, - val oauthRedirectUrl: Uri + val oauthRedirectUrl: Uri, ) : Parcelable sealed class LoginResult : Parcelable { @@ -149,7 +149,7 @@ class LoginWebViewActivity : BaseActivity(), Injectable { override fun onReceivedError( view: WebView, request: WebResourceRequest, - error: WebResourceError + error: WebResourceError, ) { Log.d("LoginWeb", "Failed to load ${data.url}: $error") sendResult(LoginResult.Err(getString(R.string.error_could_not_load_login_page))) @@ -157,7 +157,7 @@ class LoginWebViewActivity : BaseActivity(), Injectable { override fun shouldOverrideUrlLoading( view: WebView, - request: WebResourceRequest + request: WebResourceRequest, ): Boolean { return shouldOverrideUrlLoading(request.url) } @@ -204,7 +204,7 @@ class LoginWebViewActivity : BaseActivity(), Injectable { AlertDialog.Builder(this@LoginWebViewActivity) .setTitle(getString(R.string.instance_rule_title, data.domain)) .setMessage( - instanceRules.joinToString(separator = "\n\n") { "• $it" } + instanceRules.joinToString(separator = "\n\n") { "• $it" }, ) .setPositiveButton(android.R.string.ok, null) .show() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt index 39dd311aa..6cac6bd61 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt @@ -25,7 +25,7 @@ import kotlinx.coroutines.launch import javax.inject.Inject class LoginWebViewViewModel @Inject constructor( - private val api: MastodonApi + private val api: MastodonApi, ) : ViewModel() { val instanceRules: MutableStateFlow> = MutableStateFlow(emptyList()) @@ -40,7 +40,7 @@ class LoginWebViewViewModel @Inject constructor( instanceRules.value = instance.rules?.map { rule -> rule.text }.orEmpty() }, { throwable -> Log.w("LoginWebViewViewModel", "failed to load instance info", throwable) - }) + },) } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/FollowViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/FollowViewHolder.kt index b433a73ee..880aa79c8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/FollowViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/FollowViewHolder.kt @@ -34,16 +34,16 @@ import com.keylesspalace.tusky.viewdata.NotificationViewData class FollowViewHolder( private val binding: ItemFollowBinding, private val notificationActionListener: NotificationActionListener, - private val linkListener: LinkListener + private val linkListener: LinkListener, ) : NotificationsPagingAdapter.ViewHolder, RecyclerView.ViewHolder(binding.root) { private val avatarRadius42dp = itemView.context.resources.getDimensionPixelSize( - R.dimen.avatar_radius_42dp + R.dimen.avatar_radius_42dp, ) override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { // Skip updates with payloads. That indicates a timestamp update, and // this view does not have timestamps. @@ -53,7 +53,7 @@ class FollowViewHolder( viewData.account, viewData.type === Notification.Type.SIGN_UP, statusDisplayOptions.animateAvatars, - statusDisplayOptions.animateEmojis + statusDisplayOptions.animateEmojis, ) setupButtons(notificationActionListener, viewData.account.id) } @@ -62,7 +62,7 @@ class FollowViewHolder( account: TimelineAccount, isSignUp: Boolean, animateAvatars: Boolean, - animateEmojis: Boolean + animateEmojis: Boolean, ) { val context = binding.notificationText.context val format = @@ -71,7 +71,7 @@ class FollowViewHolder( R.string.notification_sign_up_format } else { R.string.notification_follow_format - } + }, ) val wrappedDisplayName = account.name.unicodeWrap() val wholeMessage = String.format(format, wrappedDisplayName) @@ -79,7 +79,7 @@ class FollowViewHolder( wholeMessage.emojify( account.emojis, binding.notificationText, - animateEmojis + animateEmojis, ) binding.notificationText.text = emojifiedMessage val username = context.getString(R.string.post_username_format, account.username) @@ -87,20 +87,20 @@ class FollowViewHolder( val emojifiedDisplayName = wrappedDisplayName.emojify( account.emojis, binding.notificationUsername, - animateEmojis + animateEmojis, ) binding.notificationDisplayName.text = emojifiedDisplayName loadAvatar( account.avatar, binding.notificationAvatar, avatarRadius42dp, - animateAvatars + animateAvatars, ) val emojifiedNote = account.note.parseAsMastodonHtml().emojify( account.emojis, binding.notificationAccountNote, - animateEmojis + animateEmojis, ) setClickableText(binding.notificationAccountNote, emojifiedNote, emptyList(), null, linkListener) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationFetcher.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationFetcher.kt index efb322263..109b605f0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationFetcher.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationFetcher.kt @@ -46,7 +46,7 @@ import kotlin.time.Duration.Companion.milliseconds class NotificationFetcher @Inject constructor( private val mastodonApi: MastodonApi, private val accountManager: AccountManager, - private val context: Context + private val context: Context, ) { suspend fun fetchAndShow() { for (account in accountManager.getAllAccountsOrderedByActive()) { @@ -93,7 +93,7 @@ class NotificationFetcher @Inject constructor( notificationManager, notification, account, - index == 0 + index == 0, ) notificationManager.notify(notification.id, account.id.toInt(), androidNotification) // Android will rate limit / drop notifications if they're posted too @@ -105,7 +105,7 @@ class NotificationFetcher @Inject constructor( NotificationHelper.updateSummaryNotifications( context, notificationManager, - account + account, ) accountManager.saveAccount(account) @@ -161,7 +161,7 @@ class NotificationFetcher @Inject constructor( val response = mastodonApi.notificationsWithAuth( authHeader, account.domain, - minId = minId + minId = minId, ) if (!response.isSuccessful) break @@ -185,7 +185,7 @@ class NotificationFetcher @Inject constructor( mastodonApi.updateMarkersWithAuth( auth = authHeader, domain = account.domain, - notificationsLastReadId = newMarkerId + notificationsLastReadId = newMarkerId, ) account.notificationMarkerId = newMarkerId accountManager.saveAccount(account) @@ -199,7 +199,7 @@ class NotificationFetcher @Inject constructor( val allMarkers = mastodonApi.markersWithAuth( authHeader, account.domain, - listOf("notifications") + listOf("notifications"), ) val notificationMarker = allMarkers["notifications"] Log.d(TAG, "Fetched marker for ${account.fullName}: $notificationMarker") diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt index 26104499f..cfdaeaeb9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt @@ -114,14 +114,14 @@ class NotificationsFragment : statusActionListener = this, notificationActionListener = this, accountActionListener = this, - statusDisplayOptions = viewModel.statusDisplayOptions.value + statusDisplayOptions = viewModel.statusDisplayOptions.value, ) } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { return inflater.inflate(R.layout.fragment_timeline_notifications, container, false) } @@ -149,7 +149,7 @@ class NotificationsFragment : binding.recyclerView.setAccessibilityDelegateCompat( ListStatusAccessibilityDelegate( binding.recyclerView, - this + this, ) { pos: Int -> val notification = adapter.snapshot().getOrNull(pos) // We support replies only for now @@ -158,49 +158,51 @@ class NotificationsFragment : } else { null } - } + }, ) binding.recyclerView.addItemDecoration( DividerItemDecoration( context, - DividerItemDecoration.VERTICAL - ) + DividerItemDecoration.VERTICAL, + ), ) - binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - val actionButton = (activity as ActionButtonActivity).actionButton + binding.recyclerView.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + val actionButton = (activity as ActionButtonActivity).actionButton - override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { - actionButton?.let { fab -> - if (!viewModel.uiState.value.showFabWhileScrolling) { - if (dy > 0 && fab.isShown) { - fab.hide() // Hide when scrolling down - } else if (dy < 0 && !fab.isShown) { - fab.show() // Show when scrolling up + override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { + actionButton?.let { fab -> + if (!viewModel.uiState.value.showFabWhileScrolling) { + if (dy > 0 && fab.isShown) { + fab.hide() // Hide when scrolling down + } else if (dy < 0 && !fab.isShown) { + fab.show() // Show when scrolling up + } + } else if (!fab.isShown) { + fab.show() } - } else if (!fab.isShown) { - fab.show() } } - } - @Suppress("SyntheticAccessor") - override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { - newState != SCROLL_STATE_IDLE && return + @Suppress("SyntheticAccessor") + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + newState != SCROLL_STATE_IDLE && return - // Save the ID of the first notification visible in the list, so the user's - // reading position is always restorable. - layoutManager.findFirstVisibleItemPosition().takeIf { it != NO_POSITION }?.let { position -> - adapter.snapshot().getOrNull(position)?.id?.let { id -> - viewModel.accept(InfallibleUiAction.SaveVisibleId(visibleId = id)) + // Save the ID of the first notification visible in the list, so the user's + // reading position is always restorable. + layoutManager.findFirstVisibleItemPosition().takeIf { it != NO_POSITION }?.let { position -> + adapter.snapshot().getOrNull(position)?.id?.let { id -> + viewModel.accept(InfallibleUiAction.SaveVisibleId(visibleId = id)) + } } } - } - }) + }, + ) binding.recyclerView.adapter = adapter.withLoadStateHeaderAndFooter( header = TimelineLoadStateAdapter { adapter.retry() }, - footer = TimelineLoadStateAdapter { adapter.retry() } + footer = TimelineLoadStateAdapter { adapter.retry() }, ) (binding.recyclerView.itemAnimator as SimpleItemAnimator?)!!.supportsChangeAnimations = @@ -241,13 +243,13 @@ class NotificationsFragment : val message = getString( error.message, error.throwable.localizedMessage - ?: getString(R.string.ui_error_unknown) + ?: getString(R.string.ui_error_unknown), ) val snackbar = Snackbar.make( // Without this the FAB will not move out of the way (activity as ActionButtonActivity).actionButton ?: binding.root, message, - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ).setTextMaxLines(5) error.action?.let { action -> snackbar.setAction(R.string.action_retry) { @@ -281,14 +283,15 @@ class NotificationsFragment : Snackbar.make( (activity as ActionButtonActivity).actionButton ?: binding.root, getString(it.msg), - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ).show() when (it) { // The follow request is no longer valid, refresh the adapter to // remove it. is NotificationActionSuccess.AcceptFollowRequest, - is NotificationActionSuccess.RejectFollowRequest -> adapter.refresh() + is NotificationActionSuccess.RejectFollowRequest, + -> adapter.refresh() } } } @@ -318,11 +321,11 @@ class NotificationsFragment : statusViewData.status.copy(reblogged = it.action.state) is StatusActionSuccess.VoteInPoll -> statusViewData.status.copy( - poll = it.action.poll.votedCopy(it.action.choices) + poll = it.action.poll.votedCopy(it.action.choices), ) } indexedViewData.value?.statusViewData = statusViewData.copy( - status = status + status = status, ) adapter.notifyItemChanged(indexedViewData.index) @@ -402,7 +405,7 @@ class NotificationsFragment : getView() ?: return@post binding.recyclerView.smoothScrollBy( 0, - Utils.dpToPx(requireContext(), -30) + Utils.dpToPx(requireContext(), -30), ) } peeked = true @@ -441,7 +444,7 @@ class NotificationsFragment : if (adapter.itemCount == 0) { binding.statusView.setup( R.drawable.elephant_friend_empty, - R.string.message_empty + R.string.message_empty, ) binding.recyclerView.hide() binding.statusView.show() @@ -559,7 +562,7 @@ class NotificationsFragment : super.viewMedia( attachmentIndex, list(status, viewModel.statusDisplayOptions.value.showSensitiveMedia), - view + view, ) } @@ -576,7 +579,7 @@ class NotificationsFragment : override fun onExpandedChange(expanded: Boolean, position: Int) { val notificationViewData = adapter.snapshot()[position] ?: return notificationViewData.statusViewData = notificationViewData.statusViewData?.copy( - isExpanded = expanded + isExpanded = expanded, ) adapter.notifyItemChanged(position) } @@ -584,7 +587,7 @@ class NotificationsFragment : override fun onContentHiddenChange(isShowing: Boolean, position: Int) { val notificationViewData = adapter.snapshot()[position] ?: return notificationViewData.statusViewData = notificationViewData.statusViewData?.copy( - isShowingContent = isShowing + isShowingContent = isShowing, ) adapter.notifyItemChanged(position) } @@ -592,7 +595,7 @@ class NotificationsFragment : override fun onContentCollapsedChange(isCollapsed: Boolean, position: Int) { val notificationViewData = adapter.snapshot()[position] ?: return notificationViewData.statusViewData = notificationViewData.statusViewData?.copy( - isCollapsed = isCollapsed + isCollapsed = isCollapsed, ) adapter.notifyItemChanged(position) } @@ -604,7 +607,7 @@ class NotificationsFragment : override fun clearWarningAction(position: Int) { val notificationViewData = adapter.snapshot()[position] ?: return notificationViewData.statusViewData = notificationViewData.statusViewData?.copy( - filterAction = Filter.Action.NONE + filterAction = Filter.Action.NONE, ) adapter.notifyItemChanged(position) } @@ -654,7 +657,7 @@ class NotificationsFragment : override fun onViewReport(reportId: String) { requireContext().openLink( - "https://${viewModel.account.domain}/admin/reports/$reportId" + "https://${viewModel.account.domain}/admin/reports/$reportId", ) } @@ -676,21 +679,21 @@ class NotificationsFragment : object : DiffUtil.ItemCallback() { override fun areItemsTheSame( oldItem: NotificationViewData, - newItem: NotificationViewData + newItem: NotificationViewData, ): Boolean { return oldItem.id == newItem.id } override fun areContentsTheSame( oldItem: NotificationViewData, - newItem: NotificationViewData + newItem: NotificationViewData, ): Boolean { return false } override fun getChangePayload( oldItem: NotificationViewData, - newItem: NotificationViewData + newItem: NotificationViewData, ): Any? { return if (oldItem == newItem) { // If items are equal - update timestamp only @@ -706,7 +709,7 @@ class NotificationsFragment : class FilterDialogFragment( private val activeFilter: Set, - private val listener: ((filter: Set) -> Unit) + private val listener: ((filter: Set) -> Unit), ) : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val context = requireContext() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingAdapter.kt index f7476e318..289efb7ec 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingAdapter.kt @@ -52,20 +52,24 @@ enum class NotificationViewKind { FOLLOW, FOLLOW_REQUEST, REPORT, - UNKNOWN; + UNKNOWN, + ; companion object { fun from(kind: Notification.Type?): NotificationViewKind { return when (kind) { Notification.Type.MENTION, Notification.Type.POLL, - Notification.Type.UNKNOWN -> STATUS + Notification.Type.UNKNOWN, + -> STATUS Notification.Type.FAVOURITE, Notification.Type.REBLOG, Notification.Type.STATUS, - Notification.Type.UPDATE -> NOTIFICATION + Notification.Type.UPDATE, + -> NOTIFICATION Notification.Type.FOLLOW, - Notification.Type.SIGN_UP -> FOLLOW + Notification.Type.SIGN_UP, + -> FOLLOW Notification.Type.FOLLOW_REQUEST -> FOLLOW_REQUEST Notification.Type.REPORT -> REPORT null -> UNKNOWN @@ -106,7 +110,7 @@ class NotificationsPagingAdapter( private val statusActionListener: StatusActionListener, private val notificationActionListener: NotificationActionListener, private val accountActionListener: AccountActionListener, - var statusDisplayOptions: StatusDisplayOptions + var statusDisplayOptions: StatusDisplayOptions, ) : PagingDataAdapter(diffCallback) { private val absoluteTimeFormatter = AbsoluteTimeFormatter() @@ -117,7 +121,7 @@ class NotificationsPagingAdapter( fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) } @@ -138,14 +142,14 @@ class NotificationsPagingAdapter( StatusViewHolder( ItemStatusBinding.inflate(inflater, parent, false), statusActionListener, - accountId + accountId, ) } NotificationViewKind.STATUS_FILTERED -> { StatusViewHolder( ItemStatusWrapperBinding.inflate(inflater, parent, false), statusActionListener, - accountId + accountId, ) } NotificationViewKind.NOTIFICATION -> { @@ -153,14 +157,14 @@ class NotificationsPagingAdapter( ItemStatusNotificationBinding.inflate(inflater, parent, false), statusActionListener, notificationActionListener, - absoluteTimeFormatter + absoluteTimeFormatter, ) } NotificationViewKind.FOLLOW -> { FollowViewHolder( ItemFollowBinding.inflate(inflater, parent, false), notificationActionListener, - statusActionListener + statusActionListener, ) } NotificationViewKind.FOLLOW_REQUEST -> { @@ -168,18 +172,18 @@ class NotificationsPagingAdapter( ItemFollowRequestBinding.inflate(inflater, parent, false), accountActionListener, statusActionListener, - showHeader = true + showHeader = true, ) } NotificationViewKind.REPORT -> { ReportNotificationViewHolder( ItemReportNotificationBinding.inflate(inflater, parent, false), - notificationActionListener + notificationActionListener, ) } else -> { FallbackNotificationViewHolder( - SimpleListItem1Binding.inflate(inflater, parent, false) + SimpleListItem1Binding.inflate(inflater, parent, false), ) } } @@ -192,7 +196,7 @@ class NotificationsPagingAdapter( override fun onBindViewHolder( holder: RecyclerView.ViewHolder, position: Int, - payloads: MutableList + payloads: MutableList, ) { bindViewHolder(holder, position, payloads) } @@ -200,7 +204,7 @@ class NotificationsPagingAdapter( private fun bindViewHolder( holder: RecyclerView.ViewHolder, position: Int, - payloads: List<*>? + payloads: List<*>?, ) { getItem(position)?.let { (holder as ViewHolder).bind(it, payloads, statusDisplayOptions) } } @@ -210,12 +214,12 @@ class NotificationsPagingAdapter( * be used, but is useful when migrating code. */ private class FallbackNotificationViewHolder( - val binding: SimpleListItem1Binding + val binding: SimpleListItem1Binding, ) : ViewHolder, RecyclerView.ViewHolder(binding.root) { override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { binding.text1.text = viewData.statusViewData?.content } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt index 37c72f0ec..20bcb7f01 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSource.kt @@ -37,7 +37,7 @@ private val INVALID = LoadResult.Invalid() class NotificationsPagingSource @Inject constructor( private val mastodonApi: MastodonApi, private val gson: Gson, - private val notificationFilter: Set + private val notificationFilter: Set, ) : PagingSource() { override suspend fun load(params: LoadParams): LoadResult { Log.d(TAG, "load() with ${params.javaClass.simpleName} for key: ${params.key}") @@ -50,12 +50,12 @@ class NotificationsPagingSource @Inject constructor( is LoadParams.Append -> mastodonApi.notifications( maxId = params.key, limit = params.loadSize, - excludes = notificationFilter + excludes = notificationFilter, ) is LoadParams.Prepend -> mastodonApi.notifications( minId = params.key, limit = params.loadSize, - excludes = notificationFilter + excludes = notificationFilter, ) } @@ -92,7 +92,7 @@ class NotificationsPagingSource @Inject constructor( return LoadResult.Page( data = response.body()!!, nextKey = links.next, - prevKey = links.prev + prevKey = links.prev, ) } catch (e: Exception) { return LoadResult.Error(e) @@ -116,7 +116,7 @@ class NotificationsPagingSource @Inject constructor( val key = params.key ?: return@coroutineScope mastodonApi.notifications( limit = params.loadSize, - excludes = notificationFilter + excludes = notificationFilter, ) // It's important to return *something* from this state. If an empty page is returned @@ -193,7 +193,7 @@ class NotificationsPagingSource @Inject constructor( // Everything failed -- fallback to fetching the most recent notifications return@coroutineScope mastodonApi.notifications( limit = params.loadSize, - excludes = notificationFilter + excludes = notificationFilter, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsRepository.kt index 7de654f8a..0baa58f32 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsRepository.kt @@ -37,7 +37,7 @@ import javax.inject.Inject class NotificationsRepository @Inject constructor( private val mastodonApi: MastodonApi, private val gson: Gson, - @ApplicationScope private val externalScope: CoroutineScope + @ApplicationScope private val externalScope: CoroutineScope, ) { private var factory: InvalidatingPagingSourceFactory? = null @@ -48,7 +48,7 @@ class NotificationsRepository @Inject constructor( fun getNotificationsStream( filter: Set, pageSize: Int = PAGE_SIZE, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getNotificationsStream(), filtering: $filter") @@ -59,7 +59,7 @@ class NotificationsRepository @Inject constructor( return Pager( config = PagingConfig(pageSize = pageSize, initialLoadSize = pageSize), initialKey = initialKey, - pagingSourceFactory = factory!! + pagingSourceFactory = factory!!, ).flow } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModel.kt index 8e010f9a4..e3f42f5fe 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModel.kt @@ -82,17 +82,17 @@ data class UiState( val activeFilter: Set = emptySet(), /** True if the FAB should be shown while scrolling */ - val showFabWhileScrolling: Boolean = true + val showFabWhileScrolling: Boolean = true, ) /** Preferences the UI reacts to */ data class UiPrefs( - val showFabWhileScrolling: Boolean + val showFabWhileScrolling: Boolean, ) { companion object { /** Relevant preference keys. Changes to any of these trigger a display update */ val prefKeys = setOf( - PrefKeys.FAB_HIDE + PrefKeys.FAB_HIDE, ) } } @@ -164,7 +164,7 @@ sealed class NotificationActionSuccess( * The original action, in case additional information is required from it to display the * message. */ - open val action: NotificationAction + open val action: NotificationAction, ) : UiSuccess() { data class AcceptFollowRequest(override val action: NotificationAction) : NotificationActionSuccess(R.string.ui_success_accepted_follow_request, action) @@ -181,7 +181,7 @@ sealed class NotificationActionSuccess( /** Actions the user can trigger on an individual status */ sealed class StatusAction( - open val statusViewData: StatusViewData + open val statusViewData: StatusViewData, ) : FallibleUiAction() { /** Set the bookmark state for a status */ data class Bookmark(val state: Boolean, override val statusViewData: StatusViewData) : @@ -199,7 +199,7 @@ sealed class StatusAction( data class VoteInPoll( val poll: Poll, val choices: List, - override val statusViewData: StatusViewData + override val statusViewData: StatusViewData, ) : StatusAction(statusViewData) } @@ -236,45 +236,45 @@ sealed class UiError( @StringRes val message: Int, /** The action that failed. Can be resent to retry the action */ - open val action: UiAction? = null + open val action: UiAction? = null, ) { data class ClearNotifications(override val throwable: Throwable) : UiError( throwable, - R.string.ui_error_clear_notifications + R.string.ui_error_clear_notifications, ) data class Bookmark( override val throwable: Throwable, - override val action: StatusAction.Bookmark + override val action: StatusAction.Bookmark, ) : UiError(throwable, R.string.ui_error_bookmark, action) data class Favourite( override val throwable: Throwable, - override val action: StatusAction.Favourite + override val action: StatusAction.Favourite, ) : UiError(throwable, R.string.ui_error_favourite, action) data class Reblog( override val throwable: Throwable, - override val action: StatusAction.Reblog + override val action: StatusAction.Reblog, ) : UiError(throwable, R.string.ui_error_reblog, action) data class VoteInPoll( override val throwable: Throwable, - override val action: StatusAction.VoteInPoll + override val action: StatusAction.VoteInPoll, ) : UiError(throwable, R.string.ui_error_vote, action) data class AcceptFollowRequest( override val throwable: Throwable, - override val action: NotificationAction.AcceptFollowRequest + override val action: NotificationAction.AcceptFollowRequest, ) : UiError(throwable, R.string.ui_error_accept_follow_request, action) data class RejectFollowRequest( override val throwable: Throwable, - override val action: NotificationAction.RejectFollowRequest + override val action: NotificationAction.RejectFollowRequest, ) : UiError(throwable, R.string.ui_error_reject_follow_request, action) data class GetFilters( - override val throwable: Throwable + override val throwable: Throwable, ) : UiError(throwable, R.string.ui_error_filter_v1_load, null) companion object { @@ -298,7 +298,7 @@ class NotificationsViewModel @Inject constructor( private val timelineCases: TimelineCases, private val eventHub: EventHub, private val filtersRepository: FiltersRepository, - private val filterModel: FilterModel + private val filterModel: FilterModel, ) : ViewModel() { /** The account to display notifications for */ val account = accountManager.activeAccount!! @@ -355,8 +355,8 @@ class NotificationsViewModel @Inject constructor( .onStart { emit( InfallibleUiAction.ApplyFilter( - filter = deserialize(account.notificationsFilter) - ) + filter = deserialize(account.notificationsFilter), + ), ) } @@ -391,8 +391,8 @@ class NotificationsViewModel @Inject constructor( statusDisplayOptions = MutableStateFlow( StatusDisplayOptions.from( preferences, - account - ) + account, + ), ) viewModelScope.launch { @@ -403,7 +403,7 @@ class NotificationsViewModel @Inject constructor( statusDisplayOptions.value.make( preferences, it.preferenceKey, - account + account, ) } .collect { @@ -458,23 +458,23 @@ class NotificationsViewModel @Inject constructor( is StatusAction.Bookmark -> timelineCases.bookmark( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.Favourite -> timelineCases.favourite( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.Reblog -> timelineCases.reblog( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.VoteInPoll -> timelineCases.voteInPoll( action.statusViewData.actionableId, action.poll.id, - action.choices + action.choices, ) }.getOrThrow() uiSuccess.emit(StatusActionSuccess.from(action)) @@ -516,18 +516,18 @@ class NotificationsViewModel @Inject constructor( uiState = combine(notificationFilter, getUiPrefs()) { filter, prefs -> UiState( activeFilter = filter.filter, - showFabWhileScrolling = prefs.showFabWhileScrolling + showFabWhileScrolling = prefs.showFabWhileScrolling, ) }.stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5000), - initialValue = UiState() + initialValue = UiState(), ) } private fun getNotifications( filters: Set, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getNotifications: $initialKey") return repository.getNotificationsStream(filter = filters, initialKey = initialKey) @@ -539,7 +539,7 @@ class NotificationsViewModel @Inject constructor( !(notification.status?.actionableStatus?.sensitive ?: false), isExpanded = statusDisplayOptions.value.openSpoiler, isCollapsed = true, - filterAction = filterAction + filterAction = filterAction, ) }.filter { it.statusViewData?.filterAction != Filter.Action.HIDE @@ -561,7 +561,7 @@ class NotificationsViewModel @Inject constructor( filterModel.initWithFilters( filters.filters.filter { it.context.contains("notifications") - } + }, ) repository.invalidate() } @@ -594,7 +594,7 @@ class NotificationsViewModel @Inject constructor( .onStart { emit(toPrefs()) } private fun toPrefs() = UiPrefs( - showFabWhileScrolling = !preferences.getBoolean(PrefKeys.FAB_HIDE, false) + showFabWhileScrolling = !preferences.getBoolean(PrefKeys.FAB_HIDE, false), ) companion object { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt index f61307e3e..82c824891 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt @@ -55,7 +55,7 @@ fun showMigrationNoticeIfNecessary( context: Context, parent: View, anchorView: View?, - accountManager: AccountManager + accountManager: AccountManager, ) { // No point showing anything if we cannot enable it if (!isUnifiedPushAvailable(context)) return @@ -163,7 +163,7 @@ suspend fun registerUnifiedPushEndpoint( api: MastodonApi, accountManager: AccountManager, account: AccountEntity, - endpoint: String + endpoint: String, ) = withContext(Dispatchers.IO) { // Generate a prime256v1 key pair for WebPush // Decryption is unimplemented for now, since Mastodon uses an old WebPush @@ -179,7 +179,7 @@ suspend fun registerUnifiedPushEndpoint( endpoint, keyPair.pubkey, auth, - buildSubscriptionData(context, account) + buildSubscriptionData(context, account), ).onFailure { throwable -> Log.w(TAG, "Error setting push endpoint for account ${account.id}", throwable) disableUnifiedPushNotificationsForAccount(context, account) @@ -201,7 +201,7 @@ suspend fun updateUnifiedPushSubscription(context: Context, api: MastodonApi, ac api.updatePushNotificationSubscription( "Bearer ${account.accessToken}", account.domain, - buildSubscriptionData(context, account) + buildSubscriptionData(context, account), ).onSuccess { Log.d(TAG, "UnifiedPush subscription updated for account ${account.id}") diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusNotificationViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusNotificationViewHolder.kt index ab23d45d2..a6ba34d30 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusNotificationViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusNotificationViewHolder.kt @@ -67,22 +67,22 @@ internal class StatusNotificationViewHolder( private val binding: ItemStatusNotificationBinding, private val statusActionListener: StatusActionListener, private val notificationActionListener: NotificationActionListener, - private val absoluteTimeFormatter: AbsoluteTimeFormatter + private val absoluteTimeFormatter: AbsoluteTimeFormatter, ) : NotificationsPagingAdapter.ViewHolder, RecyclerView.ViewHolder(binding.root) { private val avatarRadius48dp = itemView.context.resources.getDimensionPixelSize( - R.dimen.avatar_radius_48dp + R.dimen.avatar_radius_48dp, ) private val avatarRadius36dp = itemView.context.resources.getDimensionPixelSize( - R.dimen.avatar_radius_36dp + R.dimen.avatar_radius_36dp, ) private val avatarRadius24dp = itemView.context.resources.getDimensionPixelSize( - R.dimen.avatar_radius_24dp + R.dimen.avatar_radius_24dp, ) override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { val statusViewData = viewData.statusViewData if (payloads.isNullOrEmpty()) { @@ -103,13 +103,13 @@ internal class StatusNotificationViewHolder( account.avatar, account.bot, statusDisplayOptions.animateAvatars, - statusDisplayOptions.showBotOverlay + statusDisplayOptions.showBotOverlay, ) } else { setAvatars( account.avatar, viewData.account.avatar, - statusDisplayOptions.animateAvatars + statusDisplayOptions.animateAvatars, ) } @@ -129,7 +129,7 @@ internal class StatusNotificationViewHolder( if (StatusBaseViewHolder.Key.KEY_CREATED == item && statusViewData != null) { setCreatedAt( statusViewData.status.actionableStatus.createdAt, - statusDisplayOptions.useAbsoluteTime + statusDisplayOptions.useAbsoluteTime, ) } } @@ -178,7 +178,7 @@ internal class StatusNotificationViewHolder( then, now, DateUtils.SECOND_IN_MILLIS, - DateUtils.FORMAT_ABBREV_RELATIVE + DateUtils.FORMAT_ABBREV_RELATIVE, ) } else { // unknown minutes~ @@ -193,7 +193,7 @@ internal class StatusNotificationViewHolder( private fun getIconWithColor( context: Context, @DrawableRes drawable: Int, - @ColorRes color: Int + @ColorRes color: Int, ): Drawable? { val icon = ContextCompat.getDrawable(context, drawable) icon?.setColorFilter(context.getColor(color), PorterDuff.Mode.SRC_ATOP) @@ -206,7 +206,7 @@ internal class StatusNotificationViewHolder( statusAvatarUrl, binding.notificationStatusAvatar, avatarRadius48dp, - animateAvatars + animateAvatars, ) if (showBotOverlay && isBot) { binding.notificationNotificationAvatar.visibility = View.VISIBLE @@ -225,21 +225,21 @@ internal class StatusNotificationViewHolder( statusAvatarUrl, binding.notificationStatusAvatar, avatarRadius36dp, - animateAvatars + animateAvatars, ) binding.notificationNotificationAvatar.visibility = View.VISIBLE loadAvatar( notificationAvatarUrl, binding.notificationNotificationAvatar, avatarRadius24dp, - animateAvatars + animateAvatars, ) } fun setMessage( notificationViewData: NotificationViewData, listener: LinkListener, - animateEmojis: Boolean + animateEmojis: Boolean, ) { val statusViewData = notificationViewData.statusViewData val displayName = notificationViewData.account.name.unicodeWrap() @@ -273,7 +273,7 @@ internal class StatusNotificationViewHolder( icon, null, null, - null + null, ) val wholeMessage = String.format(format, displayName) val str = SpannableStringBuilder(wholeMessage) @@ -282,12 +282,12 @@ internal class StatusNotificationViewHolder( StyleSpan(Typeface.BOLD), displayNameIndex, displayNameIndex + displayName.length, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE, ) val emojifiedText = str.emojify( notificationViewData.account.emojis, binding.notificationTopText, - animateEmojis + animateEmojis, ) binding.notificationTopText.text = emojifiedText if (statusViewData != null) { @@ -298,18 +298,18 @@ internal class StatusNotificationViewHolder( if (hasSpoiler) View.VISIBLE else View.GONE if (statusViewData.isExpanded) { binding.notificationContentWarningButton.setText( - R.string.post_content_warning_show_less + R.string.post_content_warning_show_less, ) } else { binding.notificationContentWarningButton.setText( - R.string.post_content_warning_show_more + R.string.post_content_warning_show_more, ) } binding.notificationContentWarningButton.setOnClickListener { if (bindingAdapterPosition != RecyclerView.NO_POSITION) { notificationActionListener.onExpandedChange( !statusViewData.isExpanded, - bindingAdapterPosition + bindingAdapterPosition, ) } binding.notificationContent.visibility = @@ -322,7 +322,7 @@ internal class StatusNotificationViewHolder( private fun setupContentAndSpoiler( listener: LinkListener, statusViewData: StatusViewData, - animateEmojis: Boolean + animateEmojis: Boolean, ) { val shouldShowContentIfSpoiler = statusViewData.isExpanded val hasSpoiler = !TextUtils.isEmpty(statusViewData.status.spoilerText) @@ -339,19 +339,19 @@ internal class StatusNotificationViewHolder( if (position != RecyclerView.NO_POSITION) { notificationActionListener.onNotificationContentCollapsedChange( !statusViewData.isCollapsed, - position + position, ) } } binding.buttonToggleNotificationContent.visibility = View.VISIBLE if (statusViewData.isCollapsed) { binding.buttonToggleNotificationContent.setText( - R.string.post_content_warning_show_more + R.string.post_content_warning_show_more, ) binding.notificationContent.filters = COLLAPSE_INPUT_FILTER } else { binding.buttonToggleNotificationContent.setText( - R.string.post_content_warning_show_less + R.string.post_content_warning_show_less, ) binding.notificationContent.filters = NO_INPUT_FILTER } @@ -363,19 +363,19 @@ internal class StatusNotificationViewHolder( content.emojify( emojis, binding.notificationContent, - animateEmojis + animateEmojis, ) setClickableText( binding.notificationContent, emojifiedText, statusViewData.actionable.mentions, statusViewData.actionable.tags, - listener + listener, ) val emojifiedContentWarning: CharSequence = statusViewData.spoilerText.emojify( statusViewData.actionable.emojis, binding.notificationContentWarningDescription, - animateEmojis + animateEmojis, ) binding.notificationContentWarningDescription.text = emojifiedContentWarning } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusViewHolder.kt index 380129130..b5f5bb070 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/StatusViewHolder.kt @@ -27,13 +27,13 @@ import com.keylesspalace.tusky.viewdata.NotificationViewData internal class StatusViewHolder( binding: ViewBinding, private val statusActionListener: StatusActionListener, - private val accountId: String + private val accountId: String, ) : NotificationsPagingAdapter.ViewHolder, StatusViewHolder(binding.root) { override fun bind( viewData: NotificationViewData, payloads: List<*>?, - statusDisplayOptions: StatusDisplayOptions + statusDisplayOptions: StatusDisplayOptions, ) { val statusViewData = viewData.statusViewData if (statusViewData == null) { @@ -48,7 +48,7 @@ internal class StatusViewHolder( statusViewData, statusActionListener, statusDisplayOptions, - payloads?.firstOrNull() + payloads?.firstOrNull(), ) } if (viewData.type == Notification.Type.POLL) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt index b0fedb2b1..16446ac28 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt @@ -99,7 +99,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { activity?.startActivity(intent) activity?.overridePendingTransition( R.anim.slide_from_right, - R.anim.slide_to_left + R.anim.slide_to_left, ) true } @@ -113,7 +113,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { activity?.startActivity(intent) activity?.overridePendingTransition( R.anim.slide_from_right, - R.anim.slide_to_left + R.anim.slide_to_left, ) true } @@ -128,7 +128,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { activity?.startActivity(intent) activity?.overridePendingTransition( R.anim.slide_from_right, - R.anim.slide_to_left + R.anim.slide_to_left, ) true } @@ -146,7 +146,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { activity?.startActivity(intent) activity?.overridePendingTransition( R.anim.slide_from_right, - R.anim.slide_to_left + R.anim.slide_to_left, ) true } @@ -160,7 +160,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { activity?.startActivity(intent) activity?.overridePendingTransition( R.anim.slide_from_right, - R.anim.slide_to_left + R.anim.slide_to_left, ) true } @@ -294,28 +294,30 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { // TODO these could also be "datastore backed" preferences (a ServerPreferenceDataStore); follow-up of issue #3204 mastodonApi.accountUpdateSource(visibility, sensitive, language) - .enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - val account = response.body() - if (response.isSuccessful && account != null) { - accountManager.activeAccount?.let { - it.defaultPostPrivacy = account.source?.privacy - ?: Status.Visibility.PUBLIC - it.defaultMediaSensitivity = account.source?.sensitive ?: false - it.defaultPostLanguage = language.orEmpty() - accountManager.saveAccount(it) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + val account = response.body() + if (response.isSuccessful && account != null) { + accountManager.activeAccount?.let { + it.defaultPostPrivacy = account.source?.privacy + ?: Status.Visibility.PUBLIC + it.defaultMediaSensitivity = account.source?.sensitive ?: false + it.defaultPostLanguage = language.orEmpty() + accountManager.saveAccount(it) + } + } else { + Log.e("AccountPreferences", "failed updating settings on server") + showErrorSnackbar(visibility, sensitive) } - } else { - Log.e("AccountPreferences", "failed updating settings on server") + } + + override fun onFailure(call: Call, t: Throwable) { + Log.e("AccountPreferences", "failed updating settings on server", t) showErrorSnackbar(visibility, sensitive) } - } - - override fun onFailure(call: Call, t: Throwable) { - Log.e("AccountPreferences", "failed updating settings on server", t) - showErrorSnackbar(visibility, sensitive) - } - }) + }, + ) } private fun showErrorSnackbar(visibility: String?, sensitive: Boolean?) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt index a3b8cbc68..04f23aa2b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt @@ -97,18 +97,18 @@ class PreferencesActivity : onBackPressedDispatcher.addCallback(this, restartActivitiesOnBackPressedCallback) restartActivitiesOnBackPressedCallback.isEnabled = intent.extras?.getBoolean( - EXTRA_RESTART_ON_BACK + EXTRA_RESTART_ON_BACK, ) ?: savedInstanceState?.getBoolean(EXTRA_RESTART_ON_BACK, false) ?: false } override fun onPreferenceStartFragment( caller: PreferenceFragmentCompat, - pref: Preference + pref: Preference, ): Boolean { val args = pref.extras val fragment = supportFragmentManager.fragmentFactory.instantiate( classLoader, - pref.fragment!! + pref.fragment!!, ) fragment.arguments = args fragment.setTargetFragment(caller, 0) @@ -117,7 +117,7 @@ class PreferencesActivity : R.anim.slide_from_right, R.anim.slide_to_left, R.anim.slide_from_left, - R.anim.slide_to_right + R.anim.slide_to_right, ) replace(R.id.fragment_container, fragment) addToBackStack(null) @@ -160,7 +160,8 @@ class PreferencesActivity : } "statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars", "useBlurhash", "showSelfUsername", "showCardsInTimelines", "confirmReblogs", "confirmFavourites", - "enableSwipeForTabs", "mainNavPosition", PrefKeys.HIDE_TOP_TOOLBAR, PrefKeys.SHOW_STATS_INLINE -> { + "enableSwipeForTabs", "mainNavPosition", PrefKeys.HIDE_TOP_TOOLBAR, PrefKeys.SHOW_STATS_INLINE, + -> { restartActivitiesOnBackPressedCallback.isEnabled = true } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/ProxyPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/ProxyPreferencesFragment.kt index da63db127..ea2c298a6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/ProxyPreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/ProxyPreferencesFragment.kt @@ -56,7 +56,7 @@ class ProxyPreferencesFragment : PreferenceFragmentCompat() { val portErrorMessage = getString( R.string.pref_title_http_proxy_port_message, MIN_PROXY_PORT, - MAX_PROXY_PORT + MAX_PROXY_PORT, ) validatedEditTextPreference(portErrorMessage, ProxyConfiguration::isValidProxyPort) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt index c56be7d30..4fce5a844 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt @@ -46,7 +46,7 @@ import javax.inject.Inject class ReportViewModel @Inject constructor( private val mastodonApi: MastodonApi, - private val eventHub: EventHub + private val eventHub: EventHub, ) : ViewModel() { private val navigationMutable = MutableLiveData() @@ -66,14 +66,14 @@ class ReportViewModel @Inject constructor( private val accountIdFlow = MutableSharedFlow( replay = 1, - onBufferOverflow = BufferOverflow.DROP_OLDEST + onBufferOverflow = BufferOverflow.DROP_OLDEST, ) val statusesFlow = accountIdFlow.flatMapLatest { accountId -> Pager( initialKey = statusId, config = PagingConfig(pageSize = 20, initialLoadSize = 20), - pagingSourceFactory = { StatusesPagingSource(accountId, mastodonApi) } + pagingSourceFactory = { StatusesPagingSource(accountId, mastodonApi) }, ).flow } .map { pagingData -> @@ -134,7 +134,7 @@ class ReportViewModel @Inject constructor( }, { updateRelationship(null) - } + }, ) } } @@ -166,7 +166,7 @@ class ReportViewModel @Inject constructor( }, { t -> muteStateMutable.value = Error(false, t.message) - } + }, ) } @@ -188,7 +188,7 @@ class ReportViewModel @Inject constructor( } }, { t -> blockStateMutable.value = Error(false, t.message) - }) + },) } blockStateMutable.value = Loading() } @@ -201,7 +201,7 @@ class ReportViewModel @Inject constructor( reportingStateMutable.value = Success(true) }, { error -> reportingStateMutable.value = Error(cause = error) - }) + },) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/Screen.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/Screen.kt index fb0b15cae..e3c5c197d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/Screen.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/Screen.kt @@ -20,5 +20,5 @@ enum class Screen { Note, Done, Back, - Finish + Finish, } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusViewHolder.kt index ba076b77e..d985f729d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusViewHolder.kt @@ -47,7 +47,7 @@ class StatusViewHolder( private val statusDisplayOptions: StatusDisplayOptions, private val viewState: StatusViewState, private val adapterHandler: AdapterHandler, - private val getStatusForPosition: (Int) -> StatusViewData? + private val getStatusForPosition: (Int) -> StatusViewData?, ) : RecyclerView.ViewHolder(binding.root) { private val mediaViewHeight = itemView.context.resources.getDimensionPixelSize(R.dimen.status_media_preview_height) @@ -90,7 +90,7 @@ class StatusViewHolder( sensitive, previewListener, viewState.isMediaShow(viewData.id, viewData.status.sensitive), - mediaViewHeight + mediaViewHeight, ) statusViewHelper.setupPollReadonly(viewData.status.poll.toViewData(), viewData.status.emojis, statusDisplayOptions) @@ -103,7 +103,7 @@ class StatusViewHolder( shouldTrimStatus(viewdata.content), viewState.isCollapsed(viewdata.id, true), viewState.isContentShow(viewdata.id, viewdata.status.sensitive), - viewdata.spoilerText + viewdata.spoilerText, ) if (viewdata.spoilerText.isBlank()) { @@ -144,7 +144,7 @@ class StatusViewHolder( mentions: List, tags: List?, emojis: List, - listener: LinkListener + listener: LinkListener, ) { if (expanded) { val emojifiedText = content.emojify(emojis, binding.statusContent, statusDisplayOptions.animateEmojis) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesAdapter.kt index dab371ccf..c1c414f77 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesAdapter.kt @@ -28,7 +28,7 @@ import com.keylesspalace.tusky.viewdata.StatusViewData class StatusesAdapter( private val statusDisplayOptions: StatusDisplayOptions, private val statusViewState: StatusViewState, - private val adapterHandler: AdapterHandler + private val adapterHandler: AdapterHandler, ) : PagingDataAdapter(STATUS_COMPARATOR) { private val statusForPosition: (Int) -> StatusViewData? = { position: Int -> @@ -42,7 +42,7 @@ class StatusesAdapter( statusDisplayOptions, statusViewState, adapterHandler, - statusForPosition + statusForPosition, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt index c007239d8..c09626e2c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt @@ -27,7 +27,7 @@ import kotlinx.coroutines.withContext class StatusesPagingSource( private val accountId: String, - private val mastodonApi: MastodonApi + private val mastodonApi: MastodonApi, ) : PagingSource() { override fun getRefreshKey(state: PagingState): String? { @@ -63,7 +63,7 @@ class StatusesPagingSource( return LoadResult.Page( data = result, prevKey = result.firstOrNull()?.id, - nextKey = result.lastOrNull()?.id + nextKey = result.lastOrNull()?.id, ) } catch (e: Exception) { Log.w("StatusesPagingSource", "failed to load statuses", e) @@ -82,7 +82,7 @@ class StatusesPagingSource( sinceId = null, minId = minId, limit = limit, - excludeReblogs = true + excludeReblogs = true, ).await() } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportDoneFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportDoneFragment.kt index 0f8065776..441945e5e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportDoneFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportDoneFragment.kt @@ -60,7 +60,7 @@ class ReportDoneFragment : Fragment(R.layout.fragment_report_done), Injectable { when (it.data) { true -> R.string.action_unmute else -> R.string.action_mute - } + }, ) } @@ -76,7 +76,7 @@ class ReportDoneFragment : Fragment(R.layout.fragment_report_done), Injectable { when (it.data) { true -> R.string.action_unblock else -> R.string.action_block - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportStatusesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportStatusesFragment.kt index 362680f6f..cb8d00ef9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportStatusesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportStatusesFragment.kt @@ -159,7 +159,7 @@ class ReportStatusesFragment : animateEmojis = preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), showStatsInline = preferences.getBoolean(PrefKeys.SHOW_STATS_INLINE, false), showSensitiveMedia = accountManager.activeAccount!!.alwaysShowSensitiveMedia, - openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler + openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler, ) adapter = StatusesAdapter(statusDisplayOptions, viewModel.statusViewState, this) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt index a53c08928..38df7fd4a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusActivity.kt @@ -163,8 +163,8 @@ class ScheduledStatusActivity : visibility = item.params.visibility, scheduledAt = item.scheduledAt, sensitive = item.params.sensitive, - kind = ComposeActivity.ComposeKind.EDIT_SCHEDULED - ) + kind = ComposeActivity.ComposeKind.EDIT_SCHEDULED, + ), ) startActivity(intent) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusAdapter.kt index 9d51bc53c..97960545f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusAdapter.kt @@ -29,7 +29,7 @@ interface ScheduledStatusActionListener { } class ScheduledStatusAdapter( - val listener: ScheduledStatusActionListener + val listener: ScheduledStatusActionListener, ) : PagingDataAdapter>( object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean { @@ -39,7 +39,7 @@ class ScheduledStatusAdapter( override fun areContentsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean { return oldItem == newItem } - } + }, ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt index c9af661e4..7461f6150 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt @@ -23,7 +23,7 @@ import com.keylesspalace.tusky.network.MastodonApi import kotlinx.coroutines.rx3.await class ScheduledStatusPagingSourceFactory( - private val mastodonApi: MastodonApi + private val mastodonApi: MastodonApi, ) : () -> ScheduledStatusPagingSource { private val scheduledTootsCache = mutableListOf() @@ -44,7 +44,7 @@ class ScheduledStatusPagingSourceFactory( class ScheduledStatusPagingSource( private val mastodonApi: MastodonApi, - private val scheduledStatusesCache: MutableList + private val scheduledStatusesCache: MutableList, ) : PagingSource() { override fun getRefreshKey(state: PagingState): String? { @@ -56,19 +56,19 @@ class ScheduledStatusPagingSource( LoadResult.Page( data = scheduledStatusesCache, prevKey = null, - nextKey = scheduledStatusesCache.lastOrNull()?.id + nextKey = scheduledStatusesCache.lastOrNull()?.id, ) } else { try { val result = mastodonApi.scheduledStatuses( maxId = params.key, - limit = params.loadSize + limit = params.loadSize, ).await() LoadResult.Page( data = result, prevKey = null, - nextKey = result.lastOrNull()?.id + nextKey = result.lastOrNull()?.id, ) } catch (e: Exception) { Log.w("ScheduledStatuses", "Error loading scheduled statuses", e) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt index 483c8e4df..fd51f5442 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt @@ -30,14 +30,14 @@ import javax.inject.Inject class ScheduledStatusViewModel @Inject constructor( val mastodonApi: MastodonApi, - val eventHub: EventHub + val eventHub: EventHub, ) : ViewModel() { private val pagingSourceFactory = ScheduledStatusPagingSourceFactory(mastodonApi) val data = Pager( config = PagingConfig(pageSize = 20, initialLoadSize = 20), - pagingSourceFactory = pagingSourceFactory + pagingSourceFactory = pagingSourceFactory, ).flow .cachedIn(viewModelScope) @@ -49,7 +49,7 @@ class ScheduledStatusViewModel @Inject constructor( }, { throwable -> Log.w("ScheduledTootViewModel", "Error deleting scheduled status", throwable) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchType.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchType.kt index 235f8ce03..31edc70e1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchType.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchType.kt @@ -18,5 +18,5 @@ package com.keylesspalace.tusky.components.search enum class SearchType(val apiParameter: String) { Status("statuses"), Account("accounts"), - Hashtag("hashtags") + Hashtag("hashtags"), } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt index dbc571a5d..31f6df0e4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt @@ -41,7 +41,7 @@ import javax.inject.Inject class SearchViewModel @Inject constructor( mastodonApi: MastodonApi, private val timelineCases: TimelineCases, - private val accountManager: AccountManager + private val accountManager: AccountManager, ) : ViewModel() { var currentQuery: String = "" @@ -61,7 +61,7 @@ class SearchViewModel @Inject constructor( status.toViewData( isShowingContent = alwaysShowSensitiveMedia || !status.actionableStatus.sensitive, isExpanded = alwaysOpenSpoiler, - isCollapsed = true + isCollapsed = true, ) }.apply { loadedStatuses.addAll(this) @@ -76,19 +76,19 @@ class SearchViewModel @Inject constructor( val statusesFlow = Pager( config = PagingConfig(pageSize = DEFAULT_LOAD_SIZE, initialLoadSize = DEFAULT_LOAD_SIZE), - pagingSourceFactory = statusesPagingSourceFactory + pagingSourceFactory = statusesPagingSourceFactory, ).flow .cachedIn(viewModelScope) val accountsFlow = Pager( config = PagingConfig(pageSize = DEFAULT_LOAD_SIZE, initialLoadSize = DEFAULT_LOAD_SIZE), - pagingSourceFactory = accountsPagingSourceFactory + pagingSourceFactory = accountsPagingSourceFactory, ).flow .cachedIn(viewModelScope) val hashtagsFlow = Pager( config = PagingConfig(pageSize = DEFAULT_LOAD_SIZE, initialLoadSize = DEFAULT_LOAD_SIZE), - pagingSourceFactory = hashtagsPagingSourceFactory + pagingSourceFactory = hashtagsPagingSourceFactory, ).flow .cachedIn(viewModelScope) @@ -119,12 +119,12 @@ class SearchViewModel @Inject constructor( updateStatus( statusViewData.status.copy( reblogged = reblog, - reblog = statusViewData.status.reblog?.copy(reblogged = reblog) - ) + reblog = statusViewData.status.reblog?.copy(reblogged = reblog), + ), ) }, { t -> Log.d(TAG, "Failed to reblog status ${statusViewData.id}", t) - }) + },) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchAccountsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchAccountsAdapter.kt index a8b913081..73e3ac760 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchAccountsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchAccountsAdapter.kt @@ -31,7 +31,7 @@ class SearchAccountsAdapter(private val linkListener: LinkListener, private val val binding = ItemAccountBinding.inflate( LayoutInflater.from(parent.context), parent, - false + false, ) return AccountViewHolder(binding) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt index 10339536a..e40bea712 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt @@ -27,7 +27,7 @@ class SearchPagingSource( private val searchType: SearchType, private val searchRequest: String, private val initialItems: List?, - private val parser: (SearchResult) -> List + private val parser: (SearchResult) -> List, ) : PagingSource() { override fun getRefreshKey(state: PagingState): Int? { @@ -39,7 +39,7 @@ class SearchPagingSource( return LoadResult.Page( data = emptyList(), prevKey = null, - nextKey = null + nextKey = null, ) } @@ -47,7 +47,7 @@ class SearchPagingSource( return LoadResult.Page( data = initialItems.toList(), prevKey = null, - nextKey = initialItems.size + nextKey = initialItems.size, ) } @@ -60,7 +60,7 @@ class SearchPagingSource( resolve = true, limit = params.loadSize, offset = currentKey, - following = false + following = false, ).await() val res = parser(data) @@ -74,7 +74,7 @@ class SearchPagingSource( return LoadResult.Page( data = res, prevKey = null, - nextKey = nextKey + nextKey = nextKey, ) } catch (e: Exception) { return LoadResult.Error(e) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSourceFactory.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSourceFactory.kt index f995d029b..dfe323364 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSourceFactory.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSourceFactory.kt @@ -23,7 +23,7 @@ class SearchPagingSourceFactory( private val mastodonApi: MastodonApi, private val searchType: SearchType, private val initialItems: List? = null, - private val parser: (SearchResult) -> List + private val parser: (SearchResult) -> List, ) : () -> SearchPagingSource { private var searchRequest: String = "" @@ -36,7 +36,7 @@ class SearchPagingSourceFactory( searchType = searchType, searchRequest = searchRequest, initialItems = initialItems, - parser = parser + parser = parser, ).also { source -> currentSource = source } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchStatusesAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchStatusesAdapter.kt index 6517308bc..6ea13140c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchStatusesAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchStatusesAdapter.kt @@ -27,7 +27,7 @@ import com.keylesspalace.tusky.viewdata.StatusViewData class SearchStatusesAdapter( private val statusDisplayOptions: StatusDisplayOptions, - private val statusListener: StatusActionListener + private val statusListener: StatusActionListener, ) : PagingDataAdapter(STATUS_COMPARATOR) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatusViewHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchAccountsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchAccountsFragment.kt index 1bcfaaaa0..b5e402a9d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchAccountsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchAccountsFragment.kt @@ -32,8 +32,8 @@ class SearchAccountsFragment : SearchFragment() { binding.searchRecyclerView.addItemDecoration( DividerItemDecoration( binding.searchRecyclerView.context, - DividerItemDecoration.VERTICAL - ) + DividerItemDecoration.VERTICAL, + ), ) } @@ -44,7 +44,7 @@ class SearchAccountsFragment : SearchFragment() { this, preferences.getBoolean(PrefKeys.ANIMATE_GIF_AVATARS, false), preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), - preferences.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true) + preferences.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchHashtagsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchHashtagsFragment.kt index 8c4f41fb0..8117cebd9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchHashtagsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchHashtagsFragment.kt @@ -34,8 +34,8 @@ class SearchHashtagsFragment : SearchFragment() { binding.searchRecyclerView.addItemDecoration( DividerItemDecoration( binding.searchRecyclerView.context, - DividerItemDecoration.VERTICAL - ) + DividerItemDecoration.VERTICAL, + ), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt index 0cbe30047..6567e5c15 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt @@ -90,7 +90,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis animateEmojis = preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), showStatsInline = preferences.getBoolean(PrefKeys.SHOW_STATS_INLINE, false), showSensitiveMedia = accountManager.activeAccount!!.alwaysShowSensitiveMedia, - openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler + openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler, ) binding.searchRecyclerView.addItemDecoration(DividerItemDecoration(binding.searchRecyclerView.context, DividerItemDecoration.VERTICAL)) @@ -136,7 +136,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis val intent = ViewMediaActivity.newIntent( context, attachments, - attachmentIndex + attachmentIndex, ) if (view != null) { val url = actionable.attachments[attachmentIndex].url @@ -144,7 +144,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis val options = ActivityOptionsCompat.makeSceneTransitionAnimation( requireActivity(), view, - url + url, ) startActivity(intent, options.toBundle()) } else { @@ -226,8 +226,8 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis replyingStatusAuthor = actionableStatus.account.localUsername, replyingStatusContent = status.content.toString(), language = actionableStatus.language, - kind = ComposeActivity.ComposeKind.NEW - ) + kind = ComposeActivity.ComposeKind.NEW, + ), ) bottomSheetActivity?.startActivityWithSlideInAnimation(intent) } @@ -284,7 +284,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis R.string.action_unmute_conversation } else { R.string.action_mute_conversation - } + }, ) } @@ -384,7 +384,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis private fun onMute(accountId: String, accountUsername: String) { showMuteAccountDialog( this.requireActivity(), - accountUsername + accountUsername, ) { notifications, duration -> viewModel.muteAccount(accountId, notifications, duration) } @@ -404,7 +404,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis override fun onAccountSelected(account: AccountEntity) { bottomSheetActivity?.openAsAccount(statusUrl, account) } - } + }, ) } @@ -431,7 +431,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis Toast.makeText( context, R.string.error_media_download_permission, - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() } } @@ -484,15 +484,15 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis sensitive = redraftStatus.sensitive, poll = redraftStatus.poll?.toNewPoll(status.createdAt), language = redraftStatus.language, - kind = ComposeActivity.ComposeKind.NEW - ) + kind = ComposeActivity.ComposeKind.NEW, + ), ) startActivity(intent) }, { error -> Log.w("SearchStatusesFragment", "error deleting status", error) Toast.makeText(context, R.string.error_generic, Toast.LENGTH_SHORT).show() - } + }, ) } } @@ -515,7 +515,7 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis language = status.language, statusId = source.id, poll = status.poll?.toNewPoll(status.createdAt), - kind = ComposeActivity.ComposeKind.EDIT_POSTED + kind = ComposeActivity.ComposeKind.EDIT_POSTED, ) startActivity(ComposeActivity.startIntent(requireContext(), composeOptions)) }, @@ -523,9 +523,9 @@ class SearchStatusesFragment : SearchFragment(), StatusActionLis Snackbar.make( requireView(), getString(R.string.error_status_source_load), - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ).show() - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRepository.kt index 7ab7e43d2..a022125f6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRepository.kt @@ -49,7 +49,7 @@ class CachedTimelineRepository @Inject constructor( private val accountManager: AccountManager, private val appDatabase: AppDatabase, private val gson: Gson, - @ApplicationScope private val externalScope: CoroutineScope + @ApplicationScope private val externalScope: CoroutineScope, ) { private var factory: InvalidatingPagingSourceFactory? = null @@ -60,7 +60,7 @@ class CachedTimelineRepository @Inject constructor( fun getStatusStream( kind: TimelineKind, pageSize: Int = PAGE_SIZE, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getStatusStream(): key: $initialKey") @@ -90,9 +90,9 @@ class CachedTimelineRepository @Inject constructor( accountManager, factory!!, appDatabase, - gson + gson, ), - pagingSourceFactory = factory!! + pagingSourceFactory = factory!!, ).flow } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/FiltersRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/FiltersRepository.kt index 03a2ab78f..73e4bad24 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/FiltersRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/FiltersRepository.kt @@ -35,7 +35,7 @@ sealed class FilterKind { /** Repository for filter information */ class FiltersRepository @Inject constructor( - private val mastodonApi: MastodonApi + private val mastodonApi: MastodonApi, ) { /** * Get the current set of filters. @@ -54,7 +54,7 @@ class FiltersRepository @Inject constructor( } else { throw throwable } - } + }, ) companion object { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRepository.kt index a82de5b3d..1b47154e5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRepository.kt @@ -70,7 +70,7 @@ import javax.inject.Inject /** Timeline repository where the timeline information is backed by an in-memory cache. */ class NetworkTimelineRepository @Inject constructor( private val mastodonApi: MastodonApi, - private val accountManager: AccountManager + private val accountManager: AccountManager, ) { private val pageCache = PageCache() @@ -82,7 +82,7 @@ class NetworkTimelineRepository @Inject constructor( viewModelScope: CoroutineScope, kind: TimelineKind, pageSize: Int = PAGE_SIZE, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getStatusStream(): key: $initialKey") @@ -98,9 +98,9 @@ class NetworkTimelineRepository @Inject constructor( accountManager, factory!!, pageCache, - kind + kind, ), - pagingSourceFactory = factory!! + pagingSourceFactory = factory!!, ).flow } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt index 00a2f5467..7a736cd3f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt @@ -152,7 +152,7 @@ class TimelineFragment : override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { return inflater.inflate(R.layout.fragment_timeline, container, false) } @@ -166,27 +166,29 @@ class TimelineFragment : setupRecyclerView() if (actionButtonPresent()) { - binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { - val composeButton = (activity as ActionButtonActivity).actionButton - if (composeButton != null) { - if (!viewModel.uiState.value.showFabWhileScrolling) { - if (dy > 0 && composeButton.isShown) { - composeButton.hide() // hides the button if we're scrolling down - } else if (dy < 0 && !composeButton.isShown) { - composeButton.show() // shows it if we are scrolling up + binding.recyclerView.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + override fun onScrolled(view: RecyclerView, dx: Int, dy: Int) { + val composeButton = (activity as ActionButtonActivity).actionButton + if (composeButton != null) { + if (!viewModel.uiState.value.showFabWhileScrolling) { + if (dy > 0 && composeButton.isShown) { + composeButton.hide() // hides the button if we're scrolling down + } else if (dy < 0 && !composeButton.isShown) { + composeButton.show() // shows it if we are scrolling up + } + } else if (!composeButton.isShown) { + composeButton.show() } - } else if (!composeButton.isShown) { - composeButton.show() } } - } - override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { - newState != SCROLL_STATE_IDLE && return - saveVisibleId() - } - }) + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + newState != SCROLL_STATE_IDLE && return + saveVisibleId() + } + }, + ) } /** @@ -225,13 +227,13 @@ class TimelineFragment : val message = getString( error.message, error.throwable.localizedMessage - ?: getString(R.string.ui_error_unknown) + ?: getString(R.string.ui_error_unknown), ) snackbar = Snackbar.make( // Without this the FAB will not move out of the way (activity as ActionButtonActivity).actionButton ?: binding.root, message, - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ).setTextMaxLines(5) error.action?.let { action -> snackbar!!.setAction(R.string.action_retry) { @@ -278,7 +280,7 @@ class TimelineFragment : statusViewData.status.copy(reblogged = it.action.state) is StatusActionSuccess.VoteInPoll -> statusViewData.status.copy( - poll = it.action.poll.votedCopy(it.action.choices) + poll = it.action.poll.votedCopy(it.action.choices), ) } (indexedViewData.value as StatusViewData).status = status @@ -293,7 +295,8 @@ class TimelineFragment : when (it) { is UiSuccess.Block, is UiSuccess.Mute, - is UiSuccess.MuteConversation -> + is UiSuccess.MuteConversation, + -> adapter.refresh() is UiSuccess.StatusSent -> handleStatusSentOrEdit(it.status) @@ -316,7 +319,7 @@ class TimelineFragment : adapter.notifyItemRangeChanged( first, count, - null + null, ) } @@ -389,7 +392,7 @@ class TimelineFragment : getView() ?: return@post binding.recyclerView.smoothScrollBy( 0, - Utils.dpToPx(requireContext(), -30) + Utils.dpToPx(requireContext(), -30), ) } peeked = true @@ -428,7 +431,7 @@ class TimelineFragment : PresentationState.ERROR -> { val message = (loadState.refresh as LoadState.Error).error.getErrorString( - requireContext() + requireContext(), ) // Show errors as a snackbar if there is existing content to show @@ -439,7 +442,7 @@ class TimelineFragment : (activity as ActionButtonActivity).actionButton ?: binding.root, message, - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ) .setTextMaxLines(5) .setAction(R.string.action_retry) { adapter.retry() } @@ -460,7 +463,7 @@ class TimelineFragment : if (adapter.itemCount == 0) { binding.statusView.setup( R.drawable.elephant_friend_empty, - R.string.message_empty + R.string.message_empty, ) if (timelineKind == TimelineKind.Home) { binding.statusView.showHelp(R.string.help_empty_home) @@ -547,7 +550,7 @@ class TimelineFragment : } else { null } - } + }, ) binding.recyclerView.setHasFixedSize(true) binding.recyclerView.layoutManager = layoutManager @@ -559,7 +562,7 @@ class TimelineFragment : binding.recyclerView.adapter = adapter.withLoadStateHeaderAndFooter( header = TimelineLoadStateAdapter { adapter.retry() }, - footer = TimelineLoadStateAdapter { adapter.retry() } + footer = TimelineLoadStateAdapter { adapter.retry() }, ) } @@ -595,7 +598,7 @@ class TimelineFragment : Snackbar.make( binding.root, "null at adapter.peek($position)", - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ).show() null } ?: return @@ -603,7 +606,7 @@ class TimelineFragment : Snackbar.make( binding.root, "statusViewData had null poll", - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ).show() null } ?: return @@ -657,7 +660,7 @@ class TimelineFragment : super.viewMedia( attachmentIndex, AttachmentViewData.list(status.actionable), - view + view, ) } @@ -703,7 +706,8 @@ class TimelineFragment : is TimelineKind.Home, is TimelineKind.PublicFederated, - is TimelineKind.PublicLocal -> adapter.refresh() + is TimelineKind.PublicLocal, + -> adapter.refresh() is TimelineKind.User -> if (status.account.id == (timelineKind as TimelineKind.User).id) { adapter.refresh() } @@ -711,7 +715,8 @@ class TimelineFragment : is TimelineKind.Favourites, is TimelineKind.Tag, is TimelineKind.TrendingStatuses, - is TimelineKind.UserList -> return + is TimelineKind.UserList, + -> return } } @@ -771,7 +776,7 @@ class TimelineFragment : fun newInstance( timelineKind: TimelineKind, - enableSwipeToRefresh: Boolean = true + enableSwipeToRefresh: Boolean = true, ): TimelineFragment { val fragment = TimelineFragment() val arguments = Bundle(2) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateAdapter.kt index 286f2cdce..cf457e87c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateAdapter.kt @@ -23,11 +23,11 @@ import androidx.paging.LoadStateAdapter /** Show load state and retry options when loading timelines */ class TimelineLoadStateAdapter( - private val retry: () -> Unit + private val retry: () -> Unit, ) : LoadStateAdapter() { override fun onCreateViewHolder( parent: ViewGroup, - loadState: LoadState + loadState: LoadState, ): TimelineLoadStateViewHolder { return TimelineLoadStateViewHolder.create(parent, retry) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateViewHolder.kt index 60b82162b..20fa02583 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineLoadStateViewHolder.kt @@ -38,7 +38,7 @@ import java.net.SocketTimeoutException */ class TimelineLoadStateViewHolder( private val binding: ItemLoadStateFooterViewBinding, - retry: () -> Unit + retry: () -> Unit, ) : RecyclerView.ViewHolder(binding.root) { init { binding.retryButton.setOnClickListener { retry.invoke() } @@ -65,7 +65,7 @@ class TimelineLoadStateViewHolder( val binding = ItemLoadStateFooterViewBinding.inflate( LayoutInflater.from(parent.context), parent, - false + false, ) return TimelineLoadStateViewHolder(binding, retry) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelinePagingAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelinePagingAdapter.kt index 60df0e858..ff8d2a650 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelinePagingAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelinePagingAdapter.kt @@ -30,7 +30,7 @@ import com.keylesspalace.tusky.viewdata.StatusViewData class TimelinePagingAdapter( private val statusListener: StatusActionListener, - var statusDisplayOptions: StatusDisplayOptions + var statusDisplayOptions: StatusDisplayOptions, ) : PagingDataAdapter(TimelineDifferCallback) { override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder { val inflater = LayoutInflater.from(viewGroup.context) @@ -52,7 +52,7 @@ class TimelinePagingAdapter( override fun onBindViewHolder( viewHolder: RecyclerView.ViewHolder, position: Int, - payloads: List<*> + payloads: List<*>, ) { bindViewHolder(viewHolder, position, payloads) } @@ -60,14 +60,14 @@ class TimelinePagingAdapter( private fun bindViewHolder( viewHolder: RecyclerView.ViewHolder, position: Int, - payloads: List<*>? + payloads: List<*>?, ) { getItem(position)?.let { (viewHolder as StatusViewHolder).setupWithStatus( it, statusListener, statusDisplayOptions, - payloads?.getOrNull(0) + payloads?.getOrNull(0), ) } } @@ -91,21 +91,21 @@ class TimelinePagingAdapter( val TimelineDifferCallback = object : DiffUtil.ItemCallback() { override fun areItemsTheSame( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Boolean { return oldItem.id == newItem.id } override fun areContentsTheSame( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Boolean { return oldItem == newItem } override fun getChangePayload( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Any? { return if (oldItem == newItem) { // If items are equal - update timestamp only diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt index e9f952c68..3fc14f78f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt @@ -47,7 +47,7 @@ fun TimelineAccount.toEntity(accountId: Long, gson: Gson): TimelineAccountEntity url = url, avatar = avatar, emojis = gson.toJson(emojis), - bot = bot + bot = bot, ) } @@ -61,7 +61,7 @@ fun TimelineAccountEntity.toAccount(gson: Gson): TimelineAccount { url = url, avatar = avatar, bot = bot, - emojis = gson.fromJson(emojis, emojisListType) + emojis = gson.fromJson(emojis, emojisListType), ) } @@ -70,7 +70,7 @@ fun Status.toEntity( gson: Gson, expanded: Boolean, contentShowing: Boolean, - contentCollapsed: Boolean + contentCollapsed: Boolean, ): TimelineStatusEntity { return TimelineStatusEntity( serverId = this.id, @@ -106,7 +106,7 @@ fun Status.toEntity( card = actionableStatus.card?.let(gson::toJson), repliesCount = actionableStatus.repliesCount, language = actionableStatus.language, - filtered = actionableStatus.filtered + filtered = actionableStatus.filtered, ) } @@ -149,7 +149,7 @@ fun TimelineStatusWithAccount.toViewData(gson: Gson, isDetailed: Boolean = false card = card, repliesCount = status.repliesCount, language = status.language, - filtered = status.filtered + filtered = status.filtered, ) } val status = if (reblog != null) { @@ -182,7 +182,7 @@ fun TimelineStatusWithAccount.toViewData(gson: Gson, isDetailed: Boolean = false card = null, repliesCount = status.repliesCount, language = status.language, - filtered = status.filtered + filtered = status.filtered, ) } else { Status( @@ -214,7 +214,7 @@ fun TimelineStatusWithAccount.toViewData(gson: Gson, isDetailed: Boolean = false card = card, repliesCount = status.repliesCount, language = status.language, - filtered = status.filtered + filtered = status.filtered, ) } return StatusViewData( @@ -222,6 +222,6 @@ fun TimelineStatusWithAccount.toViewData(gson: Gson, isDetailed: Boolean = false isExpanded = this.status.expanded, isShowingContent = this.status.contentShowing, isCollapsed = this.status.contentCollapsed, - isDetailed = isDetailed + isDetailed = isDetailed, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/util/TimelineUtils.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/util/TimelineUtils.kt index c8d95fd81..7a261c99c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/util/TimelineUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/util/TimelineUtils.kt @@ -7,7 +7,7 @@ fun Throwable.isExpected() = this is IOException || this is HttpException inline fun ifExpected( t: Throwable, - cb: () -> T + cb: () -> T, ): T { if (t.isExpected()) { return cb() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt index 85d3b456b..1bc1df958 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt @@ -45,7 +45,7 @@ class CachedTimelineRemoteMediator( accountManager: AccountManager, private val factory: InvalidatingPagingSourceFactory, private val db: AppDatabase, - private val gson: Gson + private val gson: Gson, ) : RemoteMediator() { private val timelineDao = db.timelineDao() @@ -54,7 +54,7 @@ class CachedTimelineRemoteMediator( override suspend fun load( loadType: LoadType, - state: PagingState + state: PagingState, ): MediatorResult { if (!activeAccount.isLoggedIn()) { return MediatorResult.Success(endOfPaginationReached = true) @@ -74,7 +74,7 @@ class CachedTimelineRemoteMediator( remoteKeyDao.remoteKeyForKind( activeAccount.id, TIMELINE_ID, - RemoteKeyKind.NEXT + RemoteKeyKind.NEXT, ) } ?: return MediatorResult.Success(endOfPaginationReached = true) Log.d(TAG, "Loading from remoteKey: $rke") @@ -85,7 +85,7 @@ class CachedTimelineRemoteMediator( remoteKeyDao.remoteKeyForKind( activeAccount.id, TIMELINE_ID, - RemoteKeyKind.PREV + RemoteKeyKind.PREV, ) } ?: return MediatorResult.Success(endOfPaginationReached = true) Log.d(TAG, "Loading from remoteKey: $rke") @@ -118,16 +118,16 @@ class CachedTimelineRemoteMediator( activeAccount.id, TIMELINE_ID, RemoteKeyKind.NEXT, - links.next - ) + links.next, + ), ) remoteKeyDao.upsert( RemoteKeyEntity( activeAccount.id, TIMELINE_ID, RemoteKeyKind.PREV, - links.prev - ) + links.prev, + ), ) } // links.prev may be null if there are no statuses, only set if non-null, @@ -138,8 +138,8 @@ class CachedTimelineRemoteMediator( activeAccount.id, TIMELINE_ID, RemoteKeyKind.PREV, - prev - ) + prev, + ), ) } // links.next may be null if there are no statuses, only set if non-null, @@ -150,8 +150,8 @@ class CachedTimelineRemoteMediator( activeAccount.id, TIMELINE_ID, RemoteKeyKind.NEXT, - next - ) + next, + ), ) } } @@ -206,8 +206,8 @@ class CachedTimelineRemoteMediator( gson = gson, expanded = expanded, contentShowing = contentShowing, - contentCollapsed = contentCollapsed - ) + contentCollapsed = contentCollapsed, + ), ) } return overlappedStatuses diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineViewModel.kt index f5f0d4883..2b8a40acd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/CachedTimelineViewModel.kt @@ -61,7 +61,7 @@ class CachedTimelineViewModel @Inject constructor( preferences: SharedPreferences, accountPreferenceDataStore: AccountPreferenceDataStore, filterModel: FilterModel, - private val gson: Gson + private val gson: Gson, ) : TimelineViewModel( timelineCases, eventHub, @@ -69,7 +69,7 @@ class CachedTimelineViewModel @Inject constructor( accountManager, preferences, accountPreferenceDataStore, - filterModel + filterModel, ) { override lateinit var statuses: Flow> @@ -90,7 +90,7 @@ class CachedTimelineViewModel @Inject constructor( /** @return Flow of statuses that make up the timeline of [kind] */ private fun getStatuses( kind: TimelineKind, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getStatuses: kind: $kind, initialKey: $initialKey") return repository.getStatusStream(kind = kind, initialKey = initialKey) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelinePagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelinePagingSource.kt index 5d3b27ee1..0336fc9de 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelinePagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelinePagingSource.kt @@ -28,7 +28,7 @@ private val INVALID = LoadResult.Invalid() /** [PagingSource] for Mastodon Status, identified by the Status ID */ class NetworkTimelinePagingSource @Inject constructor( - private val pageCache: PageCache + private val pageCache: PageCache, ) : PagingSource() { override suspend fun load(params: LoadParams): LoadResult { @@ -139,7 +139,7 @@ class NetworkTimelinePagingSource @Inject constructor( nextKey = page?.nextKey, prevKey = page?.prevKey, itemsAfter = itemsAfter, - itemsBefore = itemsBefore + itemsBefore = itemsBefore, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt index 10f11746c..571f7bb1d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt @@ -41,7 +41,7 @@ class NetworkTimelineRemoteMediator( accountManager: AccountManager, private val factory: InvalidatingPagingSourceFactory, private val pageCache: PageCache, - private val timelineKind: TimelineKind + private val timelineKind: TimelineKind, ) : RemoteMediator() { private val activeAccount = accountManager.activeAccount!! @@ -115,7 +115,7 @@ class NetworkTimelineRemoteMediator( pageCache.upsert(page) Log.d( TAG, - " Page $loadType complete for $timelineKind, now got ${pageCache.size} pages" + " Page $loadType complete for $timelineKind, now got ${pageCache.size} pages", ) pageCache.debug() } @@ -162,7 +162,7 @@ class NetworkTimelineRemoteMediator( limit = loadSize, excludeReplies = null, onlyMedia = null, - pinned = true + pinned = true, ) is TimelineKind.User.Posts -> api.accountStatuses( timelineKind.id, @@ -171,7 +171,7 @@ class NetworkTimelineRemoteMediator( limit = loadSize, excludeReplies = true, onlyMedia = null, - pinned = null + pinned = null, ) is TimelineKind.User.Replies -> api.accountStatuses( timelineKind.id, @@ -180,13 +180,13 @@ class NetworkTimelineRemoteMediator( limit = loadSize, excludeReplies = null, onlyMedia = null, - pinned = null + pinned = null, ) is TimelineKind.UserList -> api.listTimeline( timelineKind.id, maxId = maxId, minId = minId, - limit = loadSize + limit = loadSize, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineViewModel.kt index c61ec58e7..613af2150 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/NetworkTimelineViewModel.kt @@ -58,7 +58,7 @@ class NetworkTimelineViewModel @Inject constructor( accountManager: AccountManager, sharedPreferences: SharedPreferences, accountPreferenceDataStore: AccountPreferenceDataStore, - filterModel: FilterModel + filterModel: FilterModel, ) : TimelineViewModel( timelineCases, eventHub, @@ -66,7 +66,7 @@ class NetworkTimelineViewModel @Inject constructor( accountManager, sharedPreferences, accountPreferenceDataStore, - filterModel + filterModel, ) { private val modifiedViewData = mutableMapOf() @@ -84,7 +84,7 @@ class NetworkTimelineViewModel @Inject constructor( /** @return Flow of statuses that make up the timeline of [kind] */ private fun getStatuses( kind: TimelineKind, - initialKey: String? = null + initialKey: String? = null, ): Flow> { Log.d(TAG, "getStatuses: kind: $kind, initialKey: $initialKey") return repository.getStatusStream(viewModelScope, kind = kind, initialKey = initialKey) @@ -93,7 +93,7 @@ class NetworkTimelineViewModel @Inject constructor( modifiedViewData[it.id] ?: it.toViewData( isShowingContent = statusDisplayOptions.value.showSensitiveMedia || !it.actionableStatus.sensitive, isExpanded = statusDisplayOptions.value.openSpoiler, - isCollapsed = true + isCollapsed = true, ) }.filter { shouldFilterStatus(it) != Filter.Action.HIDE @@ -103,21 +103,21 @@ class NetworkTimelineViewModel @Inject constructor( override fun updatePoll(newPoll: Poll, status: StatusViewData) { modifiedViewData[status.id] = status.copy( - status = status.status.copy(poll = newPoll) + status = status.status.copy(poll = newPoll), ) repository.invalidate() } override fun changeExpanded(expanded: Boolean, status: StatusViewData) { modifiedViewData[status.id] = status.copy( - isExpanded = expanded + isExpanded = expanded, ) repository.invalidate() } override fun changeContentShowing(isShowing: Boolean, status: StatusViewData) { modifiedViewData[status.id] = status.copy( - isShowingContent = isShowing + isShowingContent = isShowing, ) repository.invalidate() } @@ -126,7 +126,7 @@ class NetworkTimelineViewModel @Inject constructor( Log.d(TAG, "changeContentCollapsed: $isCollapsed") Log.d(TAG, " " + status.content) modifiedViewData[status.id] = status.copy( - isCollapsed = isCollapsed + isCollapsed = isCollapsed, ) repository.invalidate() } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/PageCache.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/PageCache.kt index a34ad5a6b..7ef7d2146 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/PageCache.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/PageCache.kt @@ -41,7 +41,7 @@ data class Page( * Key for next page (older results, APPEND operation) if more data can be loaded in that * direction, `null` otherwise. */ - val nextKey: String? = null + val nextKey: String? = null, ) { override fun toString() = "k: ${data.lastOrNull()?.id}, prev: $prevKey, next: $nextKey, size: ${"%2d".format(data.size)}, range: ${data.firstOrNull()?.id}..${data.lastOrNull()?.id}" @@ -87,7 +87,7 @@ data class Page( return Page( data = d, nextKey = next, - prevKey = prev + prevKey = prev, ) } @@ -108,8 +108,8 @@ data class Page( Page( data = statuses.toMutableList(), nextKey = links.next, - prevKey = links.prev - ) + prevKey = links.prev, + ), ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt index e2767203f..a32845545 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt @@ -83,19 +83,19 @@ data class UiState( val showFabWhileScrolling: Boolean = true, /** True if media previews should be shown */ - val showMediaPreview: Boolean = true + val showMediaPreview: Boolean = true, ) /** Preferences the UI reacts to */ data class UiPrefs( val showFabWhileScrolling: Boolean, - val showMediaPreview: Boolean + val showMediaPreview: Boolean, ) { companion object { /** Relevant preference keys. Changes to any of these trigger a display update */ val prefKeys = setOf( PrefKeys.FAB_HIDE, - PrefKeys.MEDIA_PREVIEW_ENABLED + PrefKeys.MEDIA_PREVIEW_ENABLED, ) } } @@ -173,7 +173,7 @@ sealed class StatusAction(open val statusViewData: StatusViewData) : FallibleUiA data class VoteInPoll( val poll: Poll, val choices: List, - override val statusViewData: StatusViewData + override val statusViewData: StatusViewData, ) : StatusAction(statusViewData) } @@ -218,30 +218,30 @@ sealed class UiError( @StringRes val message: Int, /** The action that failed. Can be resent to retry the action */ - open val action: UiAction? = null + open val action: UiAction? = null, ) { data class Bookmark( override val throwable: Throwable, - override val action: StatusAction.Bookmark + override val action: StatusAction.Bookmark, ) : UiError(throwable, R.string.ui_error_bookmark, action) data class Favourite( override val throwable: Throwable, - override val action: StatusAction.Favourite + override val action: StatusAction.Favourite, ) : UiError(throwable, R.string.ui_error_favourite, action) data class Reblog( override val throwable: Throwable, - override val action: StatusAction.Reblog + override val action: StatusAction.Reblog, ) : UiError(throwable, R.string.ui_error_reblog, action) data class VoteInPoll( override val throwable: Throwable, - override val action: StatusAction.VoteInPoll + override val action: StatusAction.VoteInPoll, ) : UiError(throwable, R.string.ui_error_vote, action) data class GetFilters( - override val throwable: Throwable + override val throwable: Throwable, ) : UiError(throwable, R.string.ui_error_filter_v1_load, null) companion object { @@ -262,7 +262,7 @@ abstract class TimelineViewModel( protected val accountManager: AccountManager, private val sharedPreferences: SharedPreferences, private val accountPreferenceDataStore: AccountPreferenceDataStore, - private val filterModel: FilterModel + private val filterModel: FilterModel, ) : ViewModel() { val uiState: StateFlow @@ -327,8 +327,8 @@ abstract class TimelineViewModel( statusDisplayOptions = MutableStateFlow( StatusDisplayOptions.from( sharedPreferences, - activeAccount - ) + activeAccount, + ), ) viewModelScope.launch { @@ -339,7 +339,7 @@ abstract class TimelineViewModel( statusDisplayOptions.value.make( sharedPreferences, it.preferenceKey, - activeAccount + activeAccount, ) } .collect { @@ -357,23 +357,23 @@ abstract class TimelineViewModel( is StatusAction.Bookmark -> timelineCases.bookmark( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.Favourite -> timelineCases.favourite( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.Reblog -> timelineCases.reblog( action.statusViewData.actionableId, - action.state + action.state, ) is StatusAction.VoteInPoll -> timelineCases.voteInPoll( action.statusViewData.actionableId, action.poll.id, - action.choices + action.choices, ) }.getOrThrow() uiSuccess.emit(StatusActionSuccess.from(action)) @@ -399,12 +399,12 @@ abstract class TimelineViewModel( uiState = getUiPrefs().map { prefs -> UiState( showFabWhileScrolling = prefs.showFabWhileScrolling, - showMediaPreview = prefs.showMediaPreview + showMediaPreview = prefs.showMediaPreview, ) }.stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5000), - initialValue = UiState() + initialValue = UiState(), ) } @@ -421,7 +421,7 @@ abstract class TimelineViewModel( private fun toPrefs() = UiPrefs( showFabWhileScrolling = !sharedPreferences.getBoolean(PrefKeys.FAB_HIDE, false), - showMediaPreview = accountPreferenceDataStore.getBoolean(PrefKeys.MEDIA_PREVIEW_ENABLED, true) + showMediaPreview = accountPreferenceDataStore.getBoolean(PrefKeys.MEDIA_PREVIEW_ENABLED, true), ) @CallSuper @@ -566,7 +566,7 @@ abstract class TimelineViewModel( filterModel.initWithFilters( filters.filters.filter { filterContextMatchesKind(timelineKind, it.context) - } + }, ) invalidate() } @@ -650,7 +650,7 @@ abstract class TimelineViewModel( fun filterContextMatchesKind( timelineKind: TimelineKind, - filterContext: List + filterContext: List, ): Boolean { return filterContext.contains(Filter.Kind.from(timelineKind).kind) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingActivity.kt index 5819984f1..a07ab64df 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingActivity.kt @@ -75,7 +75,7 @@ class TrendingActivity : BottomSheetActivity(), HasAndroidInjector, MenuProvider override fun handleOnBackPressed() { if (binding.pager.currentItem != 0) binding.pager.currentItem = 0 else finish() } - } + }, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingDateViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingDateViewHolder.kt index 5d9e3c3af..6228a6fe6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingDateViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingDateViewHolder.kt @@ -24,7 +24,7 @@ import java.util.Locale import java.util.TimeZone class TrendingDateViewHolder( - private val binding: ItemTrendingDateBinding + private val binding: ItemTrendingDateBinding, ) : RecyclerView.ViewHolder(binding.root) { private val dateFormat = SimpleDateFormat("EEE dd MMM yyyy", Locale.getDefault()).apply { @@ -35,7 +35,7 @@ class TrendingDateViewHolder( binding.dates.text = itemView.context.getString( R.string.date_range, dateFormat.format(start), - dateFormat.format(end) + dateFormat.format(end), ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinkViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinkViewHolder.kt index dbe5bb244..0da111b52 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinkViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinkViewHolder.kt @@ -34,7 +34,7 @@ import com.keylesspalace.tusky.util.hide class TrendingLinkViewHolder( private val binding: ItemTrendingLinkBinding, - private val onClick: (String) -> Unit + private val onClick: (String) -> Unit, ) : RecyclerView.ViewHolder(binding.root) { private var link: TrendsLink? = null diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksAdapter.kt index 608bd1da2..1a7c934d1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksAdapter.kt @@ -28,7 +28,7 @@ import com.keylesspalace.tusky.util.StatusDisplayOptions class TrendingLinksAdapter( statusDisplayOptions: StatusDisplayOptions, - private val onViewLink: (String) -> Unit + private val onViewLink: (String) -> Unit, ) : ListAdapter(diffCallback) { var statusDisplayOptions = statusDisplayOptions set(value) { @@ -43,7 +43,7 @@ class TrendingLinksAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TrendingLinkViewHolder { return TrendingLinkViewHolder( ItemTrendingLinkBinding.inflate(LayoutInflater.from(parent.context)), - onViewLink + onViewLink, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksFragment.kt index fc87714e4..8c4fc6e75 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksFragment.kt @@ -81,7 +81,7 @@ class TrendingLinksFragment : override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) binding.recyclerView.layoutManager = getLayoutManager( - requireContext().resources.getInteger(R.integer.trending_column_count) + requireContext().resources.getInteger(R.integer.trending_column_count), ) } @@ -116,7 +116,7 @@ class TrendingLinksFragment : binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) binding.messageView.show() } else { @@ -133,7 +133,7 @@ class TrendingLinksFragment : val snackbar = Snackbar.make( binding.root, it.throwable.message ?: "Error", - Snackbar.LENGTH_INDEFINITE + Snackbar.LENGTH_INDEFINITE, ) if (it.throwable !is HttpException || it.throwable.code() != 404) { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksRepository.kt index 522e10438..e1153cb1a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingLinksRepository.kt @@ -21,7 +21,7 @@ import com.keylesspalace.tusky.network.MastodonApi import javax.inject.Inject class TrendingLinksRepository @Inject constructor( - private val api: MastodonApi + private val api: MastodonApi, ) { suspend fun getTrendingLinks() = api.trendingLinks() } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt index 58aad9e84..22fe69f50 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt @@ -22,12 +22,12 @@ import com.keylesspalace.tusky.util.formatNumber import com.keylesspalace.tusky.viewdata.TrendingViewData class TrendingTagViewHolder( - private val binding: ItemTrendingCellBinding + private val binding: ItemTrendingCellBinding, ) : RecyclerView.ViewHolder(binding.root) { fun setup( tagViewData: TrendingViewData.Tag, - onViewTag: (String) -> Unit + onViewTag: (String) -> Unit, ) { binding.tag.text = binding.root.context.getString(R.string.title_tag, tagViewData.name) @@ -51,7 +51,7 @@ class TrendingTagViewHolder( itemView.context.getString( R.string.accessibility_talking_about_tag, totalAccounts, - tagViewData.name + tagViewData.name, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsAdapter.kt index 4137d200e..6cac913b3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsAdapter.kt @@ -25,7 +25,7 @@ import com.keylesspalace.tusky.databinding.ItemTrendingDateBinding import com.keylesspalace.tusky.viewdata.TrendingViewData class TrendingTagsAdapter( - private val onViewTag: (String) -> Unit + private val onViewTag: (String) -> Unit, ) : ListAdapter(TrendingDifferCallback) { init { @@ -76,14 +76,14 @@ class TrendingTagsAdapter( val TrendingDifferCallback = object : DiffUtil.ItemCallback() { override fun areItemsTheSame( oldItem: TrendingViewData, - newItem: TrendingViewData + newItem: TrendingViewData, ): Boolean { return oldItem.id == newItem.id } override fun areContentsTheSame( oldItem: TrendingViewData, - newItem: TrendingViewData + newItem: TrendingViewData, ): Boolean { return oldItem == newItem } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsFragment.kt index bfa5b99e1..5c0f7ee09 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagsFragment.kt @@ -91,21 +91,23 @@ class TrendingTagsFragment : setupSwipeRefreshLayout() setupRecyclerView() - adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { - @SuppressLint("SyntheticAccessor") - override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { - if (positionStart == 0 && adapter.itemCount != itemCount) { - binding.recyclerView.post { - if (getView() != null) { - binding.recyclerView.scrollBy( - 0, - Utils.dpToPx(requireContext(), -30) - ) + adapter.registerAdapterDataObserver( + object : RecyclerView.AdapterDataObserver() { + @SuppressLint("SyntheticAccessor") + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + if (positionStart == 0 && adapter.itemCount != itemCount) { + binding.recyclerView.post { + if (getView() != null) { + binding.recyclerView.scrollBy( + 0, + Utils.dpToPx(requireContext(), -30), + ) + } } } } - } - }) + }, + ) viewLifecycleOwner.lifecycleScope.launch { viewModel.uiState.collectLatest { trendingState -> @@ -177,8 +179,8 @@ class TrendingTagsFragment : (requireActivity() as BaseActivity).startActivityWithSlideInAnimation( StatusListActivity.newHashtagIntent( requireContext(), - tag - ) + tag, + ), ) } @@ -205,7 +207,7 @@ class TrendingTagsFragment : binding.messageView.setup( R.drawable.elephant_friend_empty, R.string.message_empty, - null + null, ) } else { binding.recyclerView.show() @@ -238,7 +240,7 @@ class TrendingTagsFragment : binding.swipeRefreshLayout.isRefreshing = false binding.messageView.setup( R.drawable.errorphant_offline, - R.string.error_network + R.string.error_network, ) { refreshContent() } } @@ -250,7 +252,7 @@ class TrendingTagsFragment : binding.swipeRefreshLayout.isRefreshing = false binding.messageView.setup( R.drawable.errorphant_error, - R.string.error_generic + R.string.error_generic, ) { refreshContent() } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingLinksViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingLinksViewModel.kt index e0a6a5d71..def4f949f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingLinksViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingLinksViewModel.kt @@ -61,7 +61,7 @@ class TrendingLinksViewModel @Inject constructor( private val repository: TrendingLinksRepository, preferences: SharedPreferences, accountManager: AccountManager, - private val eventHub: EventHub + private val eventHub: EventHub, ) : ViewModel() { val account = accountManager.activeAccount!! @@ -69,7 +69,7 @@ class TrendingLinksViewModel @Inject constructor( val loadState = _loadState.asStateFlow() private val _statusDisplayOptions = MutableStateFlow( - StatusDisplayOptions.from(preferences, account) + StatusDisplayOptions.from(preferences, account), ) val statusDisplayOptions = _statusDisplayOptions.asStateFlow() @@ -100,7 +100,7 @@ class TrendingLinksViewModel @Inject constructor( val response = repository.getTrendingLinks() response.fold( { list -> _loadState.update { LoadState.Success(list) } }, - { throwable -> _loadState.update { LoadState.Error(throwable) } } + { throwable -> _loadState.update { LoadState.Error(throwable) } }, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt index 92f0a8c46..2449ebe20 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt @@ -37,7 +37,7 @@ import javax.inject.Inject class TrendingTagsViewModel @Inject constructor( private val mastodonApi: MastodonApi, - private val eventHub: EventHub + private val eventHub: EventHub, ) : ViewModel() { enum class LoadingState { INITIAL, LOADING, REFRESHING, LOADED, ERROR_NETWORK, ERROR_OTHER @@ -45,7 +45,7 @@ class TrendingTagsViewModel @Inject constructor( data class TrendingTagsUiState( val trendingViewData: List, - val loadingState: LoadingState + val loadingState: LoadingState, ) val uiState: Flow get() = _uiState @@ -110,7 +110,7 @@ class TrendingTagsViewModel @Inject constructor( } else { _uiState.value = TrendingTagsUiState(emptyList(), LoadingState.ERROR_OTHER) } - } + }, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ThreadAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ThreadAdapter.kt index 7a13d47a3..5718e5939 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ThreadAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ThreadAdapter.kt @@ -30,7 +30,7 @@ import com.keylesspalace.tusky.viewdata.StatusViewData class ThreadAdapter( private val statusDisplayOptions: StatusDisplayOptions, - private val statusActionListener: StatusActionListener + private val statusActionListener: StatusActionListener, ) : ListAdapter(ThreadDifferCallback) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatusBaseViewHolder { @@ -74,21 +74,21 @@ class ThreadAdapter( val ThreadDifferCallback = object : DiffUtil.ItemCallback() { override fun areItemsTheSame( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Boolean { return oldItem.id == newItem.id } override fun areContentsTheSame( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Boolean { return false // Items are different always. It allows to refresh timestamp on every view holder update } override fun getChangePayload( oldItem: StatusViewData, - newItem: StatusViewData + newItem: StatusViewData, ): Any? { return if (oldItem == newItem) { // If items are equal - update timestamp only diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadFragment.kt index e83e72ebb..a2fefc4c6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadFragment.kt @@ -114,7 +114,7 @@ class ViewThreadFragment : animateEmojis = preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false), showStatsInline = preferences.getBoolean(PrefKeys.SHOW_STATS_INLINE, false), showSensitiveMedia = accountManager.activeAccount!!.alwaysShowSensitiveMedia, - openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler + openSpoiler = accountManager.activeAccount!!.alwaysOpenSpoiler, ) adapter = ThreadAdapter(statusDisplayOptions, this) } @@ -122,7 +122,7 @@ class ViewThreadFragment : override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { return inflater.inflate(R.layout.fragment_view_thread, container, false) } @@ -138,8 +138,8 @@ class ViewThreadFragment : binding.recyclerView.setAccessibilityDelegateCompat( ListStatusAccessibilityDelegate( binding.recyclerView, - this - ) { index -> adapter.currentList.getOrNull(index) } + this, + ) { index -> adapter.currentList.getOrNull(index) }, ) val divider = DividerItemDecoration(context, LinearLayout.VERTICAL) binding.recyclerView.addItemDecoration(divider) @@ -218,7 +218,7 @@ class ViewThreadFragment : // Ensure the top of the status is visible (binding.recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( uiState.detailedStatusPosition, - 0 + 0, ) } } @@ -258,7 +258,7 @@ class ViewThreadFragment : when (revealButtonState) { RevealButtonState.REVEAL -> R.drawable.ic_eye_24dp else -> R.drawable.ic_hide_media_24dp - } + }, ) } @@ -296,7 +296,7 @@ class ViewThreadFragment : */ @CheckResult private fun getProgressBarJob(view: View, delayMs: Long) = viewLifecycleOwner.lifecycleScope.launch( - start = CoroutineStart.LAZY + start = CoroutineStart.LAZY, ) { try { delay(delayMs) @@ -339,7 +339,7 @@ class ViewThreadFragment : super.viewMedia( attachmentIndex, list(status, alwaysShowSensitiveMedia), - view + view, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt index f66d3b038..dec5a5c2f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt @@ -61,7 +61,7 @@ class ViewThreadViewModel @Inject constructor( eventHub: EventHub, accountManager: AccountManager, private val db: AppDatabase, - private val gson: Gson + private val gson: Gson, ) : ViewModel() { private val _uiState: MutableStateFlow = MutableStateFlow(ThreadUiState.Loading) @@ -113,7 +113,7 @@ class ViewThreadViewModel @Inject constructor( Log.d(TAG, "Loaded status from local timeline") val viewData = timelineStatus.toViewData( gson, - isDetailed = true + isDetailed = true, ) // Return the correct status, depending on which one matched. If you do not do @@ -136,7 +136,7 @@ class ViewThreadViewModel @Inject constructor( _uiState.value = ThreadUiState.LoadingThread( statusViewDatum = detailedStatus, - revealButton = detailedStatus.getRevealButtonState() + revealButton = detailedStatus.getRevealButtonState(), ) // If the detailedStatus was loaded from the database it might be out-of-date @@ -158,16 +158,16 @@ class ViewThreadViewModel @Inject constructor( _uiState.value = ThreadUiState.Success( statusViewData = statuses, detailedStatusPosition = ancestors.size, - revealButton = statuses.getRevealButtonState() + revealButton = statuses.getRevealButtonState(), ) }, { throwable -> _errors.emit(throwable) _uiState.value = ThreadUiState.Success( statusViewData = listOf(detailedStatus), detailedStatusPosition = 0, - revealButton = RevealButtonState.NO_BUTTON + revealButton = RevealButtonState.NO_BUTTON, ) - }) + },) } } @@ -244,7 +244,7 @@ class ViewThreadViewModel @Inject constructor( fun removeStatus(statusToRemove: StatusViewData) { updateSuccess { uiState -> uiState.copy( - statusViewData = uiState.statusViewData.filterNot { status -> status == statusToRemove } + statusViewData = uiState.statusViewData.filterNot { status -> status == statusToRemove }, ) } } @@ -260,7 +260,7 @@ class ViewThreadViewModel @Inject constructor( } uiState.copy( statusViewData = statuses, - revealButton = statuses.getRevealButtonState() + revealButton = statuses.getRevealButtonState(), ) } } @@ -306,7 +306,7 @@ class ViewThreadViewModel @Inject constructor( uiState.copy( statusViewData = uiState.statusViewData.filter { viewData -> viewData.status.account.id != accountId - } + }, ) } } @@ -338,7 +338,7 @@ class ViewThreadViewModel @Inject constructor( } else { status } - } + }, ) } } @@ -348,7 +348,7 @@ class ViewThreadViewModel @Inject constructor( uiState.copy( statusViewData = uiState.statusViewData.filter { status -> status.id != event.statusId - } + }, ) } } @@ -360,13 +360,13 @@ class ViewThreadViewModel @Inject constructor( statusViewData = uiState.statusViewData.map { viewData -> viewData.copy(isExpanded = false) }, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ) RevealButtonState.REVEAL -> uiState.copy( statusViewData = uiState.statusViewData.map { viewData -> viewData.copy(isExpanded = true) }, - revealButton = RevealButtonState.HIDE + revealButton = RevealButtonState.HIDE, ) else -> uiState } @@ -427,13 +427,13 @@ class ViewThreadViewModel @Inject constructor( } filterModel.initWithFilters( - filters.filter { filter -> filter.context.contains(FilterV1.THREAD) } + filters.filter { filter -> filter.context.contains(FilterV1.THREAD) }, ) updateStatuses() } else { Log.e(TAG, "Error getting filters", throwable) } - } + }, ) } } @@ -443,7 +443,7 @@ class ViewThreadViewModel @Inject constructor( val statuses = uiState.statusViewData.filter() uiState.copy( statusViewData = statuses, - revealButton = statuses.getRevealButtonState() + revealButton = statuses.getRevealButtonState(), ) } } @@ -460,14 +460,14 @@ class ViewThreadViewModel @Inject constructor( } private fun Status.toViewData( - isDetailed: Boolean = false + isDetailed: Boolean = false, ): StatusViewData { val oldStatus = (_uiState.value as? ThreadUiState.Success)?.statusViewData?.find { it.id == this.id } return toViewData( isShowingContent = oldStatus?.isShowingContent ?: (alwaysShowSensitiveMedia || !actionableStatus.sensitive), isExpanded = oldStatus?.isExpanded ?: alwaysOpenSpoiler, isCollapsed = oldStatus?.isCollapsed ?: !isDetailed, - isDetailed = oldStatus?.isDetailed ?: isDetailed + isDetailed = oldStatus?.isDetailed ?: isDetailed, ) } @@ -490,7 +490,7 @@ class ViewThreadViewModel @Inject constructor( } else { viewData } - } + }, ) } } @@ -498,7 +498,7 @@ class ViewThreadViewModel @Inject constructor( private fun updateStatus(statusId: String, updater: (Status) -> Status) { updateStatusViewData(statusId) { viewData -> viewData.copy( - status = updater(viewData.status) + status = updater(viewData.status), ) } } @@ -521,7 +521,7 @@ sealed interface ThreadUiState { /** Loading the detailed status has completed, now loading ancestors/descendants */ data class LoadingThread( val statusViewDatum: StatusViewData?, - val revealButton: RevealButtonState + val revealButton: RevealButtonState, ) : ThreadUiState /** An error occurred at any point */ @@ -531,7 +531,7 @@ sealed interface ThreadUiState { data class Success( val statusViewData: List, val revealButton: RevealButtonState, - val detailedStatusPosition: Int + val detailedStatusPosition: Int, ) : ThreadUiState /** Refreshing the thread with a swipe */ diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsAdapter.kt index 56bf1ffc4..d39110e58 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsAdapter.kt @@ -45,7 +45,7 @@ class ViewEditsAdapter( private val animateAvatars: Boolean, private val animateEmojis: Boolean, private val useBlurhash: Boolean, - private val listener: LinkListener + private val listener: LinkListener, ) : RecyclerView.Adapter>() { private val absoluteTimeFormatter = AbsoluteTimeFormatter() @@ -58,7 +58,7 @@ class ViewEditsAdapter( override fun onCreateViewHolder( parent: ViewGroup, - viewType: Int + viewType: Int, ): BindingHolder { val binding = ItemStatusEditBinding.inflate(LayoutInflater.from(parent.context), parent, false) @@ -112,7 +112,7 @@ class ViewEditsAdapter( binding.statusEditContentWarningDescription.text = edit.spoilerText.emojify( edit.emojis, binding.statusEditContentWarningDescription, - animateEmojis + animateEmojis, ) } @@ -149,7 +149,7 @@ class ViewEditsAdapter( }, resultClickListener = null, animateEmojis = animateEmojis, - enabled = false + enabled = false, ) } @@ -240,7 +240,7 @@ class TuskyTagHandler(val context: Context) : Html.TagHandler { end( output as SpannableStringBuilder, Del::class.java, - DeletedTextSpan(context) + DeletedTextSpan(context), ) } } @@ -251,7 +251,7 @@ class TuskyTagHandler(val context: Context) : Html.TagHandler { end( output as SpannableStringBuilder, Ins::class.java, - InsertedTextSpan(context) + InsertedTextSpan(context), ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsFragment.kt index 95a0b96d1..8ff6019b7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsFragment.kt @@ -114,7 +114,7 @@ class ViewEditsFragment : is ViewEditsViewModel.MissingEditsException -> { binding.statusView.setup( R.drawable.elephant_friend_empty, - R.string.error_missing_edits + R.string.error_missing_edits, ) } else -> { @@ -135,7 +135,7 @@ class ViewEditsFragment : animateAvatars = animateAvatars, animateEmojis = animateEmojis, useBlurhash = useBlurhash, - listener = this@ViewEditsFragment + listener = this@ViewEditsFragment, ) // Focus on the most recent version diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt index 059312b49..fee6e568f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt @@ -91,7 +91,7 @@ class ViewEditsViewModel @Inject constructor(private val api: MastodonApi) : Vie loader.config = DiffConfig( false, WhiteSpaceProcessing.PRESERVE, - TextGranularity.SPACE_WORD + TextGranularity.SPACE_WORD, ) val processor = OptimisticXMLProcessor() processor.setCoalesce(true) @@ -107,13 +107,13 @@ class ViewEditsViewModel @Inject constructor(private val api: MastodonApi) : Vie for (i in 1 until sortedEdits.size) { processor.diff(previousContent, currentContent, output) sortedEdits[i - 1] = sortedEdits[i - 1].copy( - content = output.xml.toString() + content = output.xml.toString(), ) if (i < sortedEdits.size - 1) { currentContent = previousContent previousContent = loader.load( - sortedEdits[i + 1].content.replace("
", "
") + sortedEdits[i + 1].content.replace("
", "
"), ) } } @@ -142,7 +142,7 @@ sealed interface EditsUiState { data object Refreshing : EditsUiState class Error(val throwable: Throwable) : EditsUiState data class Success( - val edits: List + val edits: List, ) : EditsUiState } diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt index 84c8874f5..8a2ac118f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt @@ -29,9 +29,9 @@ import com.keylesspalace.tusky.entity.Status indices = [ Index( value = ["domain", "accountId"], - unique = true - ) - ] + unique = true, + ), + ], ) @TypeConverters(Converters::class) data class AccountEntity( @@ -104,7 +104,7 @@ data class AccountEntity( /** true if the connected Mastodon account is locked (has to manually approve all follow requests **/ @ColumnInfo(defaultValue = "0") - var locked: Boolean = false + var locked: Boolean = false, ) { val identifier: String diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt index 6767de993..8ba724f02 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountManager.kt @@ -66,7 +66,7 @@ class AccountManager @Inject constructor(val db: AppDatabase) { clientId: String, clientSecret: String, oauthScopes: String, - newAccount: Account + newAccount: Account, ) { activeAccount?.let { it.isActive = false @@ -84,7 +84,7 @@ class AccountManager @Inject constructor(val db: AppDatabase) { clientId = clientId, clientSecret = clientSecret, oauthScopes = oauthScopes, - isActive = true + isActive = true, ).also { accounts[existingAccountIndex] = it } } else { val maxAccountId = accounts.maxByOrNull { it.id }?.id ?: 0 @@ -97,7 +97,7 @@ class AccountManager @Inject constructor(val db: AppDatabase) { clientSecret = clientSecret, oauthScopes = oauthScopes, isActive = true, - accountId = newAccount.id + accountId = newAccount.id, ).also { accounts.add(it) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt b/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt index 491cd53d8..c71be37d9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt @@ -38,7 +38,7 @@ import javax.inject.Singleton @ProvidedTypeConverter @Singleton class Converters @Inject constructor( - private val gson: Gson + private val gson: Gson, ) { @TypeConverter diff --git a/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt index 2a479ab34..7b6d2c6ea 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/DraftEntity.kt @@ -43,7 +43,7 @@ data class DraftEntity( val failedToSendNew: Boolean, val scheduledAt: String?, val language: String?, - val statusId: String? + val statusId: String?, ) /** @@ -56,7 +56,7 @@ data class DraftAttachment( @SerializedName(value = "uriString", alternate = ["e", "i"]) val uriString: String, @SerializedName(value = "description", alternate = ["f", "j"]) val description: String?, @SerializedName(value = "focus") val focus: Attachment.Focus?, - @SerializedName(value = "type", alternate = ["g", "k"]) val type: Type + @SerializedName(value = "type", alternate = ["g", "k"]) val type: Type, ) : Parcelable { val uri: Uri get() = uriString.toUri() diff --git a/app/src/main/java/com/keylesspalace/tusky/db/DraftsAlert.kt b/app/src/main/java/com/keylesspalace/tusky/db/DraftsAlert.kt index 9d11f47d3..8d615e22f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/DraftsAlert.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/DraftsAlert.kt @@ -63,7 +63,7 @@ class DraftsAlert @Inject constructor(db: AppDatabase) { AlertDialog.Builder(context) .setTitle(R.string.action_post_failed) .setMessage( - context.resources.getQuantityString(R.plurals.action_post_failed_detail, count) + context.resources.getQuantityString(R.plurals.action_post_failed_detail, count), ) .setPositiveButton(R.string.action_post_failed_show_drafts) { _: DialogInterface?, _: Int -> clearDraftsAlert(coroutineScope, activeAccountId) // User looked at drafts diff --git a/app/src/main/java/com/keylesspalace/tusky/db/InstanceEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/InstanceEntity.kt index efcfe5278..6f55d1b1c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/InstanceEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/InstanceEntity.kt @@ -38,13 +38,13 @@ data class InstanceEntity( val maxMediaAttachments: Int?, val maxFields: Int?, val maxFieldNameLength: Int?, - val maxFieldValueLength: Int? + val maxFieldValueLength: Int?, ) @TypeConverters(Converters::class) data class EmojisEntity( @PrimaryKey val instance: String, - val emojiList: List? + val emojiList: List?, ) data class InstanceInfoEntity( @@ -62,5 +62,5 @@ data class InstanceInfoEntity( val maxMediaAttachments: Int?, val maxFields: Int?, val maxFieldNameLength: Int?, - val maxFieldValueLength: Int? + val maxFieldValueLength: Int?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/db/RemoteKeyEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/RemoteKeyEntity.kt index 1561c6aa7..2d879faa9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/RemoteKeyEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/RemoteKeyEntity.kt @@ -24,14 +24,14 @@ enum class RemoteKeyKind { NEXT, /** Key to load the previous (chronologically newer) page of data for this timeline */ - PREV + PREV, } /** * The next and previous keys for the given timeline. */ @Entity( - primaryKeys = ["accountId", "timelineId", "kind"] + primaryKeys = ["accountId", "timelineId", "kind"], ) data class RemoteKeyEntity( /** User account these keys relate to. */ @@ -50,5 +50,5 @@ data class RemoteKeyEntity( */ val timelineId: String, val kind: RemoteKeyKind, - val key: String? = null + val key: String? = null, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt b/app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt index 80d8ffd30..4ba39a810 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/TimelineDao.kt @@ -49,7 +49,7 @@ FROM TimelineStatusEntity s LEFT JOIN TimelineAccountEntity a ON (s.timelineUserId = a.timelineUserId AND s.authorServerId = a.serverId) LEFT JOIN TimelineAccountEntity rb ON (s.timelineUserId = rb.timelineUserId AND s.reblogAccountId = rb.serverId) WHERE s.timelineUserId = :account -ORDER BY LENGTH(s.serverId) DESC, s.serverId DESC""" +ORDER BY LENGTH(s.serverId) DESC, s.serverId DESC""", ) abstract fun getStatuses(account: Long): PagingSource @@ -64,7 +64,7 @@ ORDER BY LENGTH(s.serverId) DESC, s.serverId DESC""" SELECT serverId FROM TimelineStatusEntity WHERE timelineUserId = :account - ORDER BY LENGTH(serverId) DESC, serverId DESC""" + ORDER BY LENGTH(serverId) DESC, serverId DESC""", ) abstract fun getStatusRowNumber(account: Long): List @@ -87,7 +87,7 @@ FROM TimelineStatusEntity s LEFT JOIN TimelineAccountEntity a ON (s.timelineUserId = a.timelineUserId AND s.authorServerId = a.serverId) LEFT JOIN TimelineAccountEntity rb ON (s.timelineUserId = rb.timelineUserId AND s.reblogAccountId = rb.serverId) WHERE (s.serverId = :statusId OR s.reblogServerId = :statusId) -AND s.authorServerId IS NOT NULL""" +AND s.authorServerId IS NOT NULL""", ) abstract suspend fun getStatus(statusId: String): TimelineStatusWithAccount? @@ -96,31 +96,31 @@ AND s.authorServerId IS NOT NULL""" (LENGTH(serverId) < LENGTH(:maxId) OR LENGTH(serverId) == LENGTH(:maxId) AND serverId <= :maxId) AND (LENGTH(serverId) > LENGTH(:minId) OR LENGTH(serverId) == LENGTH(:minId) AND serverId >= :minId) - """ + """, ) abstract suspend fun deleteRange(accountId: Long, minId: String, maxId: String): Int @Query( """UPDATE TimelineStatusEntity SET favourited = :favourited -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setFavourited(accountId: Long, statusId: String, favourited: Boolean) @Query( """UPDATE TimelineStatusEntity SET bookmarked = :bookmarked -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setBookmarked(accountId: Long, statusId: String, bookmarked: Boolean) @Query( """UPDATE TimelineStatusEntity SET reblogged = :reblogged -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setReblogged(accountId: Long, statusId: String, reblogged: Boolean) @Query( """DELETE FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND -(authorServerId = :userId OR reblogAccountId = :userId)""" +(authorServerId = :userId OR reblogAccountId = :userId)""", ) abstract suspend fun removeAllByUser(accountId: Long, userId: String) @@ -141,7 +141,7 @@ WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = @Query( """DELETE FROM TimelineStatusEntity WHERE timelineUserId = :accountId -AND serverId = :statusId""" +AND serverId = :statusId""", ) abstract suspend fun delete(accountId: Long, statusId: String) @@ -163,7 +163,7 @@ AND serverId = :statusId""" @Query( """DELETE FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND serverId NOT IN (SELECT serverId FROM TimelineStatusEntity WHERE timelineUserId = :accountId ORDER BY LENGTH(serverId) DESC, serverId DESC LIMIT :limit) - """ + """, ) abstract suspend fun cleanupStatuses(accountId: Long, limit: Int) @@ -175,37 +175,37 @@ AND serverId = :statusId""" """DELETE FROM TimelineAccountEntity WHERE timelineUserId = :accountId AND serverId NOT IN (SELECT authorServerId FROM TimelineStatusEntity WHERE timelineUserId = :accountId) AND serverId NOT IN - (SELECT reblogAccountId FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND reblogAccountId IS NOT NULL)""" + (SELECT reblogAccountId FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND reblogAccountId IS NOT NULL)""", ) abstract suspend fun cleanupAccounts(accountId: Long) @Query( """UPDATE TimelineStatusEntity SET poll = :poll -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setVoted(accountId: Long, statusId: String, poll: String) @Query( """UPDATE TimelineStatusEntity SET expanded = :expanded -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setExpanded(accountId: Long, statusId: String, expanded: Boolean) @Query( """UPDATE TimelineStatusEntity SET contentShowing = :contentShowing -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setContentShowing(accountId: Long, statusId: String, contentShowing: Boolean) @Query( """UPDATE TimelineStatusEntity SET contentCollapsed = :contentCollapsed -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setContentCollapsed(accountId: Long, statusId: String, contentCollapsed: Boolean) @Query( """UPDATE TimelineStatusEntity SET pinned = :pinned -WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""" +WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""", ) abstract suspend fun setPinned(accountId: Long, statusId: String, pinned: Boolean) @@ -214,7 +214,7 @@ WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = WHERE timelineUserId = :accountId AND authorServerId IN ( SELECT serverId FROM TimelineAccountEntity WHERE username LIKE '%@' || :instanceDomain AND timelineUserId = :accountId -)""" +)""", ) abstract suspend fun deleteAllFromInstance(accountId: Long, instanceDomain: String) diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt b/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt index cf8a3c26a..da903a68f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt @@ -41,12 +41,12 @@ import com.keylesspalace.tusky.entity.Status ForeignKey( entity = TimelineAccountEntity::class, parentColumns = ["serverId", "timelineUserId"], - childColumns = ["authorServerId", "timelineUserId"] - ) + childColumns = ["authorServerId", "timelineUserId"], + ), ] ), // Avoiding rescanning status table when accounts table changes. Recommended by Room(c). - indices = [Index("authorServerId", "timelineUserId")] + indices = [Index("authorServerId", "timelineUserId")], ) @TypeConverters(Converters::class) data class TimelineStatusEntity( @@ -84,11 +84,11 @@ data class TimelineStatusEntity( val pinned: Boolean, val card: String?, val language: String?, - val filtered: List? + val filtered: List?, ) @Entity( - primaryKeys = ["serverId", "timelineUserId"] + primaryKeys = ["serverId", "timelineUserId"], ) data class TimelineAccountEntity( val serverId: String, @@ -99,7 +99,7 @@ data class TimelineAccountEntity( val url: String, val avatar: String, val emojis: String, - val bot: Boolean + val bot: Boolean, ) data class TimelineStatusWithAccount( @@ -108,5 +108,5 @@ data class TimelineStatusWithAccount( @Embedded(prefix = "a_") val account: TimelineAccountEntity, @Embedded(prefix = "rb_") - val reblogAccount: TimelineAccountEntity? = null // null when no reblog + val reblogAccount: TimelineAccountEntity? = null, // null when no reblog ) diff --git a/app/src/main/java/com/keylesspalace/tusky/di/AppComponent.kt b/app/src/main/java/com/keylesspalace/tusky/di/AppComponent.kt index d922ab370..e186c947e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/AppComponent.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/AppComponent.kt @@ -36,8 +36,8 @@ import javax.inject.Singleton ServicesModule::class, BroadcastReceiverModule::class, ViewModelModule::class, - WorkerModule::class - ] + WorkerModule::class, + ], ) interface AppComponent { @Component.Builder diff --git a/app/src/main/java/com/keylesspalace/tusky/di/AppInjector.kt b/app/src/main/java/com/keylesspalace/tusky/di/AppInjector.kt index 6446a7357..843dfb5cd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/AppInjector.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/AppInjector.kt @@ -36,29 +36,31 @@ object AppInjector { DaggerAppComponent.builder().application(app) .build().inject(app) - app.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks { - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { - handleActivity(activity) - } + app.registerActivityLifecycleCallbacks( + object : Application.ActivityLifecycleCallbacks { + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { + handleActivity(activity) + } - override fun onActivityPaused(activity: Activity) { - } + override fun onActivityPaused(activity: Activity) { + } - override fun onActivityResumed(activity: Activity) { - } + override fun onActivityResumed(activity: Activity) { + } - override fun onActivityStarted(activity: Activity) { - } + override fun onActivityStarted(activity: Activity) { + } - override fun onActivityDestroyed(activity: Activity) { - } + override fun onActivityDestroyed(activity: Activity) { + } - override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { - } + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { + } - override fun onActivityStopped(activity: Activity) { - } - }) + override fun onActivityStopped(activity: Activity) { + } + }, + ) } private fun handleActivity(activity: Activity) { @@ -74,7 +76,7 @@ object AppInjector { } } }, - true + true, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt index 81c50c4e3..c89799d81 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt @@ -70,7 +70,7 @@ class AppModule { AppDatabase.MIGRATION_44_45, AppDatabase.MIGRATION_45_46, AppDatabase.MIGRATION_46_47, AppDatabase.MIGRATION_47_48, /* 48 -> 49, auto */ /* 49 -> 50, auto */ /* 50 -> 51, auto */ /* 51 -> 52, auto */ AppDatabase.MIGRATION_52_53, - AppDatabase.MIGRATION_53_54 + AppDatabase.MIGRATION_53_54, ) .build() } diff --git a/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt index 03b4ad394..971304d82 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt @@ -68,7 +68,7 @@ class NetworkModule { fun providesHttpClient( accountManager: AccountManager, context: Context, - preferences: SharedPreferences + preferences: SharedPreferences, ): OkHttpClient { val httpProxyEnabled = preferences.getBoolean(HTTP_PROXY_ENABLED, false) val httpServer = preferences.getNonNullString(HTTP_PROXY_SERVER, "") @@ -84,7 +84,7 @@ class NetworkModule { val requestWithUserAgent = chain.request().newBuilder() .header( "User-Agent", - "Tusky/${BuildConfig.VERSION_NAME} Android/${Build.VERSION.RELEASE} OkHttp/${OkHttp.VERSION}" + "Tusky/${BuildConfig.VERSION_NAME} Android/${Build.VERSION.RELEASE} OkHttp/${OkHttp.VERSION}", ) .build() chain.proceed(requestWithUserAgent) @@ -114,7 +114,7 @@ class NetworkModule { @Singleton fun providesRetrofit( httpClient: OkHttpClient, - gson: Gson + gson: Gson, ): Retrofit { return Retrofit.Builder().baseUrl("https://" + MastodonApi.PLACEHOLDER_DOMAIN) .client(httpClient) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/AccessToken.kt b/app/src/main/java/com/keylesspalace/tusky/entity/AccessToken.kt index e974ce196..f73357659 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/AccessToken.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/AccessToken.kt @@ -18,5 +18,5 @@ package com.keylesspalace.tusky.entity import com.google.gson.annotations.SerializedName data class AccessToken( - @SerializedName("access_token") val accessToken: String + @SerializedName("access_token") val accessToken: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt index 43b9bd9c9..56ed4d21e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt @@ -36,7 +36,7 @@ data class Account( val bot: Boolean = false, val emojis: List? = emptyList(), // nullable for backward compatibility val fields: List? = emptyList(), // nullable for backward compatibility - val moved: Account? = null + val moved: Account? = null, ) { @@ -55,16 +55,16 @@ data class AccountSource( val sensitive: Boolean?, val note: String?, val fields: List?, - val language: String? + val language: String?, ) data class Field( val name: String, val value: String, - @SerializedName("verified_at") val verifiedAt: Date? + @SerializedName("verified_at") val verifiedAt: Date?, ) data class StringField( val name: String, - val value: String + val value: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Announcement.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Announcement.kt index 5837815b0..48551195d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Announcement.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Announcement.kt @@ -31,7 +31,7 @@ data class Announcement( val statuses: List, val tags: List, val emojis: List, - val reactions: List + val reactions: List, ) { override fun equals(other: Any?): Boolean { @@ -51,6 +51,6 @@ data class Announcement( val count: Int, val me: Boolean, val url: String?, - @SerializedName("static_url") val staticUrl: String? + @SerializedName("static_url") val staticUrl: String?, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/AppCredentials.kt b/app/src/main/java/com/keylesspalace/tusky/entity/AppCredentials.kt index fe6b0c3ce..87d4a6dc1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/AppCredentials.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/AppCredentials.kt @@ -19,5 +19,5 @@ import com.google.gson.annotations.SerializedName data class AppCredentials( @SerializedName("client_id") val clientId: String, - @SerializedName("client_secret") val clientSecret: String + @SerializedName("client_secret") val clientSecret: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt index 0ebd9c370..f8942fa4c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt @@ -32,7 +32,7 @@ data class Attachment( val meta: MetaData?, val type: Type, val description: String?, - val blurhash: String? + val blurhash: String?, ) : Parcelable { @JsonAdapter(MediaTypeDeserializer::class) @@ -50,7 +50,7 @@ data class Attachment( AUDIO, @SerializedName("unknown") - UNKNOWN + UNKNOWN, } class MediaTypeDeserializer : JsonDeserializer { @@ -74,7 +74,7 @@ data class Attachment( val focus: Focus?, val duration: Float?, val original: Size?, - val small: Size? + val small: Size?, ) : Parcelable /** @@ -86,7 +86,7 @@ data class Attachment( @Parcelize data class Focus( val x: Float, - val y: Float + val y: Float, ) : Parcelable { fun toMastodonApiString(): String = "$x,$y" } @@ -98,6 +98,6 @@ data class Attachment( data class Size( val width: Int, val height: Int, - val aspect: Double + val aspect: Double, ) : Parcelable } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Card.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Card.kt index 05cac1a0f..65168a023 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Card.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Card.kt @@ -27,7 +27,7 @@ data class Card( val width: Int, val height: Int, val blurhash: String?, - @SerializedName("embed_url") val embedUrl: String? + @SerializedName("embed_url") val embedUrl: String?, ) { override fun hashCode() = url.hashCode() diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Conversation.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Conversation.kt index e5a547f11..da46d9347 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Conversation.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Conversation.kt @@ -21,5 +21,5 @@ data class Conversation( val id: String, val accounts: List, @SerializedName("last_status") val lastStatus: Status?, // should never be null, but apparently its possible https://github.com/tuskyapp/Tusky/issues/1038 - val unread: Boolean + val unread: Boolean, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt b/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt index c400a1af6..852e29eef 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt @@ -27,7 +27,7 @@ data class DeletedStatus( @SerializedName("media_attachments") val attachments: List?, val poll: Poll?, @SerializedName("created_at") val createdAt: Date, - val language: String? + val language: String?, ) { fun isEmpty(): Boolean { return text == null && attachments == null diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt index 130831a2d..07c8d0a11 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Emoji.kt @@ -24,5 +24,5 @@ data class Emoji( val shortcode: String, val url: String, @SerializedName("static_url") val staticUrl: String, - @SerializedName("visible_in_picker") val visibleInPicker: Boolean? + @SerializedName("visible_in_picker") val visibleInPicker: Boolean?, ) : Parcelable diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Error.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Error.kt index 738b4499d..2bdbf08e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Error.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Error.kt @@ -20,5 +20,5 @@ package com.keylesspalace.tusky.entity /** @see [Error](https://docs.joinmastodon.org/entities/Error/) */ data class Error( val error: String, - val error_description: String? + val error_description: String?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt index dbc537828..3cb387b89 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt @@ -13,13 +13,14 @@ data class Filter( val context: List, @SerializedName("expires_at") val expiresAt: Date?, @SerializedName("filter_action") private val filterAction: String, - val keywords: List + val keywords: List, // val statuses: List, ) : Parcelable { enum class Action(val action: String) { NONE("none"), WARN("warn"), - HIDE("hide"); + HIDE("hide"), + ; companion object { fun from(action: String): Action = values().firstOrNull { it.action == action } ?: WARN @@ -30,7 +31,8 @@ data class Filter( NOTIFICATIONS("notifications"), PUBLIC("public"), THREAD("thread"), - ACCOUNT("account"); + ACCOUNT("account"), + ; companion object { fun from(kind: String): Kind = values().firstOrNull { it.kind == kind } ?: PUBLIC @@ -40,7 +42,8 @@ data class Filter( is TimelineKind.PublicFederated, is TimelineKind.PublicLocal, is TimelineKind.Tag, - is TimelineKind.Favourites -> Filter.Kind.PUBLIC + is TimelineKind.Favourites, + -> Filter.Kind.PUBLIC is TimelineKind.User -> Filter.Kind.ACCOUNT else -> Filter.Kind.PUBLIC } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/FilterKeyword.kt b/app/src/main/java/com/keylesspalace/tusky/entity/FilterKeyword.kt index c62ac4090..131540c14 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/FilterKeyword.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/FilterKeyword.kt @@ -8,5 +8,5 @@ import kotlinx.parcelize.Parcelize data class FilterKeyword( val id: String, val keyword: String, - @SerializedName("whole_word") val wholeWord: Boolean + @SerializedName("whole_word") val wholeWord: Boolean, ) : Parcelable diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/FilterResult.kt b/app/src/main/java/com/keylesspalace/tusky/entity/FilterResult.kt index f51af22ff..5fd10f98d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/FilterResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/FilterResult.kt @@ -5,5 +5,5 @@ import com.google.gson.annotations.SerializedName data class FilterResult( val filter: Filter, @SerializedName("keyword_matches") val keywordMatches: List?, - @SerializedName("status_matches") val statusMatches: List? + @SerializedName("status_matches") val statusMatches: List?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt b/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt index a93ccff5e..c82091284 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt @@ -24,7 +24,7 @@ data class FilterV1( val context: List, @SerializedName("expires_at") val expiresAt: Date?, val irreversible: Boolean, - @SerializedName("whole_word") val wholeWord: Boolean + @SerializedName("whole_word") val wholeWord: Boolean, ) { companion object { const val HOME = "home" @@ -57,9 +57,9 @@ data class FilterV1( FilterKeyword( id = id, keyword = phrase, - wholeWord = wholeWord - ) - ) + wholeWord = wholeWord, + ), + ), ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt index 77864cfeb..ba9c2351a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt @@ -34,7 +34,7 @@ data class Instance( @SerializedName("max_media_attachments") val maxMediaAttachments: Int?, val pleroma: PleromaConfiguration?, @SerializedName("upload_limit") val uploadLimit: Int?, - val rules: List? + val rules: List?, ) { override fun hashCode(): Int { return uri.hashCode() @@ -54,19 +54,19 @@ data class PollConfiguration( @SerializedName("max_option_chars") val maxOptionChars: Int?, @SerializedName("max_characters_per_option") val maxCharactersPerOption: Int?, @SerializedName("min_expiration") val minExpiration: Int?, - @SerializedName("max_expiration") val maxExpiration: Int? + @SerializedName("max_expiration") val maxExpiration: Int?, ) data class InstanceConfiguration( val statuses: StatusConfiguration?, @SerializedName("media_attachments") val mediaAttachments: MediaAttachmentConfiguration?, - val polls: PollConfiguration? + val polls: PollConfiguration?, ) data class StatusConfiguration( @SerializedName("max_characters") val maxCharacters: Int?, @SerializedName("max_media_attachments") val maxMediaAttachments: Int?, - @SerializedName("characters_reserved_per_url") val charactersReservedPerUrl: Int? + @SerializedName("characters_reserved_per_url") val charactersReservedPerUrl: Int?, ) data class MediaAttachmentConfiguration( @@ -75,24 +75,24 @@ data class MediaAttachmentConfiguration( @SerializedName("image_matrix_limit") val imageMatrixLimit: Int?, @SerializedName("video_size_limit") val videoSizeLimit: Int?, @SerializedName("video_frame_rate_limit") val videoFrameRateLimit: Int?, - @SerializedName("video_matrix_limit") val videoMatrixLimit: Int? + @SerializedName("video_matrix_limit") val videoMatrixLimit: Int?, ) data class PleromaConfiguration( - val metadata: PleromaMetadata? + val metadata: PleromaMetadata?, ) data class PleromaMetadata( - @SerializedName("fields_limits") val fieldLimits: PleromaFieldLimits + @SerializedName("fields_limits") val fieldLimits: PleromaFieldLimits, ) data class PleromaFieldLimits( @SerializedName("max_fields") val maxFields: Int?, @SerializedName("name_length") val nameLength: Int?, - @SerializedName("value_length") val valueLength: Int? + @SerializedName("value_length") val valueLength: Int?, ) data class InstanceRules( val id: String, - val text: String + val text: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Marker.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Marker.kt index 78572054d..3a623c6bc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Marker.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Marker.kt @@ -11,5 +11,5 @@ data class Marker( val lastReadId: String, val version: Int, @SerializedName("updated_at") - val updatedAt: Date + val updatedAt: Date, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/MastoList.kt b/app/src/main/java/com/keylesspalace/tusky/entity/MastoList.kt index a74337ef5..69ad597d2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/MastoList.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/MastoList.kt @@ -23,5 +23,5 @@ package com.keylesspalace.tusky.entity data class MastoList( val id: String, val title: String, - val exclusive: Boolean? + val exclusive: Boolean?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/MediaUploadResult.kt b/app/src/main/java/com/keylesspalace/tusky/entity/MediaUploadResult.kt index 15910f621..052f689a5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/MediaUploadResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/MediaUploadResult.kt @@ -5,5 +5,5 @@ package com.keylesspalace.tusky.entity * We are only interested in the id, so other attributes are omitted */ data class MediaUploadResult( - val id: String + val id: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt b/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt index 1a353eadf..1d202bef6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt @@ -29,14 +29,14 @@ data class NewStatus( @SerializedName("media_attributes") val mediaAttributes: List?, @SerializedName("scheduled_at") val scheduledAt: String?, val poll: NewPoll?, - val language: String? + val language: String?, ) @Parcelize data class NewPoll( val options: List, @SerializedName("expires_in") val expiresIn: Int, - val multiple: Boolean + val multiple: Boolean, ) : Parcelable // It would be nice if we could reuse MediaToSend, @@ -46,5 +46,5 @@ data class MediaAttribute( val id: String, val description: String?, val focus: String?, - val thumbnail: String? + val thumbnail: String?, ) : Parcelable diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Notification.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Notification.kt index a7007e57c..224c792a6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Notification.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Notification.kt @@ -28,7 +28,7 @@ data class Notification( val id: String, val account: TimelineAccount, val status: Status?, - val report: Report? + val report: Report?, ) { /** From https://docs.joinmastodon.org/entities/Notification/#type */ @@ -64,7 +64,8 @@ data class Notification( UPDATE("update", R.string.notification_update_name), /** A new report has been filed */ - REPORT("admin.report", R.string.notification_report_name); + REPORT("admin.report", R.string.notification_report_name), + ; companion object { @JvmStatic @@ -104,7 +105,7 @@ data class Notification( override fun deserialize( json: JsonElement, typeOfT: java.lang.reflect.Type, - context: JsonDeserializationContext + context: JsonDeserializationContext, ): Type { return Type.byString(json.asString) } diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/NotificationSubscribeResult.kt b/app/src/main/java/com/keylesspalace/tusky/entity/NotificationSubscribeResult.kt index 6bdaa1438..c6eb09bec 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/NotificationSubscribeResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/NotificationSubscribeResult.kt @@ -20,5 +20,5 @@ import com.google.gson.annotations.SerializedName data class NotificationSubscribeResult( val id: Int, val endpoint: String, - @SerializedName("server_key") val serverKey: String + @SerializedName("server_key") val serverKey: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Poll.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Poll.kt index 584b76f8c..fcf1d161c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Poll.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Poll.kt @@ -12,7 +12,7 @@ data class Poll( @SerializedName("voters_count") val votersCount: Int?, // nullable for compatibility with Pleroma val options: List, val voted: Boolean, - @SerializedName("own_votes") val ownVotes: List? + @SerializedName("own_votes") val ownVotes: List?, ) { fun votedCopy(choices: List): Poll { @@ -28,7 +28,7 @@ data class Poll( options = newOptions, votesCount = votesCount + choices.size, votersCount = votersCount?.plus(1), - voted = true + voted = true, ) } @@ -37,11 +37,11 @@ data class Poll( expiresAt?.let { ((it.time - creationDate.time) / 1000).toInt() + 1 } ?: 3600, - multiple + multiple, ) } data class PollOption( val title: String, - @SerializedName("votes_count") val votesCount: Int + @SerializedName("votes_count") val votesCount: Int, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Relationship.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Relationship.kt index e99bcce6d..16aaa1c57 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Relationship.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Relationship.kt @@ -35,5 +35,5 @@ data class Relationship( @JsonAdapter(GuardedBooleanAdapter::class) val subscribing: Boolean? = null, @SerializedName("domain_blocking") val blockingDomain: Boolean, val note: String?, // nullable for backward compatibility / feature detection - val notifying: Boolean? // since 3.3.0rc + val notifying: Boolean?, // since 3.3.0rc ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Report.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Report.kt index 8de7b957d..0330c102c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Report.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Report.kt @@ -8,5 +8,5 @@ data class Report( val category: String, val status_ids: List?, @SerializedName("created_at") val createdAt: Date, - @SerializedName("target_account") val targetAccount: TimelineAccount + @SerializedName("target_account") val targetAccount: TimelineAccount, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/ScheduledStatus.kt b/app/src/main/java/com/keylesspalace/tusky/entity/ScheduledStatus.kt index dfaeb499c..800b45517 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/ScheduledStatus.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/ScheduledStatus.kt @@ -21,5 +21,5 @@ data class ScheduledStatus( val id: String, @SerializedName("scheduled_at") val scheduledAt: String, val params: StatusParams, - @SerializedName("media_attachments") val mediaAttachments: ArrayList + @SerializedName("media_attachments") val mediaAttachments: ArrayList, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/SearchResult.kt b/app/src/main/java/com/keylesspalace/tusky/entity/SearchResult.kt index 5bc78cf72..5653a77de 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/SearchResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/SearchResult.kt @@ -18,5 +18,5 @@ package com.keylesspalace.tusky.entity data class SearchResult( val accounts: List, val statuses: List, - val hashtags: List + val hashtags: List, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 0b9a0796d..9896dd93d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -50,7 +50,7 @@ data class Status( val poll: Poll?, val card: Card?, val language: String?, - val filtered: List? + val filtered: List?, ) { val actionableId: String @@ -79,7 +79,8 @@ data class Status( PRIVATE(3), @SerializedName("direct") - DIRECT(4); + DIRECT(4), + ; fun serverString(): String { return when (this) { @@ -137,7 +138,7 @@ data class Status( attachments = attachments, poll = poll, createdAt = createdAt, - language = language + language = language, ) } @@ -164,12 +165,12 @@ data class Status( val id: String, val url: String, @SerializedName("acct") val username: String, - @SerializedName("username") val localUsername: String + @SerializedName("username") val localUsername: String, ) data class Application( val name: String, - val website: String? + val website: String?, ) companion object { diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/StatusContext.kt b/app/src/main/java/com/keylesspalace/tusky/entity/StatusContext.kt index ce5bb1440..da8b275b3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/StatusContext.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/StatusContext.kt @@ -17,5 +17,5 @@ package com.keylesspalace.tusky.entity data class StatusContext( val ancestors: List, - val descendants: List + val descendants: List, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/StatusEdit.kt b/app/src/main/java/com/keylesspalace/tusky/entity/StatusEdit.kt index 0e77b0fd9..37cefbf5b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/StatusEdit.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/StatusEdit.kt @@ -11,5 +11,5 @@ data class StatusEdit( val account: TimelineAccount, val poll: Poll?, @SerializedName("media_attachments") val mediaAttachments: List, - val emojis: List + val emojis: List, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/StatusParams.kt b/app/src/main/java/com/keylesspalace/tusky/entity/StatusParams.kt index d3235337b..e62e5d2e6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/StatusParams.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/StatusParams.kt @@ -22,5 +22,5 @@ data class StatusParams( val sensitive: Boolean, val visibility: Status.Visibility, @SerializedName("spoiler_text") val spoilerText: String, - @SerializedName("in_reply_to_id") val inReplyToId: String? + @SerializedName("in_reply_to_id") val inReplyToId: String?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/StatusSource.kt b/app/src/main/java/com/keylesspalace/tusky/entity/StatusSource.kt index 98a01d8b9..aea6bdd47 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/StatusSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/StatusSource.kt @@ -20,5 +20,5 @@ import com.google.gson.annotations.SerializedName data class StatusSource( val id: String, val text: String, - @SerializedName("spoiler_text") val spoilerText: String + @SerializedName("spoiler_text") val spoilerText: String, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt b/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt index f801d4969..24228049f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt @@ -30,7 +30,7 @@ data class TimelineAccount( val avatar: String, val note: String, val bot: Boolean = false, - val emojis: List? = emptyList() // nullable for backward compatibility + val emojis: List? = emptyList(), // nullable for backward compatibility ) { val name: String diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt b/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt index 786695559..a622701a3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt @@ -27,7 +27,7 @@ import java.util.Date */ data class TrendingTag( val name: String, - val history: List + val history: List, ) /** @@ -40,7 +40,7 @@ data class TrendingTag( data class TrendingTagHistory( val day: String, val accounts: String, - val uses: String + val uses: String, ) fun TrendingTag.start() = Date(history.last().day.toLong() * 1000L) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/TrendsLink.kt b/app/src/main/java/com/keylesspalace/tusky/entity/TrendsLink.kt index c95178f9b..efc87d354 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/TrendsLink.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/TrendsLink.kt @@ -30,7 +30,7 @@ enum class PreviewCardKind { VIDEO, @SerializedName("rich") - RICH + RICH, } /** @@ -56,7 +56,7 @@ interface PreviewCard { data class LinkHistory( val day: String, val accounts: Int, - val uses: Int + val uses: Int, ) /** Represents a https://docs.joinmastodon.org/entities/PreviewCard/#trends-link */ @@ -75,5 +75,5 @@ data class TrendsLink( override val image: String? = null, @SerializedName("embed_url") override val embedUrl: String, override val blurhash: String? = null, - val history: List + val history: List, ) : PreviewCard diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt index a99236839..45d2855fe 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt @@ -122,7 +122,7 @@ abstract class SFragment : Fragment(), Injectable { loggedInUsername = activeAccount.username } val mentionedUsernames = LinkedHashSet( - listOf(account.username) + actionableStatus.mentions.map { it.username } + listOf(account.username) + actionableStatus.mentions.map { it.username }, ).apply { remove(loggedInUsername) } val composeOptions = ComposeOptions( @@ -133,7 +133,7 @@ abstract class SFragment : Fragment(), Injectable { replyingStatusAuthor = account.localUsername, replyingStatusContent = actionableStatus.content.parseAsMastodonHtml().toString(), language = actionableStatus.language, - kind = ComposeActivity.ComposeKind.NEW + kind = ComposeActivity.ComposeKind.NEW, ) val intent = startIntent(requireContext(), composeOptions) @@ -188,7 +188,7 @@ abstract class SFragment : Fragment(), Injectable { R.string.action_mute_conversation } else { R.string.action_unmute_conversation - } + }, ) } popup.setOnMenuItemClickListener { item: MenuItem -> @@ -200,15 +200,15 @@ abstract class SFragment : Fragment(), Injectable { type = "text/plain" putExtra( Intent.EXTRA_TEXT, - "${statusToShare.account.username} - ${statusToShare.content.parseAsMastodonHtml()}" + "${statusToShare.account.username} - ${statusToShare.content.parseAsMastodonHtml()}", ) putExtra(Intent.EXTRA_SUBJECT, statusUrl) } startActivity( Intent.createChooser( sendIntent, - resources.getText(R.string.send_post_content_to) - ) + resources.getText(R.string.send_post_content_to), + ), ) return@setOnMenuItemClickListener true } @@ -221,8 +221,8 @@ abstract class SFragment : Fragment(), Injectable { startActivity( Intent.createChooser( sendIntent, - resources.getText(R.string.send_post_link_to) - ) + resources.getText(R.string.send_post_link_to), + ), ) return@setOnMenuItemClickListener true } @@ -325,7 +325,7 @@ abstract class SFragment : Fragment(), Injectable { val options = ActivityOptionsCompat.makeSceneTransitionAnimation( requireActivity(), view, - url + url, ) startActivity(intent, options.toBundle()) } else { @@ -394,7 +394,7 @@ abstract class SFragment : Fragment(), Injectable { modifiedInitialState = true, language = sourceStatus.language, poll = sourceStatus.poll?.toNewPoll(sourceStatus.createdAt), - kind = ComposeActivity.ComposeKind.NEW + kind = ComposeActivity.ComposeKind.NEW, ) startActivity(startIntent(requireContext(), composeOptions)) }, @@ -402,7 +402,7 @@ abstract class SFragment : Fragment(), Injectable { Log.w("SFragment", "error deleting status", error) Toast.makeText(context, R.string.error_generic, Toast.LENGTH_SHORT) .show() - } + }, ) } } @@ -424,7 +424,7 @@ abstract class SFragment : Fragment(), Injectable { language = status.language, statusId = source.id, poll = status.poll?.toNewPoll(status.createdAt), - kind = ComposeActivity.ComposeKind.EDIT_POSTED + kind = ComposeActivity.ComposeKind.EDIT_POSTED, ) startActivity(startIntent(requireContext(), composeOptions)) }, @@ -432,9 +432,9 @@ abstract class SFragment : Fragment(), Injectable { Snackbar.make( requireView(), getString(R.string.error_status_source_load), - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ).show() - } + }, ) } } @@ -452,7 +452,7 @@ abstract class SFragment : Fragment(), Injectable { override fun onAccountSelected(account: AccountEntity) { openAsAccount(statusUrl, account) } - } + }, ) } } @@ -466,7 +466,7 @@ abstract class SFragment : Fragment(), Injectable { downloadManager.enqueue( DownloadManager.Request(uri).apply { setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.lastPathSegment) - } + }, ) } } @@ -481,7 +481,7 @@ abstract class SFragment : Fragment(), Injectable { Toast.makeText( context, R.string.error_media_download_permission, - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() } } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt index bbbfdf219..55cb8ca31 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt @@ -75,7 +75,7 @@ class ViewImageFragment : ViewMediaFragment() { url: String, previewUrl: String?, description: String?, - showingDescription: Boolean + showingDescription: Boolean, ) { binding.photoView.transitionName = url binding.mediaDescription.text = description @@ -119,104 +119,106 @@ class ViewImageFragment : ViewMediaFragment() { photoActionsListener.onPhotoTap() return false } - } + }, ) - binding.photoView.setOnTouchCoordinatesListener(object : OnTouchCoordinatesListener { - /** Y coordinate of the last single-finger drag */ - var lastDragY: Float? = null + binding.photoView.setOnTouchCoordinatesListener( + object : OnTouchCoordinatesListener { + /** Y coordinate of the last single-finger drag */ + var lastDragY: Float? = null - override fun onTouchCoordinate(view: View, event: MotionEvent, bitmapPoint: PointF) { - singleTapDetector.onTouchEvent(event) + override fun onTouchCoordinate(view: View, event: MotionEvent, bitmapPoint: PointF) { + singleTapDetector.onTouchEvent(event) - // Two fingers have gone down after a single finger drag. Finish the drag - if (event.pointerCount == 2 && lastDragY != null) { - onGestureEnd(view) - lastDragY = null - } - - // Stop the parent view from handling touches if either (a) the user has 2+ - // fingers on the screen, or (b) the image has been zoomed in, and can be scrolled - // horizontally in both directions. - // - // This stops things like ViewPager2 from trying to intercept a left/right swipe - // and ensures that the image does not appear to "stick" to the screen as different - // views fight over who should be handling the swipe. - // - // If the view can be scrolled in one direction it's OK to let the parent intercept, - // which allows the user to swipe between images even if one or more of them have - // been zoomed in. - if (event.pointerCount >= 2 || view.canScrollHorizontally(1) && view.canScrollHorizontally(-1)) { - when (event.action) { - MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { - view.parent.requestDisallowInterceptTouchEvent(true) - } - - MotionEvent.ACTION_UP -> { - view.parent.requestDisallowInterceptTouchEvent(false) - } - } - return - } - - // The user is dragging the image around - if (event.pointerCount == 1) { - // If the image is zoomed then the swipe-to-dismiss functionality is disabled - if ((view as TouchImageView).isZoomed) return - - // The user's finger just went down, start recording where they are dragging from - if (event.action == MotionEvent.ACTION_DOWN) { - lastDragY = event.rawY - return - } - - // The user is dragging the un-zoomed image to possibly fling it up or down - // to dismiss. - if (event.action == MotionEvent.ACTION_MOVE) { - // lastDragY may be null; e.g., the user was performing a two-finger drag, - // and has lifted one finger. In this case do nothing - lastDragY ?: return - - // Compute the Y offset of the drag, and scale/translate the photoview - // accordingly. - val diff = event.rawY - lastDragY!! - if (view.translationY != 0f || abs(diff) > 40) { - // Drag has definitely started, stop the parent from interfering - view.parent.requestDisallowInterceptTouchEvent(true) - view.translationY += diff - val scale = (-abs(view.translationY) / 720 + 1).coerceAtLeast(0.5f) - view.scaleY = scale - view.scaleX = scale - lastDragY = event.rawY - } - return - } - - // The user has finished dragging. Allow the parent to handle touch events if - // appropriate, and end the gesture. - if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) { - view.parent.requestDisallowInterceptTouchEvent(false) - if (lastDragY != null) onGestureEnd(view) + // Two fingers have gone down after a single finger drag. Finish the drag + if (event.pointerCount == 2 && lastDragY != null) { + onGestureEnd(view) lastDragY = null + } + + // Stop the parent view from handling touches if either (a) the user has 2+ + // fingers on the screen, or (b) the image has been zoomed in, and can be scrolled + // horizontally in both directions. + // + // This stops things like ViewPager2 from trying to intercept a left/right swipe + // and ensures that the image does not appear to "stick" to the screen as different + // views fight over who should be handling the swipe. + // + // If the view can be scrolled in one direction it's OK to let the parent intercept, + // which allows the user to swipe between images even if one or more of them have + // been zoomed in. + if (event.pointerCount >= 2 || view.canScrollHorizontally(1) && view.canScrollHorizontally(-1)) { + when (event.action) { + MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { + view.parent.requestDisallowInterceptTouchEvent(true) + } + + MotionEvent.ACTION_UP -> { + view.parent.requestDisallowInterceptTouchEvent(false) + } + } return } - } - } - /** - * Handle the end of the user's gesture. - * - * If the user was previously dragging, and the image has been dragged a sufficient - * distance then we are done. Otherwise, animate the image back to its starting position. - */ - private fun onGestureEnd(view: View) { - if (abs(view.translationY) > 180) { - photoActionsListener.onDismiss() - } else { - view.animate().translationY(0f).scaleX(1f).start() + // The user is dragging the image around + if (event.pointerCount == 1) { + // If the image is zoomed then the swipe-to-dismiss functionality is disabled + if ((view as TouchImageView).isZoomed) return + + // The user's finger just went down, start recording where they are dragging from + if (event.action == MotionEvent.ACTION_DOWN) { + lastDragY = event.rawY + return + } + + // The user is dragging the un-zoomed image to possibly fling it up or down + // to dismiss. + if (event.action == MotionEvent.ACTION_MOVE) { + // lastDragY may be null; e.g., the user was performing a two-finger drag, + // and has lifted one finger. In this case do nothing + lastDragY ?: return + + // Compute the Y offset of the drag, and scale/translate the photoview + // accordingly. + val diff = event.rawY - lastDragY!! + if (view.translationY != 0f || abs(diff) > 40) { + // Drag has definitely started, stop the parent from interfering + view.parent.requestDisallowInterceptTouchEvent(true) + view.translationY += diff + val scale = (-abs(view.translationY) / 720 + 1).coerceAtLeast(0.5f) + view.scaleY = scale + view.scaleX = scale + lastDragY = event.rawY + } + return + } + + // The user has finished dragging. Allow the parent to handle touch events if + // appropriate, and end the gesture. + if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) { + view.parent.requestDisallowInterceptTouchEvent(false) + if (lastDragY != null) onGestureEnd(view) + lastDragY = null + return + } + } } - } - }) + + /** + * Handle the end of the user's gesture. + * + * If the user was previously dragging, and the image has been dragged a sufficient + * distance then we are done. Otherwise, animate the image back to its starting position. + */ + private fun onGestureEnd(view: View) { + if (abs(view.translationY) > 180) { + photoActionsListener.onDismiss() + } else { + view.animate().translationY(0f).scaleX(1f).start() + } + } + }, + ) finalizeViewSetup(url, attachment?.previewUrl, description) } @@ -227,13 +229,15 @@ class ViewImageFragment : ViewMediaFragment() { isDescriptionVisible = showingDescription && visible val alpha = if (isDescriptionVisible) 1.0f else 0.0f binding.captionSheet.animate().alpha(alpha) - .setListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator) { - view ?: return - binding.captionSheet.visible(isDescriptionVisible) - animation.removeListener(this) - } - }) + .setListener( + object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + view ?: return + binding.captionSheet.visible(isDescriptionVisible) + animation.removeListener(this) + } + }, + ) .start() } @@ -262,7 +266,7 @@ class ViewImageFragment : ViewMediaFragment() { .dontAnimate() .onlyRetrieveFromCache(true) .centerInside() - .addListener(ImageRequestListener(true, isThumbnailRequest = true)) + .addListener(ImageRequestListener(true, isThumbnailRequest = true)), ) } else { it @@ -272,7 +276,7 @@ class ViewImageFragment : ViewMediaFragment() { .error( glide.load(url) .centerInside() - .addListener(ImageRequestListener(false, isThumbnailRequest = false)) + .addListener(ImageRequestListener(false, isThumbnailRequest = false)), ) .centerInside() .addListener(ImageRequestListener(true, isThumbnailRequest = false)) @@ -301,14 +305,14 @@ class ViewImageFragment : ViewMediaFragment() { */ private inner class ImageRequestListener( private val isCacheRequest: Boolean, - private val isThumbnailRequest: Boolean + private val isThumbnailRequest: Boolean, ) : RequestListener { override fun onLoadFailed( e: GlideException?, model: Any, target: Target, - isFirstResource: Boolean + isFirstResource: Boolean, ): Boolean { // If cache for full image failed complete transition if (isCacheRequest && !isThumbnailRequest && shouldStartTransition && @@ -328,7 +332,7 @@ class ViewImageFragment : ViewMediaFragment() { model: Any, target: Target, dataSource: DataSource, - isFirstResource: Boolean + isFirstResource: Boolean, ): Boolean { binding.progressBar.hide() // Always hide the progress bar on success diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt index 3125e556e..fb4e86577 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt @@ -30,7 +30,7 @@ abstract class ViewMediaFragment : Fragment() { url: String, previewUrl: String?, description: String?, - showingDescription: Boolean + showingDescription: Boolean, ) abstract fun onToolbarVisibilityChange(visible: Boolean) @@ -59,7 +59,8 @@ abstract class ViewMediaFragment : Fragment() { Attachment.Type.IMAGE -> ViewImageFragment() Attachment.Type.VIDEO, Attachment.Type.GIFV, - Attachment.Type.AUDIO -> ViewVideoFragment() + Attachment.Type.AUDIO, + -> ViewVideoFragment() else -> ViewImageFragment() // it probably won't show anything, but its better than crashing } fragment.arguments = arguments diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 6cd13c076..ab51702f9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -158,7 +158,7 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { e1: MotionEvent, e2: MotionEvent, velocityX: Float, - velocityY: Float + velocityY: Float, ): Boolean { if (abs(velocityY) > abs(velocityX)) { videoActionsListener.onDismiss() @@ -166,7 +166,7 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { } return false } - } + }, ) @SuppressLint("ClickableViewAccessibility") @@ -231,7 +231,7 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { binding.progressBar.hide() val message = getString( R.string.error_media_playback, - error.cause?.message ?: error.message + error.cause?.message ?: error.message, ) Snackbar.make(binding.root, message, Snackbar.LENGTH_INDEFINITE) .setTextMaxLines(10) @@ -324,22 +324,24 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { // Audio-only files might have a preview image. If they do, set it as the artwork if (isAudio) { mediaAttachment.previewUrl?.let { url -> - Glide.with(this).load(url).into(object : CustomTarget() { - @SuppressLint("SyntheticAccessor") - override fun onResourceReady( - resource: Drawable, - transition: Transition? - ) { - view ?: return - binding.videoView.defaultArtwork = resource - } + Glide.with(this).load(url).into( + object : CustomTarget() { + @SuppressLint("SyntheticAccessor") + override fun onResourceReady( + resource: Drawable, + transition: Transition?, + ) { + view ?: return + binding.videoView.defaultArtwork = resource + } - @SuppressLint("SyntheticAccessor") - override fun onLoadCleared(placeholder: Drawable?) { - view ?: return - binding.videoView.defaultArtwork = null - } - }) + @SuppressLint("SyntheticAccessor") + override fun onLoadCleared(placeholder: Drawable?) { + view ?: return + binding.videoView.defaultArtwork = null + } + }, + ) } } } @@ -349,7 +351,7 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { url: String, previewUrl: String?, description: String?, - showingDescription: Boolean + showingDescription: Boolean, ) { binding.mediaDescription.text = description binding.mediaDescription.visible(showingDescription) @@ -385,14 +387,16 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable { } binding.mediaDescription.animate().alpha(alpha) - .setListener(object : AnimatorListenerAdapter() { - @SuppressLint("SyntheticAccessor") - override fun onAnimationEnd(animation: Animator) { - view ?: return - binding.mediaDescription.visible(isDescriptionVisible) - animation.removeListener(this) - } - }) + .setListener( + object : AnimatorListenerAdapter() { + @SuppressLint("SyntheticAccessor") + override fun onAnimationEnd(animation: Animator) { + view ?: return + binding.mediaDescription.visible(isDescriptionVisible) + animation.removeListener(this) + } + }, + ) .start() if (visible && (binding.videoView.player?.isPlaying == true) && !isAudio) { diff --git a/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt b/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt index 983333a9c..23619a046 100644 --- a/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt @@ -164,14 +164,14 @@ internal fun String.parseIsoDate(): Date { val cleaned = act.replace(":", "") if (cleaned != timezoneId) { throw IndexOutOfBoundsException( - "Mismatching time zone indicator: $timezoneId given, resolves to ${timezone.id}" + "Mismatching time zone indicator: $timezoneId given, resolves to ${timezone.id}", ) } } } } else { throw IndexOutOfBoundsException( - "Invalid time zone indicator '$timezoneIndicator'" + "Invalid time zone indicator '$timezoneIndicator'", ) } val calendar: Calendar = GregorianCalendar(timezone) diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt index 50ac2acfb..2e222375e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt @@ -80,11 +80,11 @@ data class Links(val next: String?, val prev: String?) { val links = HttpHeaderLink.parse(linkHeader) return Links( next = HttpHeaderLink.findByRelationType(links, "next")?.uri?.getQueryParameter( - "max_id" + "max_id", ), prev = HttpHeaderLink.findByRelationType(links, "prev")?.uri?.getQueryParameter( - "min_id" - ) + "min_id", + ), ) } } @@ -117,7 +117,7 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("min_id") minId: String? = null, @Query("since_id") sinceId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @GET("api/v1/timelines/public") @@ -126,7 +126,7 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, @Query("min_id") minId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @GET("api/v1/timelines/tag/{hashtag}") @@ -137,7 +137,7 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, @Query("min_id") minId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @GET("api/v1/timelines/list/{listId}") @@ -146,7 +146,7 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, @Query("min_id") minId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @GET("api/v1/notifications") @@ -158,20 +158,20 @@ interface MastodonApi { /** Maximum number of results to return. Defaults to 15, max is 30 */ @Query("limit") limit: Int? = null, /** Types to excludes from the results */ - @Query("exclude_types[]") excludes: Set? = null + @Query("exclude_types[]") excludes: Set? = null, ): Response> /** Fetch a single notification */ @GET("api/v1/notifications/{id}") suspend fun notification( - @Path("id") id: String + @Path("id") id: String, ): Response @GET("api/v1/markers") suspend fun markersWithAuth( @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, - @Query("timeline[]") timelines: List + @Query("timeline[]") timelines: List, ): Map @FormUrlEncoded @@ -180,7 +180,7 @@ interface MastodonApi { @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, @Field("home[last_read_id]") homeLastReadId: String? = null, - @Field("notifications[last_read_id]") notificationsLastReadId: String? = null + @Field("notifications[last_read_id]") notificationsLastReadId: String? = null, ): NetworkResult @GET("api/v1/notifications") @@ -188,7 +188,7 @@ interface MastodonApi { @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, /** Return results immediately newer than this ID */ - @Query("min_id") minId: String? + @Query("min_id") minId: String?, ): Response> @POST("api/v1/notifications/clear") @@ -199,12 +199,12 @@ interface MastodonApi { suspend fun updateMedia( @Path("mediaId") mediaId: String, @Field("description") description: String?, - @Field("focus") focus: String? + @Field("focus") focus: String?, ): NetworkResult @GET("api/v1/media/{mediaId}") suspend fun getMedia( - @Path("mediaId") mediaId: String + @Path("mediaId") mediaId: String, ): Response @POST("api/v1/statuses") @@ -212,12 +212,12 @@ interface MastodonApi { @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, @Header("Idempotency-Key") idempotencyKey: String, - @Body status: NewStatus + @Body status: NewStatus, ): NetworkResult @GET("api/v1/statuses/{id}") suspend fun status( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @PUT("api/v1/statuses/{id}") @@ -226,111 +226,111 @@ interface MastodonApi { @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, @Header("Idempotency-Key") idempotencyKey: String, - @Body editedStatus: NewStatus + @Body editedStatus: NewStatus, ): NetworkResult @GET("api/v1/statuses/{id}") suspend fun statusAsync( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @GET("api/v1/statuses/{id}/source") suspend fun statusSource( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @GET("api/v1/statuses/{id}/context") suspend fun statusContext( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @GET("api/v1/statuses/{id}/history") suspend fun statusEdits( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult> @GET("api/v1/statuses/{id}/reblogged_by") suspend fun statusRebloggedBy( @Path("id") statusId: String, - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @GET("api/v1/statuses/{id}/favourited_by") suspend fun statusFavouritedBy( @Path("id") statusId: String, - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @DELETE("api/v1/statuses/{id}") suspend fun deleteStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/reblog") suspend fun reblogStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/unreblog") suspend fun unreblogStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/favourite") suspend fun favouriteStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/unfavourite") suspend fun unfavouriteStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/bookmark") suspend fun bookmarkStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/unbookmark") suspend fun unbookmarkStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/pin") suspend fun pinStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/unpin") suspend fun unpinStatus( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/mute") suspend fun muteConversation( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @POST("api/v1/statuses/{id}/unmute") suspend fun unmuteConversation( - @Path("id") statusId: String + @Path("id") statusId: String, ): NetworkResult @GET("api/v1/scheduled_statuses") fun scheduledStatuses( @Query("limit") limit: Int? = null, - @Query("max_id") maxId: String? = null + @Query("max_id") maxId: String? = null, ): Single> @DELETE("api/v1/scheduled_statuses/{id}") suspend fun deleteScheduledStatus( - @Path("id") scheduledStatusId: String + @Path("id") scheduledStatusId: String, ): NetworkResult @GET("api/v1/accounts/verify_credentials") suspend fun accountVerifyCredentials( @Header(DOMAIN_HEADER) domain: String? = null, - @Header("Authorization") auth: String? = null + @Header("Authorization") auth: String? = null, ): NetworkResult @FormUrlEncoded @@ -338,7 +338,7 @@ interface MastodonApi { fun accountUpdateSource( @Field("source[privacy]") privacy: String?, @Field("source[sensitive]") sensitive: Boolean?, - @Field("source[language]") language: String? + @Field("source[language]") language: String?, ): Call @Multipart @@ -356,7 +356,7 @@ interface MastodonApi { @Part(value = "fields_attributes[2][name]") fieldName2: RequestBody?, @Part(value = "fields_attributes[2][value]") fieldValue2: RequestBody?, @Part(value = "fields_attributes[3][name]") fieldName3: RequestBody?, - @Part(value = "fields_attributes[3][value]") fieldValue3: RequestBody? + @Part(value = "fields_attributes[3][value]") fieldValue3: RequestBody?, ): NetworkResult @GET("api/v1/accounts/search") @@ -364,7 +364,7 @@ interface MastodonApi { @Query("q") query: String, @Query("resolve") resolve: Boolean? = null, @Query("limit") limit: Int? = null, - @Query("following") following: Boolean? = null + @Query("following") following: Boolean? = null, ): NetworkResult> @GET("api/v1/accounts/search") @@ -372,12 +372,12 @@ interface MastodonApi { @Query("q") query: String, @Query("resolve") resolve: Boolean? = null, @Query("limit") limit: Int? = null, - @Query("following") following: Boolean? = null + @Query("following") following: Boolean? = null, ): NetworkResult> @GET("api/v1/accounts/{id}") suspend fun account( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult /** @@ -398,19 +398,19 @@ interface MastodonApi { @Query("limit") limit: Int? = null, @Query("exclude_replies") excludeReplies: Boolean? = null, @Query("only_media") onlyMedia: Boolean? = null, - @Query("pinned") pinned: Boolean? = null + @Query("pinned") pinned: Boolean? = null, ): Response> @GET("api/v1/accounts/{id}/followers") suspend fun accountFollowers( @Path("id") accountId: String, - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @GET("api/v1/accounts/{id}/following") suspend fun accountFollowing( @Path("id") accountId: String, - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @FormUrlEncoded @@ -418,22 +418,22 @@ interface MastodonApi { suspend fun followAccount( @Path("id") accountId: String, @Field("reblogs") showReblogs: Boolean? = null, - @Field("notify") notify: Boolean? = null + @Field("notify") notify: Boolean? = null, ): NetworkResult @POST("api/v1/accounts/{id}/unfollow") suspend fun unfollowAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @POST("api/v1/accounts/{id}/block") suspend fun blockAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @POST("api/v1/accounts/{id}/unblock") suspend fun unblockAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @FormUrlEncoded @@ -441,50 +441,50 @@ interface MastodonApi { suspend fun muteAccount( @Path("id") accountId: String, @Field("notifications") notifications: Boolean? = null, - @Field("duration") duration: Int? = null + @Field("duration") duration: Int? = null, ): NetworkResult @POST("api/v1/accounts/{id}/unmute") suspend fun unmuteAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @GET("api/v1/accounts/relationships") suspend fun relationships( - @Query("id[]") accountIds: List + @Query("id[]") accountIds: List, ): NetworkResult> @POST("api/v1/pleroma/accounts/{id}/subscribe") suspend fun subscribeAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @POST("api/v1/pleroma/accounts/{id}/unsubscribe") suspend fun unsubscribeAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult @GET("api/v1/blocks") suspend fun blocks( - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @GET("api/v1/mutes") suspend fun mutes( - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @GET("api/v1/domain_blocks") fun domainBlocks( @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Single>> @FormUrlEncoded @POST("api/v1/domain_blocks") suspend fun blockDomain( - @Field("domain") domain: String + @Field("domain") domain: String, ): NetworkResult @FormUrlEncoded @@ -497,7 +497,7 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, @Query("min_id") minId: String? = null, - @Query("limit") limit: Int? + @Query("limit") limit: Int?, ): Response> @GET("api/v1/bookmarks") @@ -505,22 +505,22 @@ interface MastodonApi { @Query("max_id") maxId: String? = null, @Query("since_id") sinceId: String? = null, @Query("min_id") minId: String? = null, - @Query("limit") limit: Int? + @Query("limit") limit: Int?, ): Response> @GET("api/v1/follow_requests") suspend fun followRequests( - @Query("max_id") maxId: String? + @Query("max_id") maxId: String?, ): Response> @POST("api/v1/follow_requests/{id}/authorize") fun authorizeFollowRequest( - @Path("id") accountId: String + @Path("id") accountId: String, ): Single @POST("api/v1/follow_requests/{id}/reject") fun rejectFollowRequest( - @Path("id") accountId: String + @Path("id") accountId: String, ): Single @FormUrlEncoded @@ -530,7 +530,7 @@ interface MastodonApi { @Field("client_name") clientName: String, @Field("redirect_uris") redirectUris: String, @Field("scopes") scopes: String, - @Field("website") website: String + @Field("website") website: String, ): NetworkResult @FormUrlEncoded @@ -541,7 +541,7 @@ interface MastodonApi { @Field("client_secret") clientSecret: String, @Field("redirect_uri") redirectUri: String, @Field("code") code: String, - @Field("grant_type") grantType: String + @Field("grant_type") grantType: String, ): NetworkResult @FormUrlEncoded @@ -549,7 +549,7 @@ interface MastodonApi { suspend fun revokeOAuthToken( @Field("client_id") clientId: String, @Field("client_secret") clientSecret: String, - @Field("token") token: String + @Field("token") token: String, ): NetworkResult @GET("/api/v1/lists") @@ -557,14 +557,14 @@ interface MastodonApi { @GET("/api/v1/accounts/{id}/lists") suspend fun getListsIncludesAccount( - @Path("id") accountId: String + @Path("id") accountId: String, ): NetworkResult> @FormUrlEncoded @POST("api/v1/lists") suspend fun createList( @Field("title") title: String, - @Field("exclusive") exclusive: Boolean? + @Field("exclusive") exclusive: Boolean?, ): NetworkResult @FormUrlEncoded @@ -572,18 +572,18 @@ interface MastodonApi { suspend fun updateList( @Path("listId") listId: String, @Field("title") title: String, - @Field("exclusive") exclusive: Boolean? + @Field("exclusive") exclusive: Boolean?, ): NetworkResult @DELETE("api/v1/lists/{listId}") suspend fun deleteList( - @Path("listId") listId: String + @Path("listId") listId: String, ): NetworkResult @GET("api/v1/lists/{listId}/accounts") suspend fun getAccountsInList( @Path("listId") listId: String, - @Query("limit") limit: Int + @Query("limit") limit: Int, ): NetworkResult> @FormUrlEncoded @@ -591,25 +591,25 @@ interface MastodonApi { @HTTP(method = "DELETE", path = "api/v1/lists/{listId}/accounts", hasBody = true) suspend fun deleteAccountFromList( @Path("listId") listId: String, - @Field("account_ids[]") accountIds: List + @Field("account_ids[]") accountIds: List, ): NetworkResult @FormUrlEncoded @POST("api/v1/lists/{listId}/accounts") suspend fun addAccountToList( @Path("listId") listId: String, - @Field("account_ids[]") accountIds: List + @Field("account_ids[]") accountIds: List, ): NetworkResult @GET("/api/v1/conversations") suspend fun getConversations( @Query("max_id") maxId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @DELETE("/api/v1/conversations/{id}") suspend fun deleteConversation( - @Path("id") conversationId: String + @Path("id") conversationId: String, ) @FormUrlEncoded @@ -619,7 +619,7 @@ interface MastodonApi { @Field("context[]") context: List, @Field("irreversible") irreversible: Boolean?, @Field("whole_word") wholeWord: Boolean?, - @Field("expires_in") expiresInSeconds: Int? + @Field("expires_in") expiresInSeconds: Int?, ): NetworkResult @FormUrlEncoded @@ -630,12 +630,12 @@ interface MastodonApi { @Field("context[]") context: List, @Field("irreversible") irreversible: Boolean?, @Field("whole_word") wholeWord: Boolean?, - @Field("expires_in") expiresInSeconds: Int? + @Field("expires_in") expiresInSeconds: Int?, ): NetworkResult @DELETE("api/v1/filters/{id}") suspend fun deleteFilterV1( - @Path("id") id: String + @Path("id") id: String, ): NetworkResult @FormUrlEncoded @@ -644,7 +644,7 @@ interface MastodonApi { @Field("title") title: String, @Field("context[]") context: List, @Field("filter_action") filterAction: String, - @Field("expires_in") expiresInSeconds: Int? + @Field("expires_in") expiresInSeconds: Int?, ): NetworkResult @FormUrlEncoded @@ -654,12 +654,12 @@ interface MastodonApi { @Field("title") title: String? = null, @Field("context[]") context: List? = null, @Field("filter_action") filterAction: String? = null, - @Field("expires_in") expiresInSeconds: Int? = null + @Field("expires_in") expiresInSeconds: Int? = null, ): NetworkResult @DELETE("api/v2/filters/{id}") suspend fun deleteFilter( - @Path("id") id: String + @Path("id") id: String, ): NetworkResult @FormUrlEncoded @@ -667,7 +667,7 @@ interface MastodonApi { suspend fun addFilterKeyword( @Path("filterId") filterId: String, @Field("keyword") keyword: String, - @Field("whole_word") wholeWord: Boolean + @Field("whole_word") wholeWord: Boolean, ): NetworkResult @FormUrlEncoded @@ -675,41 +675,41 @@ interface MastodonApi { suspend fun updateFilterKeyword( @Path("keywordId") keywordId: String, @Field("keyword") keyword: String, - @Field("whole_word") wholeWord: Boolean + @Field("whole_word") wholeWord: Boolean, ): NetworkResult @DELETE("api/v2/filters/keywords/{keywordId}") suspend fun deleteFilterKeyword( - @Path("keywordId") keywordId: String + @Path("keywordId") keywordId: String, ): NetworkResult @FormUrlEncoded @POST("api/v1/polls/{id}/votes") suspend fun voteInPoll( @Path("id") id: String, - @Field("choices[]") choices: List + @Field("choices[]") choices: List, ): NetworkResult @GET("api/v1/announcements") suspend fun listAnnouncements( - @Query("with_dismissed") withDismissed: Boolean = true + @Query("with_dismissed") withDismissed: Boolean = true, ): NetworkResult> @POST("api/v1/announcements/{id}/dismiss") suspend fun dismissAnnouncement( - @Path("id") announcementId: String + @Path("id") announcementId: String, ): NetworkResult @PUT("api/v1/announcements/{id}/reactions/{name}") suspend fun addAnnouncementReaction( @Path("id") announcementId: String, - @Path("name") name: String + @Path("name") name: String, ): NetworkResult @DELETE("api/v1/announcements/{id}/reactions/{name}") suspend fun removeAnnouncementReaction( @Path("id") announcementId: String, - @Path("name") name: String + @Path("name") name: String, ): NetworkResult @FormUrlEncoded @@ -718,7 +718,7 @@ interface MastodonApi { @Field("account_id") accountId: String, @Field("status_ids[]") statusIds: List, @Field("comment") comment: String, - @Field("forward") isNotifyRemote: Boolean? + @Field("forward") isNotifyRemote: Boolean?, ): NetworkResult @GET("api/v1/accounts/{id}/statuses") @@ -728,12 +728,12 @@ interface MastodonApi { @Query("since_id") sinceId: String?, @Query("min_id") minId: String?, @Query("limit") limit: Int?, - @Query("exclude_reblogs") excludeReblogs: Boolean? + @Query("exclude_reblogs") excludeReblogs: Boolean?, ): Single> @GET("api/v1/statuses/{id}") fun statusObservable( - @Path("id") statusId: String + @Path("id") statusId: String, ): Single @GET("api/v2/search") @@ -743,7 +743,7 @@ interface MastodonApi { @Query("resolve") resolve: Boolean? = null, @Query("limit") limit: Int? = null, @Query("offset") offset: Int? = null, - @Query("following") following: Boolean? = null + @Query("following") following: Boolean? = null, ): Single @GET("api/v2/search") @@ -753,14 +753,14 @@ interface MastodonApi { @Query("resolve") resolve: Boolean? = null, @Query("limit") limit: Int? = null, @Query("offset") offset: Int? = null, - @Query("following") following: Boolean? = null + @Query("following") following: Boolean? = null, ): NetworkResult @FormUrlEncoded @POST("api/v1/accounts/{id}/note") suspend fun updateAccountNote( @Path("id") accountId: String, - @Field("comment") note: String + @Field("comment") note: String, ): NetworkResult @FormUrlEncoded @@ -774,7 +774,7 @@ interface MastodonApi { // The "data[alerts][]" fields to enable / disable notifications // Should be generated dynamically from all the available notification // types defined in [com.keylesspalace.tusky.entities.Notification.Types] - @FieldMap data: Map + @FieldMap data: Map, ): NetworkResult @FormUrlEncoded @@ -782,13 +782,13 @@ interface MastodonApi { suspend fun updatePushNotificationSubscription( @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, - @FieldMap data: Map + @FieldMap data: Map, ): NetworkResult @DELETE("api/v1/push/subscription") suspend fun unsubscribePushNotifications( @Header("Authorization") auth: String, - @Header(DOMAIN_HEADER) domain: String + @Header(DOMAIN_HEADER) domain: String, ): NetworkResult @GET("api/v1/tags/{name}") @@ -799,7 +799,7 @@ interface MastodonApi { @Query("min_id") minId: String? = null, @Query("since_id") sinceId: String? = null, @Query("max_id") maxId: String? = null, - @Query("limit") limit: Int? = null + @Query("limit") limit: Int? = null, ): Response> @POST("api/v1/tags/{name}/follow") diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MediaUploadApi.kt b/app/src/main/java/com/keylesspalace/tusky/network/MediaUploadApi.kt index 0cfab9b72..427b9a62e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MediaUploadApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MediaUploadApi.kt @@ -16,6 +16,6 @@ interface MediaUploadApi { suspend fun uploadMedia( @Part file: MultipartBody.Part, @Part description: MultipartBody.Part? = null, - @Part focus: MultipartBody.Part? = null + @Part focus: MultipartBody.Part? = null, ): Response } diff --git a/app/src/main/java/com/keylesspalace/tusky/pager/ImagePagerAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/pager/ImagePagerAdapter.kt index 26c5fc05a..5cbc1aa4f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/pager/ImagePagerAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/pager/ImagePagerAdapter.kt @@ -10,7 +10,7 @@ import java.lang.ref.WeakReference class ImagePagerAdapter( activity: FragmentActivity, private val attachments: List, - private val initialPosition: Int + private val initialPosition: Int, ) : ViewMediaAdapter(activity) { private var didTransition = false @@ -26,7 +26,7 @@ class ImagePagerAdapter( // transition and wait until it's over and it will never take place. val fragment = ViewMediaFragment.newInstance( attachment = attachments[position], - shouldStartPostponedTransition = !didTransition && position == initialPosition + shouldStartPostponedTransition = !didTransition && position == initialPosition, ) fragments[position] = WeakReference(fragment) return fragment diff --git a/app/src/main/java/com/keylesspalace/tusky/pager/SingleImagePagerAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/pager/SingleImagePagerAdapter.kt index c1f5342a3..97918a7fc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/pager/SingleImagePagerAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/pager/SingleImagePagerAdapter.kt @@ -7,7 +7,7 @@ import com.keylesspalace.tusky.fragment.ViewMediaFragment class SingleImagePagerAdapter( activity: FragmentActivity, - private val imageUrl: String + private val imageUrl: String, ) : ViewMediaAdapter(activity) { override fun createFragment(position: Int): Fragment { diff --git a/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt b/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt index 3ab941e9d..f1c5d88f6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt +++ b/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt @@ -97,8 +97,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() { idempotencyKey = randomAlphanumericString(16), retries = 0, language = null, - statusId = null - ) + statusId = null, + ), ) context.startService(sendIntent) diff --git a/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt b/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt index 3aaad1b70..6cc8beeb5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt @@ -196,7 +196,7 @@ class SendStatusService : Service(), Injectable { failOrRetry(throwable, statusId) return@launch - }) + },) } } } @@ -217,9 +217,9 @@ class SendStatusService : Service(), Injectable { id = media.id!!, description = media.description, focus = media.focus?.toMastodonApiString(), - thumbnail = null + thumbnail = null, ) - } + }, ) val sendResult = if (isNew) { @@ -227,7 +227,7 @@ class SendStatusService : Service(), Injectable { "Bearer " + account.accessToken, account.domain, statusToSend.idempotencyKey, - newStatus + newStatus, ) } else { mastodonApi.editStatus( @@ -235,7 +235,7 @@ class SendStatusService : Service(), Injectable { "Bearer " + account.accessToken, account.domain, statusToSend.idempotencyKey, - newStatus + newStatus, ) } @@ -262,7 +262,7 @@ class SendStatusService : Service(), Injectable { }, { throwable -> Log.w(TAG, "failed sending status", throwable) failOrRetry(throwable, statusId) - }) + },) stopSelfWhenDone() } } @@ -305,7 +305,7 @@ class SendStatusService : Service(), Injectable { R.string.send_post_notification_error_title, R.string.send_post_notification_saved_content, failedStatus.accountId, - statusId + statusId, ) notificationManager.cancel(statusId) @@ -330,7 +330,7 @@ class SendStatusService : Service(), Injectable { R.string.send_post_notification_cancel_title, R.string.send_post_notification_saved_content, statusToCancel.accountId, - statusId + statusId, ) notificationManager.notify(statusId, notification) @@ -358,7 +358,7 @@ class SendStatusService : Service(), Injectable { failedToSendAlert = failedToSendAlert, scheduledAt = status.scheduledAt, language = status.language, - statusId = status.statusId + statusId = status.statusId, ) } @@ -369,7 +369,7 @@ class SendStatusService : Service(), Injectable { this, statusId, intent, - NotificationHelper.pendingIntentFlags(false) + NotificationHelper.pendingIntentFlags(false), ) } @@ -377,7 +377,7 @@ class SendStatusService : Service(), Injectable { @StringRes title: Int, @StringRes content: Int, accountId: Long, - statusId: Int + statusId: Int, ): Notification { val intent = MainActivity.draftIntent(this, accountId) @@ -385,7 +385,7 @@ class SendStatusService : Service(), Injectable { this, statusId, intent, - NotificationHelper.pendingIntentFlags(false) + NotificationHelper.pendingIntentFlags(false), ) return NotificationCompat.Builder(this@SendStatusService, CHANNEL_ID) @@ -418,7 +418,7 @@ class SendStatusService : Service(), Injectable { fun sendStatusIntent( context: Context, - statusToSend: StatusToSend + statusToSend: StatusToSend, ): Intent { val intent = Intent(context, SendStatusService::class.java) intent.putExtra(KEY_STATUS, statusToSend) @@ -428,7 +428,7 @@ class SendStatusService : Service(), Injectable { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) val uriClip = ClipData( ClipDescription("Status Media", arrayOf("image/*", "video/*")), - ClipData.Item(statusToSend.media[0].uri) + ClipData.Item(statusToSend.media[0].uri), ) statusToSend.media .drop(1) @@ -461,7 +461,7 @@ data class StatusToSend( val idempotencyKey: String, var retries: Int, val language: String?, - val statusId: String? + val statusId: String?, ) : Parcelable @Parcelize @@ -471,5 +471,5 @@ data class MediaToSend( val uri: String, val description: String?, val focus: Attachment.Focus?, - var processed: Boolean + var processed: Boolean, ) : Parcelable diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt index a95134414..7bd067306 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceDataStore.kt @@ -13,7 +13,7 @@ import javax.inject.Inject class AccountPreferenceDataStore @Inject constructor( private val accountManager: AccountManager, private val eventHub: EventHub, - @ApplicationScope private val externalScope: CoroutineScope + @ApplicationScope private val externalScope: CoroutineScope, ) : PreferenceDataStore() { private val account: AccountEntity = accountManager.activeAccount!! diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt b/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt index fbe8084bc..09920d7b9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt @@ -4,7 +4,7 @@ import java.net.IDN class ProxyConfiguration private constructor( val hostname: String, - val port: Int + val port: Int, ) { companion object { fun create(hostname: String, port: Int): ProxyConfiguration? { @@ -18,7 +18,7 @@ class ProxyConfiguration private constructor( true } else { value.runCatching(String::toInt).map( - PROXY_RANGE::contains + PROXY_RANGE::contains, ).getOrDefault(false) } is Int -> PROXY_RANGE.contains(value) diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt index 837eb16d6..27a85262e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt @@ -5,7 +5,8 @@ enum class AppTheme(val value: String) { DAY("day"), BLACK("black"), AUTO("auto"), - AUTO_SYSTEM("auto_system"); + AUTO_SYSTEM("auto_system"), + ; companion object { fun stringValues() = values().map { it.value }.toTypedArray() diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsDSL.kt b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsDSL.kt index cb8b13e67..a00b2045a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/SettingsDSL.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/SettingsDSL.kt @@ -18,7 +18,7 @@ import de.c1710.filemojicompat_ui.views.picker.preference.EmojiPickerPreference class PreferenceParent( val context: Context, - val addPref: (pref: Preference) -> Unit + val addPref: (pref: Preference) -> Unit, ) inline fun PreferenceParent.preference(builder: Preference.() -> Unit): Preference { @@ -44,7 +44,7 @@ inline fun PreferenceParent.emojiPreference(activity: A, builder: EmojiPicke } inline fun PreferenceParent.sliderPreference( - builder: SliderPreference.() -> Unit + builder: SliderPreference.() -> Unit, ): SliderPreference { val pref = SliderPreference(context) builder(pref) @@ -53,7 +53,7 @@ inline fun PreferenceParent.sliderPreference( } inline fun PreferenceParent.switchPreference( - builder: SwitchPreference.() -> Unit + builder: SwitchPreference.() -> Unit, ): SwitchPreference { val pref = SwitchPreference(context) builder(pref) @@ -64,7 +64,7 @@ inline fun PreferenceParent.switchPreference( inline fun PreferenceParent.validatedEditTextPreference( errorMessage: String?, crossinline isValid: (a: String) -> Boolean, - builder: EditTextPreference.() -> Unit + builder: EditTextPreference.() -> Unit, ): EditTextPreference { val pref = EditTextPreference(context) pref.setOnBindEditTextListener { editText -> @@ -87,7 +87,7 @@ inline fun PreferenceParent.validatedEditTextPreference( inline fun PreferenceParent.preferenceCategory( @StringRes title: Int? = null, - builder: PreferenceParent.(PreferenceCategory) -> Unit + builder: PreferenceParent.(PreferenceCategory) -> Unit, ) { val category = PreferenceCategory(context) addPref(category) @@ -97,7 +97,7 @@ inline fun PreferenceParent.preferenceCategory( } inline fun PreferenceFragmentCompat.makePreferenceScreen( - builder: PreferenceParent.() -> Unit + builder: PreferenceParent.() -> Unit, ): PreferenceScreen { val context = requireContext() val screen = preferenceManager.createPreferenceScreen(context) diff --git a/app/src/main/java/com/keylesspalace/tusky/usecase/DeveloperToolsUseCase.kt b/app/src/main/java/com/keylesspalace/tusky/usecase/DeveloperToolsUseCase.kt index c7da0aed5..a4e6bf3a9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/usecase/DeveloperToolsUseCase.kt +++ b/app/src/main/java/com/keylesspalace/tusky/usecase/DeveloperToolsUseCase.kt @@ -27,7 +27,7 @@ import javax.inject.Inject * in debug mode. */ class DeveloperToolsUseCase @Inject constructor( - private val db: AppDatabase + private val db: AppDatabase, ) { private var timelineDao: TimelineDao = db.timelineDao() diff --git a/app/src/main/java/com/keylesspalace/tusky/usecase/LogoutUsecase.kt b/app/src/main/java/com/keylesspalace/tusky/usecase/LogoutUsecase.kt index f8d3b11ca..e5070fdf1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/usecase/LogoutUsecase.kt +++ b/app/src/main/java/com/keylesspalace/tusky/usecase/LogoutUsecase.kt @@ -15,7 +15,7 @@ class LogoutUsecase @Inject constructor( private val api: MastodonApi, private val db: AppDatabase, private val accountManager: AccountManager, - private val draftHelper: DraftHelper + private val draftHelper: DraftHelper, ) { /** @@ -33,7 +33,7 @@ class LogoutUsecase @Inject constructor( api.revokeOAuthToken( clientId = clientId, clientSecret = clientSecret, - token = activeAccount.accessToken + token = activeAccount.accessToken, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt b/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt index fc6ccbf3d..488debedd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt +++ b/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt @@ -45,7 +45,7 @@ import javax.inject.Inject class TimelineCases @Inject constructor( private val mastodonApi: MastodonApi, - private val eventHub: EventHub + private val eventHub: EventHub, ) { suspend fun reblog(statusId: String, reblog: Boolean): NetworkResult { @@ -123,7 +123,7 @@ class TimelineCases @Inject constructor( }, { e -> Log.w(TAG, "Failed to change pin state", e) NetworkResult.failure(TimelineError(e.getServerErrorMessage())) - }) + },) } suspend fun voteInPoll(statusId: String, pollId: String, choices: List): NetworkResult { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/AlertDialogExtensions.kt b/app/src/main/java/com/keylesspalace/tusky/util/AlertDialogExtensions.kt index b79671a53..d6585a4f1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/AlertDialogExtensions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/AlertDialogExtensions.kt @@ -34,7 +34,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine suspend fun AlertDialog.await( positiveText: String, negativeText: String? = null, - neutralText: String? = null + neutralText: String? = null, ) = suspendCancellableCoroutine { cont -> val listener = DialogInterface.OnClickListener { _, which -> cont.resume(which) { dismiss() } @@ -55,9 +55,9 @@ suspend fun AlertDialog.await( suspend fun AlertDialog.await( @StringRes positiveTextResource: Int, @StringRes negativeTextResource: Int? = null, - @StringRes neutralTextResource: Int? = null + @StringRes neutralTextResource: Int? = null, ) = await( context.getString(positiveTextResource), negativeTextResource?.let { context.getString(it) }, - neutralTextResource?.let { context.getString(it) } + neutralTextResource?.let { context.getString(it) }, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/AsciiFolding.kt b/app/src/main/java/com/keylesspalace/tusky/util/AsciiFolding.kt index 8f1101d29..995ced7b6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/AsciiFolding.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/AsciiFolding.kt @@ -18,7 +18,7 @@ package com.keylesspalace.tusky.util // Inspired by https://github.com/mastodon/mastodon/blob/main/app/lib/ascii_folding.rb val unicodeToASCIIMap = "ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž".toList().zip( - "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz".toList() + "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz".toList(), ).toMap() fun normalizeToASCII(text: CharSequence): CharSequence { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/BindingHolder.kt b/app/src/main/java/com/keylesspalace/tusky/util/BindingHolder.kt index 62167ee6a..1db9b5a38 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/BindingHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/BindingHolder.kt @@ -4,5 +4,5 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewbinding.ViewBinding class BindingHolder( - val binding: T + val binding: T, ) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/BlurHashDecoder.kt b/app/src/main/java/com/keylesspalace/tusky/util/BlurHashDecoder.kt index 117f59c09..fc58cbdd0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/BlurHashDecoder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/BlurHashDecoder.kt @@ -76,7 +76,7 @@ object BlurHashDecoder { return floatArrayOf( signedPow2((r - 9) / 9.0f) * maxAc, signedPow2((g - 9) / 9.0f) * maxAc, - signedPow2((b - 9) / 9.0f) * maxAc + signedPow2((b - 9) / 9.0f) * maxAc, ) } @@ -87,7 +87,7 @@ object BlurHashDecoder { height: Int, numCompX: Int, numCompY: Int, - colors: Array + colors: Array, ): Bitmap { val imageArray = IntArray(width * height) for (y in 0 until height) { @@ -124,7 +124,7 @@ object BlurHashDecoder { 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', - '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~' + '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~', ) .mapIndexed { i, c -> c to i } .toMap() diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CardViewMode.kt b/app/src/main/java/com/keylesspalace/tusky/util/CardViewMode.kt index 81c2216b0..6f8b45e2e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CardViewMode.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CardViewMode.kt @@ -3,5 +3,5 @@ package com.keylesspalace.tusky.util enum class CardViewMode { NONE, FULL_WIDTH, - INDENTED + INDENTED, } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CombinedLoadStatesExtensions.kt b/app/src/main/java/com/keylesspalace/tusky/util/CombinedLoadStatesExtensions.kt index 18c061c71..d6b82bbb2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CombinedLoadStatesExtensions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CombinedLoadStatesExtensions.kt @@ -49,7 +49,9 @@ enum class PresentationState { ERROR, /** The first request page of results is visible via the adapter */ - PRESENTED; + PRESENTED, + + ; /** * Take the next step in the PresentationState state machine, given [loadState] @@ -118,7 +120,9 @@ enum class UserRefreshState { COMPLETE, /** A refresh or prepend operation was [LoadState.Error] */ - ERROR; + ERROR, + + ; } /** diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CompositeWithOpaqueBackground.kt b/app/src/main/java/com/keylesspalace/tusky/util/CompositeWithOpaqueBackground.kt index e053e4e3f..0630eeec2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CompositeWithOpaqueBackground.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CompositeWithOpaqueBackground.kt @@ -73,7 +73,7 @@ class CompositeWithOpaqueBackground(val view: View) : BitmapTransformation() { pool: BitmapPool, toTransform: Bitmap, outWidth: Int, - outHeight: Int + outHeight: Int, ): Bitmap { // If the input bitmap has no alpha channel then there's nothing to do if (!toTransform.hasAlpha()) return toTransform @@ -137,9 +137,9 @@ class CompositeWithOpaqueBackground(val view: View) : BitmapTransformation() { 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, - 0f, 0f, 0f, 255f, 0f - ) - ) + 0f, 0f, 0f, 255f, 0f, + ), + ), ) isAntiAlias = false } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CustomFragmentStateAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/util/CustomFragmentStateAdapter.kt index eb31032f5..7f34ca968 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CustomFragmentStateAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CustomFragmentStateAdapter.kt @@ -20,7 +20,7 @@ import androidx.fragment.app.FragmentActivity import androidx.viewpager2.adapter.FragmentStateAdapter abstract class CustomFragmentStateAdapter( - private val activity: FragmentActivity + private val activity: FragmentActivity, ) : FragmentStateAdapter(activity) { fun getFragment(position: Int): Fragment? = diff --git a/app/src/main/java/com/keylesspalace/tusky/util/EmbeddedFontFamily.kt b/app/src/main/java/com/keylesspalace/tusky/util/EmbeddedFontFamily.kt index 0f4327811..905b72cc0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/EmbeddedFontFamily.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/EmbeddedFontFamily.kt @@ -28,7 +28,8 @@ enum class EmbeddedFontFamily(@FontRes val font: Int, @StyleRes val style: Int) ESTEDAD(R.font.estedad, R.style.FontEstedad), LEXEND(R.font.lexend, R.style.FontLexend), LUCIOLE(R.font.luciole, R.style.FontLuciole), - OPENDYSLEXIC(R.font.opendyslexic, R.style.FontOpenDyslexic); + OPENDYSLEXIC(R.font.opendyslexic, R.style.FontOpenDyslexic), + ; companion object { fun from(s: String?): EmbeddedFontFamily { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/FlowExtensions.kt b/app/src/main/java/com/keylesspalace/tusky/util/FlowExtensions.kt index 4da6fc381..dd4d69b26 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/FlowExtensions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/FlowExtensions.kt @@ -55,7 +55,7 @@ import kotlin.time.TimeSource */ fun Flow.throttleFirst( timeout: Duration, - timeSource: TimeSource = TimeSource.Monotonic + timeSource: TimeSource = TimeSource.Monotonic, ) = flow { var marker: TimeMark? = null collect { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt b/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt index 41d1034c7..12e084829 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/FocalPointUtil.kt @@ -59,7 +59,7 @@ object FocalPointUtil { imageWidth: Float, imageHeight: Float, focus: Focus, - mat: Matrix + mat: Matrix, ) { // Reset the cached matrix: mat.reset() @@ -89,7 +89,7 @@ object FocalPointUtil { viewWidth: Float, viewHeight: Float, imageWidth: Float, - imageHeight: Float + imageHeight: Float, ): Float { return if (isVerticalCrop(viewWidth, viewHeight, imageWidth, imageHeight)) { viewWidth / imageWidth @@ -105,7 +105,7 @@ object FocalPointUtil { viewWidth: Float, viewHeight: Float, imageWidth: Float, - imageHeight: Float + imageHeight: Float, ): Boolean { val viewRatio = viewWidth / viewHeight val imageRatio = imageWidth / imageHeight @@ -148,7 +148,7 @@ object FocalPointUtil { view: Float, image: Float, scale: Float, - focal: Float + focal: Float, ): Float { // The fraction of the image that will be in view: val inView = view / (scale * image) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt b/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt index b1734eddc..ecc679be5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt @@ -28,7 +28,7 @@ import androidx.core.net.toUri class HttpHeaderLink @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) constructor( - uri: String + uri: String, ) { data class Parameter(val name: String, val value: String?) @@ -126,7 +126,7 @@ constructor( */ fun findByRelationType( links: List, - relationType: String + relationType: String, ): HttpHeaderLink? { return links.find { link -> link.parameters.any { parameter -> diff --git a/app/src/main/java/com/keylesspalace/tusky/util/IOUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/IOUtils.kt index ece76bdfd..005554bfa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/IOUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/IOUtils.kt @@ -36,7 +36,7 @@ fun Closeable?.closeQuietly() { fun Uri.copyToFile( contentResolver: ContentResolver, - file: File + file: File, ): Boolean { val from: InputStream? val to: FileOutputStream diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt index 0979f5964..be9c4735f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt @@ -21,7 +21,7 @@ fun loadAvatar( imageView: ImageView, @Px radius: Int, animate: Boolean, - transforms: List>? = null + transforms: List>? = null, ) { if (url.isNullOrBlank()) { Glide.with(imageView) @@ -33,7 +33,7 @@ fun loadAvatar( transforms?.let { this.addAll(it) } add(centerCropTransformation) add(RoundedCorners(radius)) - } + }, ) if (animate) { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt index 04176a11e..1b0c45021 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt @@ -112,7 +112,7 @@ fun setClickableText( builder: SpannableStringBuilder, mentions: List, tags: List?, - listener: LinkListener + listener: LinkListener, ) = builder.apply { val start = getSpanStart(span) val end = getSpanEnd(span) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt b/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt index da057cbec..166cfceb9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt @@ -29,7 +29,7 @@ fun interface StatusProvider { class ListStatusAccessibilityDelegate( private val recyclerView: RecyclerView, private val statusActionListener: StatusActionListener, - private val statusProvider: StatusProvider + private val statusProvider: StatusProvider, ) : RecyclerViewAccessibilityDelegate(recyclerView) { private val a11yManager = context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager @@ -41,7 +41,7 @@ class ListStatusAccessibilityDelegate( private val itemDelegate = object : ItemDelegate(this) { override fun onInitializeAccessibilityNodeInfo( host: View, - info: AccessibilityNodeInfoCompat + info: AccessibilityNodeInfoCompat, ) { super.onInitializeAccessibilityNodeInfo(host, info) @@ -65,15 +65,15 @@ class ListStatusAccessibilityDelegate( R.id.action_open_media_1, R.id.action_open_media_2, R.id.action_open_media_3, - R.id.action_open_media_4 + R.id.action_open_media_4, ) val attachmentCount = min(actionable.attachments.size, MAX_MEDIA_ATTACHMENTS) for (i in 0 until attachmentCount) { info.addAction( AccessibilityActionCompat( mediaActions[i], - context.getString(R.string.action_open_media_n, i + 1) - ) + context.getString(R.string.action_open_media_n, i + 1), + ), ) } @@ -97,7 +97,7 @@ class ListStatusAccessibilityDelegate( override fun performAccessibilityAction( host: View, action: Int, - args: Bundle? + args: Bundle?, ): Boolean { val pos = recyclerView.getChildAdapterPosition(host) when (action) { @@ -114,7 +114,7 @@ class ListStatusAccessibilityDelegate( R.id.action_open_profile -> { interrupt() statusActionListener.onViewAccount( - (statusProvider.getStatus(pos) as StatusViewData).actionable.account.id + (statusProvider.getStatus(pos) as StatusViewData).actionable.account.id, ) } R.id.action_open_media_1 -> { @@ -180,8 +180,8 @@ class ListStatusAccessibilityDelegate( ArrayAdapter( host.context, android.R.layout.simple_list_item_1, - textLinks - ) + textLinks, + ), ) { _, which -> host.context.openLink(links[which].link) } .show() .let { forceFocus(it.listView) } @@ -197,8 +197,8 @@ class ListStatusAccessibilityDelegate( ArrayAdapter( host.context, android.R.layout.simple_list_item_1, - stringMentions - ) + stringMentions, + ), ) { _, which -> statusActionListener.onViewAccount(mentions[which].id) } @@ -215,8 +215,8 @@ class ListStatusAccessibilityDelegate( ArrayAdapter( host.context, android.R.layout.simple_list_item_1, - tags - ) + tags, + ), ) { _, which -> statusActionListener.onViewTag(tags[which].toString()) } @@ -237,7 +237,7 @@ class ListStatusAccessibilityDelegate( .map { span -> val text = content.subSequence( content.getSpanStart(span), - content.getSpanEnd(span) + content.getSpanEnd(span), ) if (isHashtag(text)) null else LinkSpanInfo(text.toString(), span.url) } @@ -272,87 +272,87 @@ class ListStatusAccessibilityDelegate( private val collapseCwAction = AccessibilityActionCompat( R.id.action_collapse_cw, - context.getString(R.string.post_content_warning_show_less) + context.getString(R.string.post_content_warning_show_less), ) private val expandCwAction = AccessibilityActionCompat( R.id.action_expand_cw, - context.getString(R.string.post_content_warning_show_more) + context.getString(R.string.post_content_warning_show_more), ) private val replyAction = AccessibilityActionCompat( R.id.action_reply, - context.getString(R.string.action_reply) + context.getString(R.string.action_reply), ) private val unreblogAction = AccessibilityActionCompat( R.id.action_unreblog, - context.getString(R.string.action_unreblog) + context.getString(R.string.action_unreblog), ) private val reblogAction = AccessibilityActionCompat( R.id.action_reblog, - context.getString(R.string.action_reblog) + context.getString(R.string.action_reblog), ) private val unfavouriteAction = AccessibilityActionCompat( R.id.action_unfavourite, - context.getString(R.string.action_unfavourite) + context.getString(R.string.action_unfavourite), ) private val favouriteAction = AccessibilityActionCompat( R.id.action_favourite, - context.getString(R.string.action_favourite) + context.getString(R.string.action_favourite), ) private val bookmarkAction = AccessibilityActionCompat( R.id.action_bookmark, - context.getString(R.string.action_bookmark) + context.getString(R.string.action_bookmark), ) private val unbookmarkAction = AccessibilityActionCompat( R.id.action_unbookmark, - context.getString(R.string.action_bookmark) + context.getString(R.string.action_bookmark), ) private val openProfileAction = AccessibilityActionCompat( R.id.action_open_profile, - context.getString(R.string.action_view_profile) + context.getString(R.string.action_view_profile), ) private val linksAction = AccessibilityActionCompat( R.id.action_links, - context.getString(R.string.action_links) + context.getString(R.string.action_links), ) private val mentionsAction = AccessibilityActionCompat( R.id.action_mentions, - context.getString(R.string.action_mentions) + context.getString(R.string.action_mentions), ) private val hashtagsAction = AccessibilityActionCompat( R.id.action_hashtags, - context.getString(R.string.action_hashtags) + context.getString(R.string.action_hashtags), ) private val openRebloggerAction = AccessibilityActionCompat( R.id.action_open_reblogger, - context.getString(R.string.action_open_reblogger) + context.getString(R.string.action_open_reblogger), ) private val openRebloggedByAction = AccessibilityActionCompat( R.id.action_open_reblogged_by, - context.getString(R.string.action_open_reblogged_by) + context.getString(R.string.action_open_reblogged_by), ) private val openFavsAction = AccessibilityActionCompat( R.id.action_open_faved_by, - context.getString(R.string.action_open_faved_by) + context.getString(R.string.action_open_faved_by), ) private val moreAction = AccessibilityActionCompat( R.id.action_more, - context.getString(R.string.action_more) + context.getString(R.string.action_more), ) private data class LinkSpanInfo(val text: String, val link: String) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LocaleExtensions.kt b/app/src/main/java/com/keylesspalace/tusky/util/LocaleExtensions.kt index 800e7a4e1..bf95a6f95 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LocaleExtensions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/LocaleExtensions.kt @@ -31,6 +31,6 @@ fun Locale.getTuskyDisplayName(context: Context): String { return context.getString( R.string.language_display_name_format, displayLanguage, - getDisplayLanguage(this) + getDisplayLanguage(this), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt b/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt index 8a5dc3d26..d2a3a48b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt @@ -29,7 +29,7 @@ import javax.inject.Singleton @Singleton class LocaleManager @Inject constructor( - val context: Context + val context: Context, ) : PreferenceDataStore() { private var prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt index b01200bb5..0e6c8bbbf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt @@ -135,7 +135,7 @@ fun reorientBitmap(bitmap: Bitmap?, orientation: Int): Bitmap? { bitmap.width, bitmap.height, matrix, - true + true, ) if (!bitmap.sameAs(result)) { bitmap.recycle() diff --git a/app/src/main/java/com/keylesspalace/tusky/util/Resource.kt b/app/src/main/java/com/keylesspalace/tusky/util/Resource.kt index ddc88f45d..bd71bf3e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/Resource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/Resource.kt @@ -10,5 +10,5 @@ class Error ( override val data: T? = null, val errorMessage: String? = null, var consumed: Boolean = false, - val cause: Throwable? = null + val cause: Throwable? = null, ) : Resource(data) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt index 4b1235148..e21eb2644 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt @@ -43,14 +43,14 @@ private val finders = mapOf( FoundMatchType.HTTP_URL to PatternFinder(':', HTTP_URL_REGEX, 5, Character::isWhitespace), FoundMatchType.HTTPS_URL to PatternFinder(':', HTTPS_URL_REGEX, 6, Character::isWhitespace), FoundMatchType.TAG to PatternFinder('#', TAG_REGEX, 1, ::isValidForTagPrefix), - FoundMatchType.MENTION to PatternFinder('@', MENTION_REGEX, 1, Character::isWhitespace) // TODO: We also need a proper validator for mentions + FoundMatchType.MENTION to PatternFinder('@', MENTION_REGEX, 1, Character::isWhitespace), // TODO: We also need a proper validator for mentions ) private enum class FoundMatchType { HTTP_URL, HTTPS_URL, TAG, - MENTION + MENTION, } private class FindCharsResult { @@ -63,7 +63,7 @@ private class PatternFinder( val searchCharacter: Char, regex: String, val searchPrefixWidth: Int, - val prefixValidator: (Int) -> Boolean + val prefixValidator: (Int) -> Boolean, ) { val pattern: Pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE) } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StatusDisplayOptions.kt b/app/src/main/java/com/keylesspalace/tusky/util/StatusDisplayOptions.kt index 21b89693d..2bd5f7812 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusDisplayOptions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusDisplayOptions.kt @@ -47,7 +47,7 @@ data class StatusDisplayOptions( @get:JvmName("showSensitiveMedia") val showSensitiveMedia: Boolean, @get:JvmName("openSpoiler") - val openSpoiler: Boolean + val openSpoiler: Boolean, ) { /** @@ -56,46 +56,46 @@ data class StatusDisplayOptions( fun make( preferences: SharedPreferences, key: String, - account: AccountEntity + account: AccountEntity, ) = when (key) { PrefKeys.ANIMATE_GIF_AVATARS -> copy( - animateAvatars = preferences.getBoolean(key, false) + animateAvatars = preferences.getBoolean(key, false), ) PrefKeys.MEDIA_PREVIEW_ENABLED -> copy( - mediaPreviewEnabled = account.mediaPreviewEnabled + mediaPreviewEnabled = account.mediaPreviewEnabled, ) PrefKeys.ABSOLUTE_TIME_VIEW -> copy( - useAbsoluteTime = preferences.getBoolean(key, false) + useAbsoluteTime = preferences.getBoolean(key, false), ) PrefKeys.SHOW_BOT_OVERLAY -> copy( - showBotOverlay = preferences.getBoolean(key, true) + showBotOverlay = preferences.getBoolean(key, true), ) PrefKeys.USE_BLURHASH -> copy( - useBlurhash = preferences.getBoolean(key, true) + useBlurhash = preferences.getBoolean(key, true), ) PrefKeys.SHOW_CARDS_IN_TIMELINES -> copy( - cardViewMode = if (preferences.getBoolean(key, false)) CardViewMode.INDENTED else CardViewMode.NONE + cardViewMode = if (preferences.getBoolean(key, false)) CardViewMode.INDENTED else CardViewMode.NONE, ) PrefKeys.CONFIRM_FAVOURITES -> copy( - confirmFavourites = preferences.getBoolean(key, false) + confirmFavourites = preferences.getBoolean(key, false), ) PrefKeys.CONFIRM_REBLOGS -> copy( - confirmReblogs = preferences.getBoolean(key, true) + confirmReblogs = preferences.getBoolean(key, true), ) PrefKeys.WELLBEING_HIDE_STATS_POSTS -> copy( - hideStats = preferences.getBoolean(key, false) + hideStats = preferences.getBoolean(key, false), ) PrefKeys.ANIMATE_CUSTOM_EMOJIS -> copy( - animateEmojis = preferences.getBoolean(key, false) + animateEmojis = preferences.getBoolean(key, false), ) PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA -> copy( - showSensitiveMedia = account.alwaysShowSensitiveMedia + showSensitiveMedia = account.alwaysShowSensitiveMedia, ) PrefKeys.ALWAYS_OPEN_SPOILER -> copy( - openSpoiler = account.alwaysOpenSpoiler + openSpoiler = account.alwaysOpenSpoiler, ) PrefKeys.SHOW_STATS_INLINE -> copy( - showStatsInline = preferences.getBoolean(key, false) + showStatsInline = preferences.getBoolean(key, false), ) else -> { this } } @@ -114,7 +114,7 @@ data class StatusDisplayOptions( PrefKeys.SHOW_BOT_OVERLAY, PrefKeys.USE_BLURHASH, PrefKeys.WELLBEING_HIDE_STATS_POSTS, - PrefKeys.SHOW_STATS_INLINE + PrefKeys.SHOW_STATS_INLINE, ) fun from(preferences: SharedPreferences, account: AccountEntity) = StatusDisplayOptions( @@ -134,7 +134,7 @@ data class StatusDisplayOptions( hideStats = preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false), showStatsInline = preferences.getBoolean(PrefKeys.SHOW_STATS_INLINE, false), showSensitiveMedia = account.alwaysShowSensitiveMedia, - openSpoiler = account.alwaysOpenSpoiler + openSpoiler = account.alwaysOpenSpoiler, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt index 2148a3b4c..9a2c0de28 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt @@ -51,21 +51,21 @@ class StatusViewHelper(private val itemView: View) { sensitive: Boolean, previewListener: MediaPreviewListener, showingContent: Boolean, - mediaPreviewHeight: Int + mediaPreviewHeight: Int, ) { val context = itemView.context val mediaPreviews = arrayOf( itemView.findViewById(R.id.status_media_preview_0), itemView.findViewById(R.id.status_media_preview_1), itemView.findViewById(R.id.status_media_preview_2), - itemView.findViewById(R.id.status_media_preview_3) + itemView.findViewById(R.id.status_media_preview_3), ) val mediaOverlays = arrayOf( itemView.findViewById(R.id.status_media_overlay_0), itemView.findViewById(R.id.status_media_overlay_1), itemView.findViewById(R.id.status_media_overlay_2), - itemView.findViewById(R.id.status_media_overlay_3) + itemView.findViewById(R.id.status_media_overlay_3), ) val sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning) @@ -191,7 +191,7 @@ class StatusViewHelper(private val itemView: View) { sensitive, previewListener, false, - mediaPreviewHeight + mediaPreviewHeight, ) } sensitiveMediaWarning.setOnClickListener { v -> @@ -204,7 +204,7 @@ class StatusViewHelper(private val itemView: View) { sensitive, previewListener, true, - mediaPreviewHeight + mediaPreviewHeight, ) } } @@ -219,7 +219,7 @@ class StatusViewHelper(private val itemView: View) { mediaLabel: TextView, attachments: List, sensitive: Boolean, - listener: MediaPreviewListener + listener: MediaPreviewListener, ) { if (attachments.isEmpty()) { mediaLabel.visibility = View.GONE @@ -267,7 +267,7 @@ class StatusViewHelper(private val itemView: View) { itemView.findViewById(R.id.status_poll_option_result_0), itemView.findViewById(R.id.status_poll_option_result_1), itemView.findViewById(R.id.status_poll_option_result_2), - itemView.findViewById(R.id.status_poll_option_result_3) + itemView.findViewById(R.id.status_poll_option_result_3), ) val pollDescription = itemView.findViewById(R.id.status_poll_description) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt index b13ed756c..35542c05b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.kt @@ -48,21 +48,21 @@ fun getDimension(context: Context, @AttrRes attribute: Int): Int { fun setDrawableTint(context: Context, drawable: Drawable, @AttrRes attribute: Int) { drawable.setColorFilter( MaterialColors.getColor(context, attribute, Color.BLACK), - PorterDuff.Mode.SRC_IN + PorterDuff.Mode.SRC_IN, ) } fun setAppNightMode(flavor: String?) { when (flavor) { THEME_NIGHT, THEME_BLACK -> AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_YES + AppCompatDelegate.MODE_NIGHT_YES, ) THEME_DAY -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) THEME_AUTO -> AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_AUTO_TIME + AppCompatDelegate.MODE_NIGHT_AUTO_TIME, ) THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, ) else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/TouchDelegateHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/TouchDelegateHelper.kt index a14101685..c28b88575 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/TouchDelegateHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/TouchDelegateHelper.kt @@ -45,7 +45,7 @@ fun ViewGroup.expandTouchSizeToFillRow(children: List) { rect.right += (right.left - view.right) / 2 } TouchDelegate(rect, view) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ViewBindingExtensions.kt b/app/src/main/java/com/keylesspalace/tusky/util/ViewBindingExtensions.kt index f398e2b6a..39bc98ff8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ViewBindingExtensions.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ViewBindingExtensions.kt @@ -17,38 +17,42 @@ import kotlin.reflect.KProperty */ inline fun AppCompatActivity.viewBinding( - crossinline bindingInflater: (LayoutInflater) -> T + crossinline bindingInflater: (LayoutInflater) -> T, ) = lazy(LazyThreadSafetyMode.NONE) { bindingInflater(layoutInflater) } class FragmentViewBindingDelegate( val fragment: Fragment, - val viewBindingFactory: (View) -> T + val viewBindingFactory: (View) -> T, ) : ReadOnlyProperty { private var binding: T? = null init { - fragment.lifecycle.addObserver(object : DefaultLifecycleObserver { - val viewLifecycleOwnerLiveDataObserver = - Observer { - val viewLifecycleOwner = it ?: return@Observer + fragment.lifecycle.addObserver( + object : DefaultLifecycleObserver { + val viewLifecycleOwnerLiveDataObserver = + Observer { + val viewLifecycleOwner = it ?: return@Observer - viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver { - override fun onDestroy(owner: LifecycleOwner) { - binding = null - } - }) + viewLifecycleOwner.lifecycle.addObserver( + object : DefaultLifecycleObserver { + override fun onDestroy(owner: LifecycleOwner) { + binding = null + } + }, + ) + } + + override fun onCreate(owner: LifecycleOwner) { + fragment.viewLifecycleOwnerLiveData.observeForever(viewLifecycleOwnerLiveDataObserver) } - override fun onCreate(owner: LifecycleOwner) { - fragment.viewLifecycleOwnerLiveData.observeForever(viewLifecycleOwnerLiveDataObserver) - } - - override fun onDestroy(owner: LifecycleOwner) { - fragment.viewLifecycleOwnerLiveData.removeObserver(viewLifecycleOwnerLiveDataObserver) - } - }) + override fun onDestroy(owner: LifecycleOwner) { + fragment.viewLifecycleOwnerLiveData.removeObserver(viewLifecycleOwnerLiveDataObserver) + } + }, + ) } override fun getValue(thisRef: Fragment, property: KProperty<*>): T { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt index 5e04c9072..d8bdb1b0a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt @@ -46,7 +46,7 @@ fun Status.toViewData( isExpanded: Boolean, isCollapsed: Boolean, isDetailed: Boolean = false, - filterAction: Filter.Action = Filter.Action.NONE + filterAction: Filter.Action = Filter.Action.NONE, ): StatusViewData { return StatusViewData( status = this, @@ -54,7 +54,7 @@ fun Status.toViewData( isCollapsed = isCollapsed, isExpanded = isExpanded, isDetailed = isDetailed, - filterAction = filterAction + filterAction = filterAction, ) } @@ -62,7 +62,7 @@ fun Notification.toViewData( isShowingContent: Boolean, isExpanded: Boolean, isCollapsed: Boolean, - filterAction: Filter.Action + filterAction: Filter.Action, ): NotificationViewData { return NotificationViewData( this.type, @@ -72,9 +72,9 @@ fun Notification.toViewData( isShowingContent, isExpanded, isCollapsed, - filterAction = filterAction + filterAction = filterAction, ), - this.report + this.report, ) } @@ -91,7 +91,7 @@ fun List.toViewData(): List { name = tag.name, usage = reversedHistory.mapNotNull { it.uses.toLongOrNull() }, accounts = reversedHistory.mapNotNull { it.accounts.toLongOrNull() }, - maxTrendingValue = maxTrendingValue + maxTrendingValue = maxTrendingValue, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/BackgroundMessageView.kt b/app/src/main/java/com/keylesspalace/tusky/view/BackgroundMessageView.kt index e24d79413..bc614b340 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/BackgroundMessageView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/BackgroundMessageView.kt @@ -23,7 +23,7 @@ import com.keylesspalace.tusky.util.visible class BackgroundMessageView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : LinearLayout(context, attrs, defStyleAttr) { private val binding = ViewBackgroundMessageBinding.inflate(LayoutInflater.from(context), this) @@ -44,7 +44,7 @@ class BackgroundMessageView @JvmOverloads constructor( fun setup( @DrawableRes imageRes: Int, @StringRes messageRes: Int, - clickListener: ((v: View) -> Unit)? = null + clickListener: ((v: View) -> Unit)? = null, ) = setup(imageRes, context.getString(messageRes), clickListener) /** @@ -54,7 +54,7 @@ class BackgroundMessageView @JvmOverloads constructor( fun setup( @DrawableRes imageRes: Int, message: String, - clickListener: ((v: View) -> Unit)? = null + clickListener: ((v: View) -> Unit)? = null, ) { binding.messageTextView.text = message binding.messageTextView.movementMethod = LinkMovementMethod.getInstance() diff --git a/app/src/main/java/com/keylesspalace/tusky/view/BezelImageView.kt b/app/src/main/java/com/keylesspalace/tusky/view/BezelImageView.kt index abd04fa9d..43aa2699d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/BezelImageView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/BezelImageView.kt @@ -29,7 +29,7 @@ import com.mikepenz.materialdrawer.view.BezelImageView class BezelImageView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyle: Int = 0 + defStyle: Int = 0, ) : BezelImageView(context, attrs, defStyle) { override fun onSizeChanged(w: Int, h: Int, old_w: Int, old_h: Int) { outlineProvider = CustomOutline(w, h) @@ -43,7 +43,7 @@ class BezelImageView @JvmOverloads constructor( 0, width, height, - if (width < height) width / 8f else height / 8f + if (width < height) width / 8f else height / 8f, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/ClickableSpanTextView.kt b/app/src/main/java/com/keylesspalace/tusky/view/ClickableSpanTextView.kt index cefef191b..ef8d9741e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/ClickableSpanTextView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/ClickableSpanTextView.kt @@ -52,7 +52,7 @@ import kotlin.math.abs class ClickableSpanTextView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = android.R.attr.textViewStyle + defStyleAttr: Int = android.R.attr.textViewStyle, ) : AppCompatTextView(context, attrs, defStyleAttr) { /** * Map of [RectF] that enclose the [ClickableSpan] without any additional touchable area. A span @@ -111,7 +111,7 @@ class ClickableSpanTextView @JvmOverloads constructor( text: CharSequence?, start: Int, lengthBefore: Int, - lengthAfter: Int + lengthAfter: Int, ) { super.onTextChanged(text, start, lengthBefore, lengthAfter) diff --git a/app/src/main/java/com/keylesspalace/tusky/view/EmojiPicker.kt b/app/src/main/java/com/keylesspalace/tusky/view/EmojiPicker.kt index 0a9bfbf7e..13aa1c9cf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/EmojiPicker.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/EmojiPicker.kt @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.RecyclerView class EmojiPicker @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null + attrs: AttributeSet? = null, ) : RecyclerView(context, attrs) { init { diff --git a/app/src/main/java/com/keylesspalace/tusky/view/FontFamilyDialogFragment.kt b/app/src/main/java/com/keylesspalace/tusky/view/FontFamilyDialogFragment.kt index 0a31e9526..c5fbe04de 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/FontFamilyDialogFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/FontFamilyDialogFragment.kt @@ -68,7 +68,7 @@ class FontFamilyDialogFragment : ListPreferenceDialogFragmentCompat() { null, R.styleable.AlertDialog, R.attr.alertDialogStyle, - 0 + 0, ) val layout = a.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, 0) a.recycle() diff --git a/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt b/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt index 2aecad08d..a60644142 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt @@ -32,7 +32,7 @@ import kotlin.math.max class GraphView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : View(context, attrs, defStyleAttr) { @get:ColorInt @ColorInt @@ -75,7 +75,7 @@ class GraphView @JvmOverloads constructor( 80, 130, 190, - 80 + 80, ) } else { listOf( @@ -85,7 +85,7 @@ class GraphView @JvmOverloads constructor( 1, 1, 1, - 1 + 1, ) } set(value) { @@ -102,7 +102,7 @@ class GraphView @JvmOverloads constructor( 60, 100, 132, - 20 + 20, ) } else { listOf( @@ -112,7 +112,7 @@ class GraphView @JvmOverloads constructor( 1, 1, 1, - 1 + 1, ) } set(value) { @@ -130,39 +130,39 @@ class GraphView @JvmOverloads constructor( primaryLineColor = context.getColor( a.getResourceId( R.styleable.GraphView_primaryLineColor, - R.color.tusky_blue - ) + R.color.tusky_blue, + ), ) secondaryLineColor = context.getColor( a.getResourceId( R.styleable.GraphView_secondaryLineColor, - R.color.tusky_red - ) + R.color.tusky_red, + ), ) lineWidth = a.getDimensionPixelSize( R.styleable.GraphView_lineWidth, - R.dimen.graph_line_thickness + R.dimen.graph_line_thickness, ).toFloat() graphColor = context.getColor( a.getResourceId( R.styleable.GraphView_graphColor, - R.color.colorBackground - ) + R.color.colorBackground, + ), ) metaColor = context.getColor( a.getResourceId( R.styleable.GraphView_metaColor, - R.color.dividerColor - ) + R.color.dividerColor, + ), ) proportionalTrending = a.getBoolean( R.styleable.GraphView_proportionalTrending, - proportionalTrending + proportionalTrending, ) } @@ -284,7 +284,7 @@ class GraphView @JvmOverloads constructor( height.toFloat(), i * pointDistance, height - (height.toFloat() / 20), - metaPaint + metaPaint, ) } @@ -297,14 +297,14 @@ class GraphView @JvmOverloads constructor( linePath = secondaryLinePath, linePaint = secondaryLinePaint, circlePaint = secondaryCirclePaint, - lineThickness = lineWidth + lineThickness = lineWidth, ) drawLine( canvas = canvas, linePath = primaryLinePath, linePaint = primaryLinePaint, circlePaint = primaryCirclePaint, - lineThickness = lineWidth + lineThickness = lineWidth, ) } } @@ -314,12 +314,12 @@ class GraphView @JvmOverloads constructor( linePath: Path, linePaint: Paint, circlePaint: Paint, - lineThickness: Float + lineThickness: Float, ) { canvas.apply { drawPath( linePath, - linePaint + linePaint, ) val pm = PathMeasure(linePath, false) diff --git a/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt b/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt index 394cd3692..93009d2ca 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt @@ -31,7 +31,7 @@ class LicenseCard @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : MaterialCardView(context, attrs, defStyleAttr) { init { @@ -43,12 +43,12 @@ class LicenseCard attrs, R.styleable.LicenseCard, 0, - 0 + 0, ).use { a -> Triple( a.getString(R.styleable.LicenseCard_name), a.getString(R.styleable.LicenseCard_license), - a.getString(R.styleable.LicenseCard_link) + a.getString(R.styleable.LicenseCard_link), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt b/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt index 717bd1441..09bec98b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt @@ -41,7 +41,7 @@ open class MediaPreviewImageView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + defStyleAttr: Int = 0, ) : AppCompatImageView(context, attrs, defStyleAttr), RequestListener { private var focus: Attachment.Focus? = null private var focalMatrix: Matrix? = null @@ -124,7 +124,7 @@ open class MediaPreviewImageView drawable.intrinsicWidth.toFloat(), drawable.intrinsicHeight.toFloat(), focus as Attachment.Focus, - focalMatrix as Matrix + focalMatrix as Matrix, ) imageMatrix = focalMatrix } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewLayout.kt b/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewLayout.kt index 854b72009..21d50fdd6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewLayout.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewLayout.kt @@ -116,7 +116,7 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) : super.onMeasure( widthMeasureSpec, - MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY) + MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY), ) } @@ -136,7 +136,7 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) : 0, y + spacing, width, - y + spacing + getChildAt(1).measuredHeight + y + spacing + getChildAt(1).measuredHeight, ) } else { getChildAt(0).layout(0, 0, halfWidth, height) @@ -158,7 +158,7 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) : halfWidth + spacing, halfHeight + spacing, width, - colHeight + colHeight, ) } } @@ -172,13 +172,13 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) : 0, topHeight + spacing, halfWidth, - topHeight + spacing + bottomHeight + topHeight + spacing + bottomHeight, ) getChildAt(3).layout( halfWidth + spacing, topHeight + spacing, width, - topHeight + spacing + bottomHeight + topHeight + spacing + bottomHeight, ) } } @@ -190,7 +190,7 @@ class MediaPreviewLayout(context: Context, attrs: AttributeSet? = null) : action( index, wrapper.findViewById(R.id.preview_image_view) as MediaPreviewImageView, - wrapper.findViewById(R.id.preview_media_description_indicator) as TextView + wrapper.findViewById(R.id.preview_media_description_indicator) as TextView, ) } } @@ -209,6 +209,6 @@ private fun View.measureToAspect(width: Int, aspect: Double): Int { private fun View.measureExactly(width: Int, height: Int) { measure( View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY), - View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY) + View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY), ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/view/MuteAccountDialog.kt b/app/src/main/java/com/keylesspalace/tusky/view/MuteAccountDialog.kt index 715fa6033..bc4e1db55 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/MuteAccountDialog.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/MuteAccountDialog.kt @@ -10,7 +10,7 @@ import com.keylesspalace.tusky.databinding.DialogMuteAccountBinding fun showMuteAccountDialog( activity: Activity, accountUsername: String, - onOk: (notifications: Boolean, duration: Int?) -> Unit + onOk: (notifications: Boolean, duration: Int?) -> Unit, ) { val binding = DialogMuteAccountBinding.inflate(activity.layoutInflater) binding.warning.text = activity.getString(R.string.dialog_mute_warning, accountUsername) diff --git a/app/src/main/java/com/keylesspalace/tusky/view/SliderPreference.kt b/app/src/main/java/com/keylesspalace/tusky/view/SliderPreference.kt index f435afbe2..b24555eba 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/SliderPreference.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/SliderPreference.kt @@ -50,7 +50,7 @@ class SliderPreference @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = androidx.preference.R.attr.preferenceStyle, - defStyleRes: Int = 0 + defStyleRes: Int = 0, ) : Preference(context, attrs, defStyleAttr, defStyleRes), Slider.OnChangeListener, Slider.OnSliderTouchListener { diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/AttachmentViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/AttachmentViewData.kt index 998cc96a4..ba3df147b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/AttachmentViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/AttachmentViewData.kt @@ -27,7 +27,7 @@ data class AttachmentViewData( val statusId: String, val statusUrl: String, val sensitive: Boolean, - val isRevealed: Boolean + val isRevealed: Boolean, ) : Parcelable { @IgnoredOnParcel @@ -43,7 +43,7 @@ data class AttachmentViewData( statusId = actionable.id, statusUrl = actionable.url!!, sensitive = actionable.sensitive, - isRevealed = alwaysShowSensitiveMedia || !actionable.sensitive + isRevealed = alwaysShowSensitiveMedia || !actionable.sensitive, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.kt index c96039b14..24f8bf28c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.kt @@ -26,5 +26,5 @@ data class NotificationViewData( val id: String, val account: TimelineAccount, var statusViewData: StatusViewData?, - val report: Report? + val report: Report?, ) diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt index 7281bf060..0d3ece873 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt @@ -33,14 +33,14 @@ data class PollViewData( val votesCount: Int, val votersCount: Int?, val options: List, - var voted: Boolean + var voted: Boolean, ) data class PollOptionViewData( val title: String, var votesCount: Int, var selected: Boolean, - var voted: Boolean + var voted: Boolean, ) fun calculatePercent(fraction: Int, totalVoters: Int?, totalVotes: Int): Int { @@ -72,7 +72,7 @@ fun Poll?.toViewData(): PollViewData? { votesCount = votesCount, votersCount = votersCount, options = options.mapIndexed { index, option -> option.toViewData(ownVotes?.contains(index) == true) }, - voted = voted + voted = voted, ) } @@ -81,6 +81,6 @@ fun PollOption.toViewData(voted: Boolean): PollOptionViewData { title = title, votesCount = votesCount, selected = false, - voted = voted + voted = voted, ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt index 1980e95b6..c4ae4ec1e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt @@ -46,7 +46,7 @@ data class StatusViewData( val isDetailed: Boolean = false, /** Whether this status should be filtered, and if so, how */ - var filterAction: Filter.Action = Filter.Action.NONE + var filterAction: Filter.Action = Filter.Action.NONE, ) { val id: String get() = status.id diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt index 6eae73319..e0ac43557 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt @@ -22,7 +22,7 @@ sealed class TrendingViewData { data class Header( val start: Date, - val end: Date + val end: Date, ) : TrendingViewData() { override val id: String get() = start.toString() + end.toString() @@ -32,7 +32,7 @@ sealed class TrendingViewData { val name: String, val usage: List, val accounts: List, - val maxTrendingValue: Long + val maxTrendingValue: Long, ) : TrendingViewData() { override val id: String get() = name diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt index aafe4ce05..2b578d7a1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt @@ -48,7 +48,7 @@ class AccountsInListViewModel @Inject constructor(private val api: MastodonApi) }, { e -> updateState { copy(accounts = Left(e)) } - } + }, ) } } @@ -66,9 +66,9 @@ class AccountsInListViewModel @Inject constructor(private val api: MastodonApi) { Log.i( javaClass.simpleName, - "Failed to add account to list: ${account.username}" + "Failed to add account to list: ${account.username}", ) - } + }, ) } } @@ -82,16 +82,16 @@ class AccountsInListViewModel @Inject constructor(private val api: MastodonApi) copy( accounts = accounts.map { accounts -> accounts.withoutFirstWhich { it.id == accountId } - } + }, ) } }, { Log.i( javaClass.simpleName, - "Failed to remove account from list: $accountId" + "Failed to remove account from list: $accountId", ) - } + }, ) } } @@ -108,7 +108,7 @@ class AccountsInListViewModel @Inject constructor(private val api: MastodonApi) }, { updateState { copy(searchResult = listOf()) } - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt index 55de04be4..88db1adb1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt @@ -54,14 +54,14 @@ internal data class ProfileDataInUi( val displayName: String, val note: String, val locked: Boolean, - val fields: List + val fields: List, ) class EditProfileViewModel @Inject constructor( private val mastodonApi: MastodonApi, private val eventHub: EventHub, private val application: Application, - private val instanceInfoRepo: InstanceInfoRepository + private val instanceInfoRepo: InstanceInfoRepository, ) : ViewModel() { val profileData = MutableLiveData>() @@ -85,7 +85,7 @@ class EditProfileViewModel @Inject constructor( }, { profileData.postValue(Error()) - } + }, ) } } @@ -140,7 +140,7 @@ class EditProfileViewModel @Inject constructor( diff.field3?.first?.toRequestBody(MultipartBody.FORM), diff.field3?.second?.toRequestBody(MultipartBody.FORM), diff.field4?.first?.toRequestBody(MultipartBody.FORM), - diff.field4?.second?.toRequestBody(MultipartBody.FORM) + diff.field4?.second?.toRequestBody(MultipartBody.FORM), ).fold( { newAccountData -> saveData.postValue(Success()) @@ -148,7 +148,7 @@ class EditProfileViewModel @Inject constructor( }, { throwable -> saveData.postValue(Error(errorMessage = throwable.getServerErrorMessage())) - } + }, ) } } @@ -160,7 +160,7 @@ class EditProfileViewModel @Inject constructor( val newProfile = profileData.value?.data?.copy( displayName = newProfileData.displayName, locked = newProfileData.locked, - source = newProfileSource + source = newProfileSource, ) profileData.value = Success(newProfile) @@ -212,7 +212,7 @@ class EditProfileViewModel @Inject constructor( val field4 = calculateFieldToUpdate(newProfileData.fields.getOrNull(3), allFieldsUnchanged) return DiffProfileData( - displayName, note, locked, field1, field2, field3, field4, headerFile, avatarFile + displayName, note, locked, field1, field2, field3, field4, headerFile, avatarFile, ) } @@ -222,7 +222,7 @@ class EditProfileViewModel @Inject constructor( } return Pair( newField.name, - newField.value + newField.value, ) } @@ -239,7 +239,7 @@ class EditProfileViewModel @Inject constructor( val field3: Pair?, val field4: Pair?, val headerFile: File?, - val avatarFile: File? + val avatarFile: File?, ) { fun hasChanges() = displayName != null || note != null || locked != null || avatarFile != null || headerFile != null || field1 != null || field2 != null || diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt index e13328a90..39424e354 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt @@ -65,7 +65,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) updateState { copy( lists = lists, - loadingState = LoadingState.LOADED + loadingState = LoadingState.LOADED, ) } }, @@ -76,10 +76,10 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) LoadingState.ERROR_NETWORK } else { LoadingState.ERROR_OTHER - } + }, ) } - } + }, ) } } @@ -94,7 +94,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) }, { sendEvent(Event.CREATE_ERROR) - } + }, ) } } @@ -109,7 +109,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) }, { sendEvent(Event.UPDATE_ERROR) - } + }, ) } } @@ -124,7 +124,7 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) }, { sendEvent(Event.DELETE_ERROR) - } + }, ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/worker/NotificationWorker.kt b/app/src/main/java/com/keylesspalace/tusky/worker/NotificationWorker.kt index b7b769d11..920997a2f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/worker/NotificationWorker.kt +++ b/app/src/main/java/com/keylesspalace/tusky/worker/NotificationWorker.kt @@ -32,7 +32,7 @@ import javax.inject.Inject class NotificationWorker( appContext: Context, params: WorkerParameters, - private val notificationsFetcher: NotificationFetcher + private val notificationsFetcher: NotificationFetcher, ) : CoroutineWorker(appContext, params) { val notification: Notification = NotificationHelper.createWorkerNotification(applicationContext, R.string.notification_notification_worker) @@ -44,7 +44,7 @@ class NotificationWorker( override suspend fun getForegroundInfo() = ForegroundInfo(NOTIFICATION_ID_FETCH_NOTIFICATION, notification) class Factory @Inject constructor( - private val notificationsFetcher: NotificationFetcher + private val notificationsFetcher: NotificationFetcher, ) : ChildWorkerFactory { override fun createWorker(appContext: Context, params: WorkerParameters): CoroutineWorker { return NotificationWorker(appContext, params, notificationsFetcher) diff --git a/app/src/main/java/com/keylesspalace/tusky/worker/PruneCacheWorker.kt b/app/src/main/java/com/keylesspalace/tusky/worker/PruneCacheWorker.kt index 870e77655..37448030b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/worker/PruneCacheWorker.kt +++ b/app/src/main/java/com/keylesspalace/tusky/worker/PruneCacheWorker.kt @@ -36,7 +36,7 @@ class PruneCacheWorker( appContext: Context, workerParams: WorkerParameters, private val appDatabase: AppDatabase, - private val accountManager: AccountManager + private val accountManager: AccountManager, ) : CoroutineWorker(appContext, workerParams) { val notification: Notification = NotificationHelper.createWorkerNotification(applicationContext, R.string.notification_prune_cache) @@ -58,7 +58,7 @@ class PruneCacheWorker( class Factory @Inject constructor( private val appDatabase: AppDatabase, - private val accountManager: AccountManager + private val accountManager: AccountManager, ) : ChildWorkerFactory { override fun createWorker(appContext: Context, params: WorkerParameters): ListenableWorker { return PruneCacheWorker(appContext, params, appDatabase, accountManager) diff --git a/app/src/main/java/com/keylesspalace/tusky/worker/WorkerFactory.kt b/app/src/main/java/com/keylesspalace/tusky/worker/WorkerFactory.kt index bb9a0bb1a..bd76312f3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/worker/WorkerFactory.kt +++ b/app/src/main/java/com/keylesspalace/tusky/worker/WorkerFactory.kt @@ -43,12 +43,12 @@ interface ChildWorkerFactory { */ @Singleton class WorkerFactory @Inject constructor( - private val workerFactories: Map, @JvmSuppressWildcards Provider> + private val workerFactories: Map, @JvmSuppressWildcards Provider>, ) : WorkerFactory() { override fun createWorker( appContext: Context, workerClassName: String, - workerParameters: WorkerParameters + workerParameters: WorkerParameters, ): ListenableWorker? { val key = try { Class.forName(workerClassName) diff --git a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt index 18db7b63d..88b767747 100644 --- a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt @@ -58,7 +58,7 @@ class BottomSheetActivityTest { displayName = "Ad Min", note = "This is their bio", url = "http://mastodon.foo.bar/@User", - avatar = "" + avatar = "", ) private val accountSingle = Single.just(SearchResult(listOf(account), emptyList(), emptyList())) @@ -91,7 +91,7 @@ class BottomSheetActivityTest { poll = null, card = null, language = null, - filtered = null + filtered = null, ) private val statusSingle = Single.just(SearchResult(emptyList(), listOf(status), emptyList())) diff --git a/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt b/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt index a3e5c8979..4a7dc54b3 100644 --- a/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt +++ b/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt @@ -51,7 +51,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = null, irreversible = false, - wholeWord = false + wholeWord = false, ), FilterV1( id = "123", @@ -59,7 +59,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME, FilterV1.PUBLIC), expiresAt = null, irreversible = false, - wholeWord = true + wholeWord = true, ), FilterV1( id = "123", @@ -67,7 +67,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = null, irreversible = false, - wholeWord = true + wholeWord = true, ), FilterV1( id = "123", @@ -75,7 +75,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = null, irreversible = false, - wholeWord = true + wholeWord = true, ), FilterV1( id = "123", @@ -83,7 +83,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = Date.from(Instant.now().minusSeconds(10)), irreversible = false, - wholeWord = true + wholeWord = true, ), FilterV1( id = "123", @@ -91,7 +91,7 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = Date.from(Instant.now().plusSeconds(3600)), irreversible = false, - wholeWord = true + wholeWord = true, ), FilterV1( id = "123", @@ -99,8 +99,8 @@ class FilterV1Test { context = listOf(FilterV1.HOME), expiresAt = null, irreversible = false, - wholeWord = false - ) + wholeWord = false, + ), ) filterModel.initWithFilters(filters) @@ -111,8 +111,8 @@ class FilterV1Test { assertEquals( Filter.Action.NONE, filterModel.shouldFilterStatus( - mockStatus(content = "should not be filtered") - ) + mockStatus(content = "should not be filtered"), + ), ) } @@ -121,8 +121,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "one two badWord three") - ) + mockStatus(content = "one two badWord three"), + ), ) } @@ -131,8 +131,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "one two badWordPart three") - ) + mockStatus(content = "one two badWordPart three"), + ), ) } @@ -141,8 +141,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "one two badWholeWord three") - ) + mockStatus(content = "one two badWholeWord three"), + ), ) } @@ -151,8 +151,8 @@ class FilterV1Test { assertEquals( Filter.Action.NONE, filterModel.shouldFilterStatus( - mockStatus(content = "one two badWholeWordTest three") - ) + mockStatus(content = "one two badWholeWordTest three"), + ), ) } @@ -163,9 +163,9 @@ class FilterV1Test { filterModel.shouldFilterStatus( mockStatus( content = "should not be filtered", - spoilerText = "badWord should be filtered" - ) - ) + spoilerText = "badWord should be filtered", + ), + ), ) } @@ -177,9 +177,9 @@ class FilterV1Test { mockStatus( content = "should not be filtered", spoilerText = "should not be filtered", - pollOptions = listOf("should not be filtered", "badWord") - ) - ) + pollOptions = listOf("should not be filtered", "badWord"), + ), + ), ) } @@ -191,9 +191,9 @@ class FilterV1Test { mockStatus( content = "should not be filtered", spoilerText = "should not be filtered", - attachmentsDescriptions = listOf("should not be filtered", "badWord") - ) - ) + attachmentsDescriptions = listOf("should not be filtered", "badWord"), + ), + ), ) } @@ -202,8 +202,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "one two someone@twitter.com three") - ) + mockStatus(content = "one two someone@twitter.com three"), + ), ) } @@ -212,8 +212,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "#hashtag one two three") - ) + mockStatus(content = "#hashtag one two three"), + ), ) } @@ -222,8 +222,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "

#hashtagone two three

") - ) + mockStatus(content = "

#hashtagone two three

"), + ), ) } @@ -232,8 +232,8 @@ class FilterV1Test { assertEquals( Filter.Action.NONE, filterModel.shouldFilterStatus( - mockStatus(content = "

https://foo.bar/ one two three

") - ) + mockStatus(content = "

https://foo.bar/ one two three

"), + ), ) } @@ -242,8 +242,8 @@ class FilterV1Test { assertEquals( Filter.Action.NONE, filterModel.shouldFilterStatus( - mockStatus(content = "content matching expired filter should not be filtered") - ) + mockStatus(content = "content matching expired filter should not be filtered"), + ), ) } @@ -252,8 +252,8 @@ class FilterV1Test { assertEquals( Filter.Action.HIDE, filterModel.shouldFilterStatus( - mockStatus(content = "content matching unexpired filter should be filtered") - ) + mockStatus(content = "content matching unexpired filter should be filtered"), + ), ) } @@ -278,7 +278,7 @@ class FilterV1Test { content: String = "", spoilerText: String = "", pollOptions: List? = null, - attachmentsDescriptions: List? = null + attachmentsDescriptions: List? = null, ): Status { return Status( id = "123", @@ -310,9 +310,9 @@ class FilterV1Test { meta = null, type = Attachment.Type.IMAGE, description = it, - blurhash = null + blurhash = null, ) - } + }, ) } else { arrayListOf() @@ -334,14 +334,14 @@ class FilterV1Test { PollOption(it, 0) }, voted = false, - ownVotes = null + ownVotes = null, ) } else { null }, card = null, language = null, - filtered = null + filtered = null, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt b/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt index 89bcf7add..f3e0da979 100644 --- a/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt @@ -53,8 +53,8 @@ class FocalPointUtilTest { 2f, 1f, 1f, - 2f - ) + 2f, + ), ) } @@ -65,8 +65,8 @@ class FocalPointUtilTest { 1f, 2f, 2f, - 1f - ) + 1f, + ), ) } @@ -76,7 +76,7 @@ class FocalPointUtilTest { 3f, 1f, 6f, - 2f + 2f, ) } @@ -88,10 +88,10 @@ class FocalPointUtilTest { 2f, 5f, 5f, - 12.5f + 12.5f, ), 0.4f, - eps + eps, ) } @@ -102,10 +102,10 @@ class FocalPointUtilTest { 2f, 5f, 1f, - 2.5f + 2.5f, ), 2f, - eps + eps, ) } @@ -116,10 +116,10 @@ class FocalPointUtilTest { 2f, 1f, 1f, - 2f + 2f, ), 2f, - eps + eps, ) } @@ -130,10 +130,10 @@ class FocalPointUtilTest { 4f, 3f, 8f, - 24f + 24f, ), 0.5f, - eps + eps, ) } @@ -144,10 +144,10 @@ class FocalPointUtilTest { 1f, 2f, 2f, - 1f + 1f, ), 2f, - eps + eps, ) } @@ -158,10 +158,10 @@ class FocalPointUtilTest { 3f, 4f, 24f, - 8f + 8f, ), 0.5f, - eps + eps, ) } @@ -171,7 +171,7 @@ class FocalPointUtilTest { assertEquals( FocalPointUtil.focalOffset(2f, 8f, 1f, 0.05f), 0f, - eps + eps, ) } @@ -180,7 +180,7 @@ class FocalPointUtilTest { assertEquals( FocalPointUtil.focalOffset(2f, 4f, 2f, 0.95f), -6f, - eps + eps, ) } @@ -189,7 +189,7 @@ class FocalPointUtilTest { assertEquals( FocalPointUtil.focalOffset(2f, 4f, 2f, 0.7f), -4.6f, - eps + eps, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt index 8ad20a411..e3188d212 100644 --- a/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt @@ -43,7 +43,7 @@ class MainActivityTest { note = "", url = "", avatar = "", - header = "" + header = "", ) private val accountEntity = AccountEntity( id = 1, @@ -51,7 +51,7 @@ class MainActivityTest { accessToken = "fakeToken", clientId = "fakeId", clientSecret = "fakeSecret", - isActive = true + isActive = true, ) @Before @@ -103,13 +103,13 @@ class MainActivityTest { displayName = "Conny Duck", note = "This is their bio", url = "https://mastodon.example/@ConnyDuck", - avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg" + avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg", ), status = null, - report = null + report = null, ), accountEntity, - true + true, ) notificationManager.notify("id", 1, notification) } diff --git a/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt index 45e6187a5..71c5aa646 100644 --- a/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt @@ -40,7 +40,7 @@ class SpanUtilsTest { "#tag", "#tåg", "https://thr.ee/meh?foo=bar&wat=@at#hmm", - "http://thr.ee/meh?foo=bar&wat=@at#hmm" + "http://thr.ee/meh?foo=bar&wat=@at#hmm", ) } } @@ -98,7 +98,7 @@ class SpanUtilsTest { class HighlightingTestsForTag( private val text: String, private val expectedStartIndex: Int, - private val expectedEndIndex: Int + private val expectedEndIndex: Int, ) { companion object { @Parameterized.Parameters(name = "{0}") @@ -111,7 +111,7 @@ class SpanUtilsTest { arrayOf("@#after_at", 1, 10), arrayOf("あいうえお#after_hiragana", 5, 20), arrayOf("##DoubleHash", 1, 12), - arrayOf("###TripleHash", 2, 13) + arrayOf("###TripleHash", 2, 13), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/StatusComparisonTest.kt b/app/src/test/java/com/keylesspalace/tusky/StatusComparisonTest.kt index 92ba990c9..0f2625f61 100644 --- a/app/src/test/java/com/keylesspalace/tusky/StatusComparisonTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/StatusComparisonTest.kt @@ -45,13 +45,13 @@ class StatusComparisonTest { status = createStatus(), isExpanded = false, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) val viewdata2 = StatusViewData( status = createStatus(), isExpanded = false, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) assertEquals(viewdata1, viewdata2) } @@ -62,13 +62,13 @@ class StatusComparisonTest { status = createStatus(), isExpanded = true, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) val viewdata2 = StatusViewData( status = createStatus(), isExpanded = false, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) assertNotEquals(viewdata1, viewdata2) } @@ -79,13 +79,13 @@ class StatusComparisonTest { status = createStatus(content = "whatever"), isExpanded = true, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) val viewdata2 = StatusViewData( status = createStatus(), isExpanded = false, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) assertNotEquals(viewdata1, viewdata2) } @@ -95,7 +95,7 @@ class StatusComparisonTest { content: String = """ \u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"https://mastodon.social/@ConnyDuck\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"\u003e@\u003cspan\u003eConnyDuck@mastodon.social\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e Hi\u003c/p\u003e """.trimIndent(), - note: String = "" + note: String = "", ): Status { val statusJson = """ { diff --git a/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt index 518af95f6..bc5eb2454 100644 --- a/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt @@ -13,11 +13,11 @@ class StringUtilsTest { "abc" to "bcd", "ab" to "abc", "cb" to "abc", - "1" to "2" + "1" to "2", ) lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThan(r)) } val notLessList = lessList.map { (l, r) -> r to l } + listOf( - "abc" to "abc" + "abc" to "abc", ) notLessList.forEach { (l, r) -> assertFalse("not $l < $r", l.isLessThan(r)) } } @@ -29,7 +29,7 @@ class StringUtilsTest { "ab" to "abc", "cb" to "abc", "1" to "2", - "abc" to "abc" + "abc" to "abc", ) lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThanOrEqual(r)) } val notLessList = lessList.filterNot { (l, r) -> l == r }.map { (l, r) -> r to l } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/ComposeActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/ComposeActivityTest.kt index f16355b57..cd3a34a08 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/ComposeActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/ComposeActivityTest.kt @@ -85,7 +85,7 @@ class ComposeActivityTest { notificationsFavorited = true, notificationSound = true, notificationVibration = true, - notificationLight = true + notificationLight = true, ) private var instanceResponseCallback: (() -> Instance)? = null private var composeOptions: ComposeActivity.ComposeOptions? = null @@ -129,7 +129,7 @@ class ComposeActivityTest { mock(), mock(), mock(), - instanceInfoRepo + instanceInfoRepo, ) activity.intent = Intent(activity, ComposeActivity::class.java).apply { putExtra(ComposeActivity.COMPOSE_OPTIONS_EXTRA, composeOptions) @@ -501,7 +501,7 @@ class ComposeActivityTest { maxMediaAttachments = null, pleroma = null, uploadLimit = null, - rules = emptyList() + rules = emptyList(), ) } @@ -510,10 +510,10 @@ class ComposeActivityTest { statuses = StatusConfiguration( maxCharacters = maximumStatusCharacters, maxMediaAttachments = null, - charactersReservedPerUrl = charactersReservedPerUrl + charactersReservedPerUrl = charactersReservedPerUrl, ), mediaAttachments = null, - polls = null + polls = null, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/StatusLengthTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/StatusLengthTest.kt index 672d1711c..6c91e3150 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/StatusLengthTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivity/StatusLengthTest.kt @@ -28,7 +28,7 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) class StatusLengthTest( private val text: String, - private val expectedLength: Int + private val expectedLength: Int, ) { companion object { @Parameterized.Parameters(name = "{0}") @@ -47,7 +47,7 @@ class StatusLengthTest( // Short hashtags are treated as is arrayOf("123 #basictag", 13), // Long hashtags are *also* treated as is (not treated as 23, like URLs) - arrayOf("123 #atagthatislongerthan23characters", 37) + arrayOf("123 #atagthatislongerthan23characters", 37), ) } } @@ -59,7 +59,7 @@ class StatusLengthTest( assertEquals( expectedLength, - ComposeActivity.statusLength(spannedText, null, 23) + ComposeActivity.statusLength(spannedText, null, 23), ) } @@ -69,11 +69,11 @@ class StatusLengthTest( highlightSpans(spannedText, 0) val cwText = SpanUtilsTest.FakeSpannable( - "a @example@example.org #hashtagmention and http://example.org URL" + "a @example@example.org #hashtagmention and http://example.org URL", ) assertEquals( expectedLength + cwText.length, - ComposeActivity.statusLength(spannedText, cwText, 23) + ComposeActivity.statusLength(spannedText, cwText, 23), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeTokenizer/ComposeTokenizerTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeTokenizer/ComposeTokenizerTest.kt index 04c692bce..77405e7e9 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeTokenizer/ComposeTokenizerTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeTokenizer/ComposeTokenizerTest.kt @@ -25,7 +25,7 @@ import org.junit.runners.Parameterized class ComposeTokenizerTest( private val text: CharSequence, private val expectedStartIndex: Int, - private val expectedEndIndex: Int + private val expectedEndIndex: Int, ) { companion object { @@ -81,7 +81,7 @@ class ComposeTokenizerTest( arrayOf("@:mastodon", 10, 10), arrayOf(" @:mastodon", 11, 11), arrayOf("#@:mastodon", 11, 11), - arrayOf(" #@:mastodon", 12, 12) + arrayOf(" #@:mastodon", 12, 12), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSourceTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSourceTest.kt index db067827c..1d581f335 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSourceTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingSourceTest.kt @@ -59,7 +59,7 @@ class NotificationsPagingSourceTest { assertTrue(loadResult is PagingSource.LoadResult.Error) assertEquals( "HTTP 429: This is an error", - (loadResult as PagingSource.LoadResult.Error).throwable.message + (loadResult as PagingSource.LoadResult.Error).throwable.message, ) } @@ -85,7 +85,7 @@ class NotificationsPagingSourceTest { assertTrue(loadResult is PagingSource.LoadResult.Error) assertEquals( "HTTP 429: This is an error: Description of the error", - (loadResult as PagingSource.LoadResult.Error).throwable.message + (loadResult as PagingSource.LoadResult.Error).throwable.message, ) } @@ -111,7 +111,7 @@ class NotificationsPagingSourceTest { assertTrue(loadResult is PagingSource.LoadResult.Error) assertEquals( "HTTP 429: no reason given", - (loadResult as PagingSource.LoadResult.Error).throwable.message + (loadResult as PagingSource.LoadResult.Error).throwable.message, ) } @@ -137,7 +137,7 @@ class NotificationsPagingSourceTest { assertTrue(loadResult is PagingSource.LoadResult.Error) assertEquals( "HTTP 429: {'malformedjson} (com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 17 path \$.)", - (loadResult as PagingSource.LoadResult.Error).throwable.message + (loadResult as PagingSource.LoadResult.Error).throwable.message, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestBase.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestBase.kt index 97fe05c33..036dbf85f 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestBase.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestBase.kt @@ -103,7 +103,7 @@ abstract class NotificationsViewModelTestBase { PrefKeys.CONFIRM_REBLOGS to true, PrefKeys.CONFIRM_FAVOURITES to false, PrefKeys.WELLBEING_HIDE_STATS_POSTS to false, - PrefKeys.FAB_HIDE to false + PrefKeys.FAB_HIDE to false, ) // Any getBoolean() call looks for the result in sharedPreferencesMap @@ -122,7 +122,7 @@ abstract class NotificationsViewModelTestBase { notificationsFilter = "['follow']", mediaPreviewEnabled = true, alwaysShowSensitiveMedia = true, - alwaysOpenSpoiler = true + alwaysOpenSpoiler = true, ) } eventHub = EventHub() @@ -137,7 +137,7 @@ abstract class NotificationsViewModelTestBase { timelineCases, eventHub, filtersRepository, - filterModel + filterModel, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestNotificationAction.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestNotificationAction.kt index c465d8bf4..3a654ea89 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestNotificationAction.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestNotificationAction.kt @@ -53,7 +53,7 @@ class NotificationsViewModelTestNotificationAction : NotificationsViewModelTestB subscribing = null, blockingDomain = false, note = null, - notifying = null + notifying = null, ) /** Action to accept a follow request */ diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusAction.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusAction.kt index 096de2b0e..6a2ecd007 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusAction.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusAction.kt @@ -45,7 +45,7 @@ class NotificationsViewModelTestStatusAction : NotificationsViewModelTestBase() status = status, isExpanded = true, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) /** Action to bookmark a status */ @@ -61,7 +61,7 @@ class NotificationsViewModelTestStatusAction : NotificationsViewModelTestBase() private val voteInPollAction = StatusAction.VoteInPoll( poll = status.poll!!, choices = listOf(1, 0, 0), - statusViewData + statusViewData, ) /** Captors for status ID and state arguments */ diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusDisplayOptions.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusDisplayOptions.kt index 2434e9233..5668705d0 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusDisplayOptions.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestStatusDisplayOptions.kt @@ -48,7 +48,7 @@ class NotificationsViewModelTestStatusDisplayOptions : NotificationsViewModelTes animateEmojis = false, showStatsInline = false, showSensitiveMedia = true, // setting in NotificationsViewModelTestBase - openSpoiler = true // setting in NotificationsViewModelTestBase + openSpoiler = true, // setting in NotificationsViewModelTestBase ) @Test @@ -71,7 +71,7 @@ class NotificationsViewModelTestStatusDisplayOptions : NotificationsViewModelTes val updatedOptions = defaultStatusDisplayOptions.make( sharedPreferences, PrefKeys.ANIMATE_GIF_AVATARS, - accountManager.activeAccount!! + accountManager.activeAccount!!, ) // Then, should be true diff --git a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestUiState.kt b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestUiState.kt index 59e6d537f..a2f83b396 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestUiState.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModelTestUiState.kt @@ -35,7 +35,7 @@ class NotificationsViewModelTestUiState : NotificationsViewModelTestBase() { private val initialUiState = UiState( activeFilter = setOf(Notification.Type.FOLLOW), - showFabWhileScrolling = true + showFabWhileScrolling = true, ) @Test diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRemoteMediatorTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRemoteMediatorTest.kt index 51013104c..fff4d6d03 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRemoteMediatorTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRemoteMediatorTest.kt @@ -54,7 +54,7 @@ class CachedTimelineRemoteMediatorTest { accessToken = "token", clientId = "id", clientSecret = "secret", - isActive = true + isActive = true, ) } @@ -91,7 +91,7 @@ class CachedTimelineRemoteMediatorTest { }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state()) } @@ -111,7 +111,7 @@ class CachedTimelineRemoteMediatorTest { }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state()) } @@ -128,19 +128,19 @@ class CachedTimelineRemoteMediatorTest { api = mock(), factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( listOf( PagingSource.LoadResult.Page( data = listOf( - mockStatusEntityWithAccount("3") + mockStatusEntityWithAccount("3"), ), prevKey = null, - nextKey = 1 - ) - ) + nextKey = 1, + ), + ), ) val result = runBlocking { remoteMediator.load(LoadType.PREPEND, state) } @@ -155,7 +155,7 @@ class CachedTimelineRemoteMediatorTest { val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1") + mockStatusEntityWithAccount("1"), ) db.insert(statusesAlreadyInDb) @@ -167,20 +167,20 @@ class CachedTimelineRemoteMediatorTest { listOf( mockStatus("8"), mockStatus("7"), - mockStatus("5") - ) + mockStatus("5"), + ), ) onBlocking { homeTimeline(maxId = "3", limit = 20) } doReturn Response.success( listOf( mockStatus("3"), mockStatus("2"), - mockStatus("1") - ) + mockStatus("1"), + ), ) }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( @@ -188,9 +188,9 @@ class CachedTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = statusesAlreadyInDb, prevKey = null, - nextKey = 0 - ) - ) + nextKey = 0, + ), + ), ) val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state) } @@ -205,8 +205,8 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("5"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1") - ) + mockStatusEntityWithAccount("1"), + ), ) } @@ -216,7 +216,7 @@ class CachedTimelineRemoteMediatorTest { val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1") + mockStatusEntityWithAccount("1"), ) db.insert(statusesAlreadyInDb) @@ -228,20 +228,20 @@ class CachedTimelineRemoteMediatorTest { listOf( mockStatus("6"), mockStatus("4"), - mockStatus("3") - ) + mockStatus("3"), + ), ) onBlocking { homeTimeline(maxId = "3", limit = 3) } doReturn Response.success( listOf( mockStatus("3"), mockStatus("2"), - mockStatus("1") - ) + mockStatus("1"), + ), ) }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( @@ -249,10 +249,10 @@ class CachedTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = statusesAlreadyInDb, prevKey = null, - nextKey = 0 - ) + nextKey = 0, + ), ), - pageSize = 3 + pageSize = 3, ) val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state) } @@ -266,8 +266,8 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("4"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1") - ) + mockStatusEntityWithAccount("1"), + ), ) } @@ -281,13 +281,13 @@ class CachedTimelineRemoteMediatorTest { listOf( mockStatus("5"), mockStatus("4"), - mockStatus("3") - ) + mockStatus("3"), + ), ) }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( @@ -295,9 +295,9 @@ class CachedTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = emptyList(), prevKey = null, - nextKey = 0 - ) - ) + nextKey = 0, + ), + ), ) val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state) } @@ -309,8 +309,8 @@ class CachedTimelineRemoteMediatorTest { listOf( mockStatusEntityWithAccount("5"), mockStatusEntityWithAccount("4"), - mockStatusEntityWithAccount("3") - ) + mockStatusEntityWithAccount("3"), + ), ) } @@ -322,7 +322,7 @@ class CachedTimelineRemoteMediatorTest { val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3", expanded = true), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1", expanded = false) + mockStatusEntityWithAccount("1", expanded = false), ) db.insert(statusesAlreadyInDb) @@ -333,13 +333,13 @@ class CachedTimelineRemoteMediatorTest { onBlocking { homeTimeline(limit = 20) } doReturn Response.success( listOf( mockStatus("3"), - mockStatus("1") - ) + mockStatus("1"), + ), ) }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( @@ -347,9 +347,9 @@ class CachedTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = statusesAlreadyInDb, prevKey = null, - nextKey = 0 - ) - ) + nextKey = 0, + ), + ), ) // When @@ -363,8 +363,8 @@ class CachedTimelineRemoteMediatorTest { // id="2" was in the database initially, but not in the results returned // from the API, so it should have been deleted here. mockStatusEntityWithAccount("3", expanded = true), - mockStatusEntityWithAccount("1", expanded = false) - ) + mockStatusEntityWithAccount("1", expanded = false), + ), ) } @@ -374,7 +374,7 @@ class CachedTimelineRemoteMediatorTest { val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("8"), mockStatusEntityWithAccount("7"), - mockStatusEntityWithAccount("5") + mockStatusEntityWithAccount("5"), ) db.insert(statusesAlreadyInDb) @@ -388,16 +388,16 @@ class CachedTimelineRemoteMediatorTest { listOf( mockStatus("3"), mockStatus("2"), - mockStatus("1") + mockStatus("1"), ), Headers.Builder().add( - "Link: ; rel=\"prev\", ; rel=\"next\"" - ).build() + "Link: ; rel=\"prev\", ; rel=\"next\"", + ).build(), ) }, factory = pagingSourceFactory, db = db, - gson = Gson() + gson = Gson(), ) val state = state( @@ -405,9 +405,9 @@ class CachedTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = statusesAlreadyInDb, prevKey = null, - nextKey = 0 - ) - ) + nextKey = 0, + ), + ), ) val result = runBlocking { remoteMediator.load(LoadType.APPEND, state) } @@ -421,21 +421,21 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("5"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1") - ) + mockStatusEntityWithAccount("1"), + ), ) } private fun state( pages: List> = emptyList(), - pageSize: Int = 20 + pageSize: Int = 20, ) = PagingState( pages = pages, anchorPosition = null, config = PagingConfig( - pageSize = pageSize + pageSize = pageSize, ), - leadingPlaceholderCount = 0 + leadingPlaceholderCount = 0, ) private fun AppDatabase.insert(statuses: List) { @@ -454,7 +454,7 @@ class CachedTimelineRemoteMediatorTest { private fun AppDatabase.assertStatuses( expected: List, - forAccount: Long = 1 + forAccount: Long = 1, ) { val pagingSource = timelineDao().getStatuses(forAccount) diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestBase.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestBase.kt index d4d43cc60..35f4aea42 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestBase.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestBase.kt @@ -93,7 +93,7 @@ abstract class CachedTimelineViewModelTestBase { PrefKeys.CONFIRM_REBLOGS to true, PrefKeys.CONFIRM_FAVOURITES to false, PrefKeys.WELLBEING_HIDE_STATS_POSTS to false, - PrefKeys.FAB_HIDE to false + PrefKeys.FAB_HIDE to false, ) // Any getBoolean() call looks for the result in sharedPreferencesMap @@ -105,7 +105,7 @@ abstract class CachedTimelineViewModelTestBase { accountPreferencesMap = mutableMapOf( PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA to false, PrefKeys.ALWAYS_OPEN_SPOILER to false, - PrefKeys.MEDIA_PREVIEW_ENABLED to true + PrefKeys.MEDIA_PREVIEW_ENABLED to true, ) // Any getBoolean() call looks for the result in accountPreferencesMap. @@ -130,7 +130,7 @@ abstract class CachedTimelineViewModelTestBase { notificationsFilter = "['follow']", mediaPreviewEnabled = true, alwaysShowSensitiveMedia = true, - alwaysOpenSpoiler = true + alwaysOpenSpoiler = true, ) } eventHub = EventHub() @@ -147,7 +147,7 @@ abstract class CachedTimelineViewModelTestBase { sharedPreferences, accountPreferenceDataStore, filterModel, - Gson() + Gson(), ) // Initialisation with the Home timeline diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusAction.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusAction.kt index 886692743..0fcb5e79a 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusAction.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusAction.kt @@ -52,7 +52,7 @@ class CachedTimelineViewModelTestStatusAction : CachedTimelineViewModelTestBase( status = status, isExpanded = true, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) /** Action to bookmark a status */ @@ -68,7 +68,7 @@ class CachedTimelineViewModelTestStatusAction : CachedTimelineViewModelTestBase( private val voteInPollAction = StatusAction.VoteInPoll( poll = status.poll!!, choices = listOf(1, 0, 0), - statusViewData + statusViewData, ) /** Captors for status ID and state arguments */ diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusDisplayOptions.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusDisplayOptions.kt index 073c9eaf2..7eb056030 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusDisplayOptions.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestStatusDisplayOptions.kt @@ -52,7 +52,7 @@ class CachedTimelineViewModelTestStatusDisplayOptions : CachedTimelineViewModelT animateEmojis = false, showStatsInline = false, showSensitiveMedia = true, // setting in NotificationsViewModelTestBase - openSpoiler = true // setting in NotificationsViewModelTestBase + openSpoiler = true, // setting in NotificationsViewModelTestBase ) @Test @@ -75,7 +75,7 @@ class CachedTimelineViewModelTestStatusDisplayOptions : CachedTimelineViewModelT val updatedOptions = defaultStatusDisplayOptions.make( sharedPreferences, PrefKeys.ANIMATE_GIF_AVATARS, - accountManager.activeAccount!! + accountManager.activeAccount!!, ) // Then, should be true diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestUiState.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestUiState.kt index e9f198598..96a641869 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestUiState.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineViewModelTestUiState.kt @@ -37,7 +37,7 @@ class CachedTimelineViewModelTestUiState : CachedTimelineViewModelTestBase() { private val initialUiState = UiState( showFabWhileScrolling = true, - showMediaPreview = true + showMediaPreview = true, ) @Test diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelinePagingSourceTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelinePagingSourceTest.kt index fdbc0b1aa..6c7e2d26e 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelinePagingSourceTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelinePagingSourceTest.kt @@ -53,8 +53,8 @@ class NetworkTimelinePagingSourceTest { prevKey = null, nextKey = null, itemsBefore = 0, - itemsAfter = 0 - ) + itemsAfter = 0, + ), ) } @@ -80,8 +80,8 @@ class NetworkTimelinePagingSourceTest { prevKey = "2", nextKey = "0", itemsBefore = 1, - itemsAfter = 1 - ) + itemsAfter = 1, + ), ) } @@ -107,8 +107,8 @@ class NetworkTimelinePagingSourceTest { prevKey = "2", nextKey = "0", itemsBefore = 1, - itemsAfter = 1 - ) + itemsAfter = 1, + ), ) } @@ -134,8 +134,8 @@ class NetworkTimelinePagingSourceTest { prevKey = "2", nextKey = "0", itemsBefore = 1, - itemsAfter = 1 - ) + itemsAfter = 1, + ), ) } @@ -161,8 +161,8 @@ class NetworkTimelinePagingSourceTest { prevKey = null, nextKey = "1", itemsBefore = 0, - itemsAfter = 2 - ) + itemsAfter = 2, + ), ) } @@ -188,8 +188,8 @@ class NetworkTimelinePagingSourceTest { prevKey = null, nextKey = null, itemsBefore = 0, - itemsAfter = 0 - ) + itemsAfter = 0, + ), ) } @@ -215,8 +215,8 @@ class NetworkTimelinePagingSourceTest { prevKey = null, nextKey = null, itemsBefore = 0, - itemsAfter = 0 - ) + itemsAfter = 0, + ), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRemoteMediatorTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRemoteMediatorTest.kt index fbc5bc3b0..4d150e220 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRemoteMediatorTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineRemoteMediatorTest.kt @@ -59,7 +59,7 @@ class NetworkTimelineRemoteMediatorTest { accessToken = "token", clientId = "id", clientSecret = "secret", - isActive = true + isActive = true, ) } @@ -80,7 +80,7 @@ class NetworkTimelineRemoteMediatorTest { accountManager = accountManager, factory = pagingSourceFactory, pageCache = PageCache(), - timelineKind = TimelineKind.Home + timelineKind = TimelineKind.Home, ) // When @@ -102,7 +102,7 @@ class NetworkTimelineRemoteMediatorTest { accountManager, factory = pagingSourceFactory, pageCache = PageCache(), - timelineKind = TimelineKind.Home + timelineKind = TimelineKind.Home, ) // When @@ -125,14 +125,14 @@ class NetworkTimelineRemoteMediatorTest { listOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), Headers.headersOf( "Link", - "; rel=\"next\", ; rel=\"prev\"" - ) + "; rel=\"next\", ; rel=\"prev\"", + ), ) }, accountManager = accountManager, factory = pagingSourceFactory, pageCache = pages, - timelineKind = TimelineKind.Home + timelineKind = TimelineKind.Home, ) val state = state( @@ -140,9 +140,9 @@ class NetworkTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = emptyList(), prevKey = null, - nextKey = null - ) - ) + nextKey = null, + ), + ), ) // When @@ -154,8 +154,8 @@ class NetworkTimelineRemoteMediatorTest { Page( data = mutableListOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) + nextKey = "5", + ), ) } @@ -176,8 +176,8 @@ class NetworkTimelineRemoteMediatorTest { Page( data = mutableListOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) + nextKey = "5", + ), ) } @@ -188,14 +188,14 @@ class NetworkTimelineRemoteMediatorTest { listOf(mockStatus("10"), mockStatus("9"), mockStatus("8")), Headers.headersOf( "Link", - "; rel=\"next\", ; rel=\"prev\"" - ) + "; rel=\"next\", ; rel=\"prev\"", + ), ) }, accountManager = accountManager, factory = pagingSourceFactory, pageCache = pages, - timelineKind = TimelineKind.Home + timelineKind = TimelineKind.Home, ) val state = state( @@ -203,9 +203,9 @@ class NetworkTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = listOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) - ) + nextKey = "5", + ), + ), ) // When @@ -217,15 +217,15 @@ class NetworkTimelineRemoteMediatorTest { Page( data = mutableListOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) + nextKey = "5", + ), ) upsert( Page( data = mutableListOf(mockStatus("10"), mockStatus("9"), mockStatus("8")), prevKey = "10", - nextKey = "8" - ) + nextKey = "8", + ), ) } @@ -246,8 +246,8 @@ class NetworkTimelineRemoteMediatorTest { Page( data = mutableListOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) + nextKey = "5", + ), ) } @@ -258,14 +258,14 @@ class NetworkTimelineRemoteMediatorTest { listOf(mockStatus("4"), mockStatus("3"), mockStatus("2")), Headers.headersOf( "Link", - "; rel=\"next\", ; rel=\"prev\"" - ) + "; rel=\"next\", ; rel=\"prev\"", + ), ) }, accountManager = accountManager, factory = pagingSourceFactory, pageCache = pages, - timelineKind = TimelineKind.Home + timelineKind = TimelineKind.Home, ) val state = state( @@ -273,9 +273,9 @@ class NetworkTimelineRemoteMediatorTest { PagingSource.LoadResult.Page( data = listOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) - ) + nextKey = "5", + ), + ), ) // When @@ -287,15 +287,15 @@ class NetworkTimelineRemoteMediatorTest { Page( data = mutableListOf(mockStatus("7"), mockStatus("6"), mockStatus("5")), prevKey = "7", - nextKey = "5" - ) + nextKey = "5", + ), ) upsert( Page( data = mutableListOf(mockStatus("4"), mockStatus("3"), mockStatus("2")), prevKey = "4", - nextKey = "2" - ) + nextKey = "2", + ), ) } @@ -316,9 +316,9 @@ class NetworkTimelineRemoteMediatorTest { anchorPosition = null, config = PagingConfig( pageSize = PAGE_SIZE, - initialLoadSize = PAGE_SIZE + initialLoadSize = PAGE_SIZE, ), - leadingPlaceholderCount = 0 + leadingPlaceholderCount = 0, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestBase.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestBase.kt index c3d51b306..6f8c488b0 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestBase.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestBase.kt @@ -92,7 +92,7 @@ abstract class NetworkTimelineViewModelTestBase { PrefKeys.CONFIRM_REBLOGS to true, PrefKeys.CONFIRM_FAVOURITES to false, PrefKeys.WELLBEING_HIDE_STATS_POSTS to false, - PrefKeys.FAB_HIDE to false + PrefKeys.FAB_HIDE to false, ) // Any getBoolean() call looks for the result in sharedPreferencesMap @@ -104,7 +104,7 @@ abstract class NetworkTimelineViewModelTestBase { accountPreferencesMap = mutableMapOf( PrefKeys.ALWAYS_SHOW_SENSITIVE_MEDIA to false, PrefKeys.ALWAYS_OPEN_SPOILER to false, - PrefKeys.MEDIA_PREVIEW_ENABLED to true + PrefKeys.MEDIA_PREVIEW_ENABLED to true, ) // Any getBoolean() call looks for the result in accountPreferencesMap. @@ -129,7 +129,7 @@ abstract class NetworkTimelineViewModelTestBase { notificationsFilter = "['follow']", mediaPreviewEnabled = true, alwaysShowSensitiveMedia = true, - alwaysOpenSpoiler = true + alwaysOpenSpoiler = true, ) } eventHub = EventHub() @@ -145,7 +145,7 @@ abstract class NetworkTimelineViewModelTestBase { accountManager, sharedPreferences, accountPreferenceDataStore, - filterModel + filterModel, ) // Initialisation with any timeline kind, as long as it's not Home // (Home uses CachedTimelineViewModel) diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusAction.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusAction.kt index 05571a3e6..7dd57f378 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusAction.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusAction.kt @@ -52,7 +52,7 @@ class NetworkTimelineViewModelTestStatusAction : NetworkTimelineViewModelTestBas status = status, isExpanded = true, isShowingContent = false, - isCollapsed = false + isCollapsed = false, ) /** Action to bookmark a status */ @@ -68,7 +68,7 @@ class NetworkTimelineViewModelTestStatusAction : NetworkTimelineViewModelTestBas private val voteInPollAction = StatusAction.VoteInPoll( poll = status.poll!!, choices = listOf(1, 0, 0), - statusViewData + statusViewData, ) /** Captors for status ID and state arguments */ diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusDisplayOptions.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusDisplayOptions.kt index 1bf39c4b7..ebabae989 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusDisplayOptions.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestStatusDisplayOptions.kt @@ -52,7 +52,7 @@ class NetworkTimelineViewModelTestStatusDisplayOptions : NetworkTimelineViewMode animateEmojis = false, showStatsInline = false, showSensitiveMedia = true, // setting in NotificationsViewModelTestBase - openSpoiler = true // setting in NotificationsViewModelTestBase + openSpoiler = true, // setting in NotificationsViewModelTestBase ) @Test @@ -75,7 +75,7 @@ class NetworkTimelineViewModelTestStatusDisplayOptions : NetworkTimelineViewMode val updatedOptions = defaultStatusDisplayOptions.make( sharedPreferences, PrefKeys.ANIMATE_GIF_AVATARS, - accountManager.activeAccount!! + accountManager.activeAccount!!, ) // Then, should be true diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestUiState.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestUiState.kt index ace1d4cc7..7f9dbf046 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestUiState.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/NetworkTimelineViewModelTestUiState.kt @@ -37,7 +37,7 @@ class NetworkTimelineViewModelTestUiState : NetworkTimelineViewModelTestBase() { private val initialUiState = UiState( showFabWhileScrolling = true, - showMediaPreview = true + showMediaPreview = true, ) @Test diff --git a/app/src/test/java/com/keylesspalace/tusky/components/timeline/StatusMocker.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/StatusMocker.kt index 133e895f7..1323c9382 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/timeline/StatusMocker.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/timeline/StatusMocker.kt @@ -16,7 +16,7 @@ fun mockStatus( spoilerText: String = "", reblogged: Boolean = false, favourited: Boolean = true, - bookmarked: Boolean = true + bookmarked: Boolean = true, ) = Status( id = id, url = "https://mastodon.example/@ConnyDuck/$id", @@ -27,7 +27,7 @@ fun mockStatus( displayName = "Conny Duck", note = "This is their bio", url = "https://mastodon.example/@ConnyDuck", - avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg" + avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg", ), inReplyToId = inReplyToId, inReplyToAccountId = inReplyToAccountId, @@ -54,7 +54,7 @@ fun mockStatus( poll = null, card = null, language = null, - filtered = null + filtered = null, ) fun mockStatusViewData( @@ -68,7 +68,7 @@ fun mockStatusViewData( isCollapsed: Boolean = !isDetailed, reblogged: Boolean = false, favourited: Boolean = true, - bookmarked: Boolean = true + bookmarked: Boolean = true, ) = StatusViewData( status = mockStatus( id = id, @@ -77,18 +77,18 @@ fun mockStatusViewData( spoilerText = spoilerText, reblogged = reblogged, favourited = favourited, - bookmarked = bookmarked + bookmarked = bookmarked, ), isExpanded = isExpanded, isShowingContent = isShowingContent, isCollapsed = isCollapsed, - isDetailed = isDetailed + isDetailed = isDetailed, ) fun mockStatusEntityWithAccount( id: String = "100", userId: Long = 1, - expanded: Boolean = false + expanded: Boolean = false, ): TimelineStatusWithAccount { val mockedStatus = mockStatus(id) val gson = Gson() @@ -99,11 +99,11 @@ fun mockStatusEntityWithAccount( gson = gson, expanded = expanded, contentShowing = false, - contentCollapsed = true + contentCollapsed = true, ), account = mockedStatus.account.toEntity( accountId = userId, - gson = gson - ) + gson = gson, + ), ) } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt index 0a07b5ab6..7c10d1bd7 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt @@ -90,7 +90,7 @@ class ViewThreadViewModelTest { accessToken = "fakeToken", clientId = "fakeId", clientSecret = "fakeSecret", - isActive = true + isActive = true, ) } val context = InstrumentationRegistry.getInstrumentation().targetContext @@ -120,12 +120,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -143,12 +143,12 @@ class ViewThreadViewModelTest { assertEquals( ThreadUiState.Success( statusViewData = listOf( - mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true) + mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true), ), detailedStatusPosition = 0, - revealButton = RevealButtonState.NO_BUTTON + revealButton = RevealButtonState.NO_BUTTON, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -165,7 +165,7 @@ class ViewThreadViewModelTest { runBlocking { assertEquals( ThreadUiState.Error::class.java, - viewModel.uiState.first().javaClass + viewModel.uiState.first().javaClass, ) } } @@ -177,8 +177,8 @@ class ViewThreadViewModelTest { onBlocking { statusContext(threadId) } doReturn NetworkResult.success( StatusContext( ancestors = listOf(mockStatus(id = "1")), - descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1")) - ) + descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1")), + ), ) } @@ -187,7 +187,7 @@ class ViewThreadViewModelTest { runBlocking { assertEquals( ThreadUiState.Error::class.java, - viewModel.uiState.first().javaClass + viewModel.uiState.first().javaClass, ) } } @@ -205,12 +205,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test", isExpanded = true), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test", isExpanded = true), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", isExpanded = true) + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", isExpanded = true), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.HIDE + revealButton = RevealButtonState.HIDE, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -229,12 +229,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test", favourited = false), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -253,12 +253,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test", reblogged = true), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -277,12 +277,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", bookmarked = false) + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", bookmarked = false), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -300,12 +300,12 @@ class ViewThreadViewModelTest { ThreadUiState.Success( statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), - mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test") + mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -318,7 +318,7 @@ class ViewThreadViewModelTest { viewModel.changeExpanded( true, - mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test") + mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), ) runBlocking { @@ -327,12 +327,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test", isExpanded = true), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -345,7 +345,7 @@ class ViewThreadViewModelTest { viewModel.changeContentCollapsed( true, - mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test") + mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), ) runBlocking { @@ -354,12 +354,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test", isCollapsed = true), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -372,7 +372,7 @@ class ViewThreadViewModelTest { viewModel.changeContentShowing( true, - mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test") + mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test"), ) runBlocking { @@ -381,12 +381,12 @@ class ViewThreadViewModelTest { statusViewData = listOf( mockStatusViewData(id = "1", spoilerText = "Test"), mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test", isShowingContent = true), - mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") + mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test"), ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL + revealButton = RevealButtonState.REVEAL, ), - viewModel.uiState.first() + viewModel.uiState.first(), ) } } @@ -397,8 +397,8 @@ class ViewThreadViewModelTest { onBlocking { statusContext(threadId) } doReturn NetworkResult.success( StatusContext( ancestors = listOf(mockStatus(id = "1", spoilerText = "Test")), - descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")) - ) + descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")), + ), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt b/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt index 6975a30a0..56259fac3 100644 --- a/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt @@ -69,14 +69,14 @@ class TimelineDaoTest { makeStatus(statusId = 5), makeStatus(statusId = 3, authorServerId = "4"), makeStatus(statusId = 2, accountId = 2, authorServerId = "5"), - makeStatus(statusId = 1, authorServerId = "5") + makeStatus(statusId = 1, authorServerId = "5"), ) val statusesAfterCleanup = listOf( makeStatus(statusId = 100), makeStatus(statusId = 10, authorServerId = "3"), makeStatus(statusId = 8, reblog = true, authorServerId = "10"), - makeStatus(statusId = 2, accountId = 2, authorServerId = "5") + makeStatus(statusId = 2, accountId = 2, authorServerId = "5"), ) for ((status, author, reblogAuthor) in statusesBeforeCleanup) { @@ -111,7 +111,7 @@ class TimelineDaoTest { 1L to "20", 1L to "3", 1L to "R10", - 2L to "5" + 2L to "5", ) assertEquals(expectedAccounts, loadedAccounts) @@ -122,7 +122,7 @@ class TimelineDaoTest { val oldStatuses = listOf( makeStatus(statusId = 3), makeStatus(statusId = 2), - makeStatus(statusId = 1) + makeStatus(statusId = 1), ) for ((status, author, reblogAuthor) in oldStatuses) { @@ -136,7 +136,7 @@ class TimelineDaoTest { // status 2 gets deleted, newly loaded status contain only 1 + 3 val newStatuses = listOf( makeStatus(statusId = 3), - makeStatus(statusId = 1) + makeStatus(statusId = 1), ) val deletedCount = timelineDao.deleteRange(1, newStatuses.last().first.serverId, newStatuses.first().first.serverId) @@ -172,7 +172,7 @@ class TimelineDaoTest { makeStatus(statusId = 13, accountId = 2), makeStatus(statusId = 12), makeStatus(statusId = 11), - makeStatus(statusId = 9) + makeStatus(statusId = 9), ) for ((status, author, reblogAuthor) in statuses) { @@ -199,11 +199,11 @@ class TimelineDaoTest { makeStatus(statusId = 100), makeStatus(statusId = 15), makeStatus(statusId = 11), - makeStatus(statusId = 9) + makeStatus(statusId = 9), ) val remainingStatusesAccount2 = listOf( - makeStatus(statusId = 13, accountId = 2) + makeStatus(statusId = 13, accountId = 2), ) assertStatuses(remainingStatusesAccount1, statusesAccount1) @@ -216,37 +216,37 @@ class TimelineDaoTest { statusId = 15, accountId = 1, domain = "mastodon.red", - authorServerId = "1" + authorServerId = "1", ) val statusWithRedDomain2 = makeStatus( statusId = 14, accountId = 1, domain = "mastodon.red", - authorServerId = "2" + authorServerId = "2", ) val statusWithRedDomainOtherAccount = makeStatus( statusId = 12, accountId = 2, domain = "mastodon.red", - authorServerId = "2" + authorServerId = "2", ) val statusWithBlueDomain = makeStatus( statusId = 10, accountId = 1, domain = "mastodon.blue", - authorServerId = "4" + authorServerId = "4", ) val statusWithBlueDomainOtherAccount = makeStatus( statusId = 10, accountId = 2, domain = "mastodon.blue", - authorServerId = "5" + authorServerId = "5", ) val statusWithGreenDomain = makeStatus( statusId = 8, accountId = 1, domain = "mastodon.green", - authorServerId = "6" + authorServerId = "6", ) for ((status, author, reblogAuthor) in listOf(statusWithRedDomain1, statusWithRedDomain2, statusWithRedDomainOtherAccount, statusWithBlueDomain, statusWithBlueDomainOtherAccount, statusWithGreenDomain)) { @@ -299,7 +299,7 @@ class TimelineDaoTest { createdAt: Long = statusId, authorServerId: String = "20", domain: String = "mastodon.example", - cardUrl: String? = null + cardUrl: String? = null, ): Triple { val author = TimelineAccountEntity( serverId = authorServerId, @@ -310,7 +310,7 @@ class TimelineDaoTest { url = "blah", avatar = "avatar", emojis = "[\"tusky\": \"http://tusky.cool/emoji.jpg\"]", - bot = false + bot = false, ) val reblogAuthor = if (reblog) { @@ -323,7 +323,7 @@ class TimelineDaoTest { url = "Rblah", avatar = "Ravatar", emojis = "[]", - bot = false + bot = false, ) } else { null @@ -368,14 +368,14 @@ class TimelineDaoTest { pinned = false, card = card, language = null, - filtered = null + filtered = null, ) return Triple(status, author, reblogAuthor) } private fun assertStatuses( expected: List>, - provided: List + provided: List, ) { for ((exp, prov) in expected.zip(provided)) { val (status, author, reblogger) = exp diff --git a/app/src/test/java/com/keylesspalace/tusky/json/GuardedBooleanAdapterTest.kt b/app/src/test/java/com/keylesspalace/tusky/json/GuardedBooleanAdapterTest.kt index 15e05d539..f3a124a33 100644 --- a/app/src/test/java/com/keylesspalace/tusky/json/GuardedBooleanAdapterTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/json/GuardedBooleanAdapterTest.kt @@ -43,9 +43,9 @@ class GuardedBooleanAdapterTest { subscribing = true, blockingDomain = false, note = "Hi", - notifying = false + notifying = false, ), - gson.fromJson(jsonInput, Relationship::class.java) + gson.fromJson(jsonInput, Relationship::class.java), ) } @@ -83,9 +83,9 @@ class GuardedBooleanAdapterTest { subscribing = null, blockingDomain = false, note = "Hi", - notifying = false + notifying = false, ), - gson.fromJson(jsonInput, Relationship::class.java) + gson.fromJson(jsonInput, Relationship::class.java), ) } @@ -122,9 +122,9 @@ class GuardedBooleanAdapterTest { subscribing = null, blockingDomain = false, note = "Hi", - notifying = false + notifying = false, ), - gson.fromJson(jsonInput, Relationship::class.java) + gson.fromJson(jsonInput, Relationship::class.java), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt b/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt index 9a4f737d1..f5a31b88e 100644 --- a/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt @@ -62,7 +62,7 @@ class InstanceSwitchAuthInterceptorTest { accessToken = "fakeToken", clientId = "fakeId", clientSecret = "fakeSecret", - isActive = true + isActive = true, ) } } @@ -96,7 +96,7 @@ class InstanceSwitchAuthInterceptorTest { accessToken = "fakeToken", clientId = "fakeId", clientSecret = "fakeSecret", - isActive = true + isActive = true, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt b/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt index bcb690641..31c5b45a8 100644 --- a/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt @@ -59,15 +59,15 @@ class TimelineCasesTest { HttpException( Response.error( 422, - "{\"error\":\"Validation Failed: You have already pinned the maximum number of toots\"}".toResponseBody() - ) - ) + "{\"error\":\"Validation Failed: You have already pinned the maximum number of toots\"}".toResponseBody(), + ), + ), ) } runBlocking { assertEquals( "Validation Failed: You have already pinned the maximum number of toots", - timelineCases.pin(statusId, true).exceptionOrNull()?.message + timelineCases.pin(statusId, true).exceptionOrNull()?.message, ) } } @@ -102,7 +102,7 @@ class TimelineCasesTest { poll = null, card = null, language = null, - filtered = null + filtered = null, ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/util/HttpHeaderLinkTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/HttpHeaderLinkTest.kt index bc7496abd..195e9f63c 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/HttpHeaderLinkTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/HttpHeaderLinkTest.kt @@ -35,17 +35,17 @@ class HttpHeaderLinkTest { TestData( "Single URL", "", - listOf(HttpHeaderLink("https://example.com")) + listOf(HttpHeaderLink("https://example.com")), ), TestData( "Single URL with parameters", "; rel=\"preconnect\"", - listOf(HttpHeaderLink("https://example.com")) + listOf(HttpHeaderLink("https://example.com")), ), TestData( "Single encoded URL with parameters", "; rel=\"preconnect\"", - listOf(HttpHeaderLink("https://example.com/%E8%8B%97%E6%9D%A1")) + listOf(HttpHeaderLink("https://example.com/%E8%8B%97%E6%9D%A1")), ), TestData( "Multiple URLs, separated by commas", @@ -53,33 +53,33 @@ class HttpHeaderLinkTest { listOf( HttpHeaderLink("https://one.example.com"), HttpHeaderLink("https://two.example.com"), - HttpHeaderLink("https://three.example.com") - ) + HttpHeaderLink("https://three.example.com"), + ), ), // Examples from https://httpwg.org/specs/rfc8288.html#rfc.section.3.5 TestData( "Single URL, multiple parameters", "; rel=\"previous\"; title=\"previous chapter\"", - listOf(HttpHeaderLink("http://example.com/TheBook/chapter2")) + listOf(HttpHeaderLink("http://example.com/TheBook/chapter2")), ), TestData( "Root resource", "; rel=\"http://example.net/foo\"", - listOf(HttpHeaderLink("/")) + listOf(HttpHeaderLink("/")), ), TestData( "Terms and anchor", "; rel=\"copyright\"; anchor=\"#foo\"", - listOf(HttpHeaderLink("/terms")) + listOf(HttpHeaderLink("/terms")), ), TestData( "Multiple URLs with parameter encoding", "; rel=\"previous\"; title*=UTF-8'de'letztes%20Kapitel, ; rel=\"next\"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel", listOf( HttpHeaderLink("/TheBook/chapter2"), - HttpHeaderLink("/TheBook/chapter4") - ) - ) + HttpHeaderLink("/TheBook/chapter4"), + ), + ), ) // Verify that the URLs are parsed correctly diff --git a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt index 3b053d017..0959dfb1f 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt @@ -26,11 +26,11 @@ class LinkHelperTest { private val mentions = listOf( Status.Mention("1", "https://example.com/@user", "user", "user"), - Status.Mention("2", "https://example.com/@anotherUser", "anotherUser", "anotherUser") + Status.Mention("2", "https://example.com/@anotherUser", "anotherUser", "anotherUser"), ) private val tags = listOf( HashTag("Tusky", "https://example.com/Tags/Tusky"), - HashTag("mastodev", "https://example.com/Tags/mastodev") + HashTag("mastodev", "https://example.com/Tags/mastodev"), ) private val context: Context @@ -118,7 +118,7 @@ class LinkHelperTest { null, "foo bar baz", "http:/foo.bar", - "c:/foo/bar" + "c:/foo/bar", ).forEach { Assert.assertEquals("", getDomain(it)) } @@ -130,7 +130,7 @@ class LinkHelperTest { "example.com", "localhost", "sub.domain.com", - "10.45.0.123" + "10.45.0.123", ).forEach { domain -> listOf( "https://$domain", @@ -140,7 +140,7 @@ class LinkHelperTest { "https://$domain/foo/bar.html#", "https://$domain/foo/bar.html#anchor", "https://$domain/foo/bar.html?argument=value", - "https://$domain/foo/bar.html?argument=value&otherArgument=otherValue" + "https://$domain/foo/bar.html?argument=value&otherArgument=otherValue", ).forEach { url -> Assert.assertEquals(domain, getDomain(url)) } @@ -153,7 +153,7 @@ class LinkHelperTest { "https://www.example.com/foo/bar" to "example.com", "https://awww.example.com/foo/bar" to "awww.example.com", "http://www.localhost" to "localhost", - "https://wwwexample.com/" to "wwwexample.com" + "https://wwwexample.com/" to "wwwexample.com", ).forEach { (url, domain) -> Assert.assertEquals(domain, getDomain(url)) } @@ -169,7 +169,7 @@ class LinkHelperTest { val oldContent = content.toString() Assert.assertEquals( context.getString(R.string.url_domain_notifier, displayedContent, maliciousDomain), - markupHiddenUrls(context, content).toString() + markupHiddenUrls(context, content).toString(), ) Assert.assertEquals(oldContent, content.toString()) } @@ -183,7 +183,7 @@ class LinkHelperTest { content.append(displayedContent, URLSpan(maliciousUrl), 0) Assert.assertEquals( context.getString(R.string.url_domain_notifier, displayedContent, maliciousDomain), - markupHiddenUrls(context, content).toString() + markupHiddenUrls(context, content).toString(), ) } @@ -247,7 +247,7 @@ class LinkHelperTest { "Another Place: another.place/", "Another Place - https://another.place", "Another Place | https://another.place/", - "Another Place https://another.place/path" + "Another Place https://another.place/path", ) asserts.forEach { Assert.assertTrue(markedUpContent.contains(context.getString(R.string.url_domain_notifier, it, "some.place"))) @@ -367,7 +367,7 @@ class LinkHelperTest { arrayOf("https://pixelfed.social/connyduck", true), arrayOf("https://gts.foo.bar/@goblin/statuses/01GH9XANCJ0TA8Y95VE9H3Y0Q2", true), arrayOf("https://gts.foo.bar/@goblin", true), - arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true) + arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt index 3622770a7..47319a89b 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt @@ -40,11 +40,11 @@ class LocaleUtilsTest { Assert.assertEquals( defaultLanguage, - getMockedInitialLanguages(arrayOf(defaultLanguage, defaultLanguage, "fr", defaultLanguage, "kab", defaultLanguage))[0] + getMockedInitialLanguages(arrayOf(defaultLanguage, defaultLanguage, "fr", defaultLanguage, "kab", defaultLanguage))[0], ) Assert.assertEquals( defaultLanguage, - getMockedInitialLanguages(arrayOf(null, defaultLanguage, "fr", defaultLanguage, "kab", defaultLanguage))[0] + getMockedInitialLanguages(arrayOf(null, defaultLanguage, "fr", defaultLanguage, "kab", defaultLanguage))[0], ) } @@ -73,8 +73,8 @@ class LocaleUtilsTest { clientId = null, clientSecret = null, isActive = true, - defaultPostLanguage = configuredLanguages[1].orEmpty() - ) + defaultPostLanguage = configuredLanguages[1].orEmpty(), + ), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/util/NumberUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/NumberUtilsTest.kt index 565a4f58b..528caa46d 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/NumberUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/NumberUtilsTest.kt @@ -75,7 +75,7 @@ class NumberUtilsTest(private val input: Long, private val want: String) { arrayOf(3500 * 1000.0.pow(2).toLong(), "3.5G"), arrayOf(3500 * 1000.0.pow(3).toLong(), "3.5T"), arrayOf(3500 * 1000.0.pow(4).toLong(), "3.5P"), - arrayOf(3500 * 1000.0.pow(5).toLong(), "3.5E") + arrayOf(3500 * 1000.0.pow(5).toLong(), "3.5E"), ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/util/SmartLengthInputFilterTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/SmartLengthInputFilterTest.kt index 5b6f417b7..c0894f05d 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/SmartLengthInputFilterTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/SmartLengthInputFilterTest.kt @@ -33,9 +33,9 @@ class SmartLengthInputFilterTest { "mmqPwQgtatbMykTW4RZdKTE46nzlbD3mXHdWQkf4uVPYhVT1CMvVbCPMaimfQ0xuU8CpxyVqA8a6lCL3YX9" + "pNnZjD7DoCg2FCejANnjXsTF6vuqPSHjQZDjy696nSAFy95p9kBeJkc70fHzX5TcfUqSaNtvx3LUtpIkwh4" + "q2EYmKISPsxlANaspEMPuX6r9fSACiEwmHsitZkp4RMKZq5NqRsGPCiAXcNIN3jj9fCYVGxUwVxVeCescDG" + - "5naEEszIR3FT1RO4MSn9c2ZZi0UdLizd8ciJAIuwwmcVyYyyM4" - ) - ) + "5naEEszIR3FT1RO4MSn9c2ZZi0UdLizd8ciJAIuwwmcVyYyyM4", + ), + ), ) } @@ -52,9 +52,9 @@ class SmartLengthInputFilterTest { "bOPeanGMBmeI9YRdiD4MmuTUkJfVLkA9rrpRtiEYw8RS3Jf9iqDkTpES9aLQODMip5xTsT4liIcUbLo0Z1d" + "NhHk7YKubigNQIm1mmh2iU3Q0ZEm8TraDpKu2o27gIwSKbAnTllrOokprPxWQWDVrN9bIliwGHzgTKPI5z8" + "gUybaqewxUYe12GvxnzqpfPFvvHricyZAC9i6Fkil5VmFdae75tLFWRBfE8Wfep0dSjL751m2yzvzZTc6uZ" + - "RTcUiipvl42DaY8Z5eG2b6xPVhvXshMORvHzwhJhPkHSbnwXX5K" - ) - ) + "RTcUiipvl42DaY8Z5eG2b6xPVhvXshMORvHzwhJhPkHSbnwXX5K", + ), + ), ) } @@ -71,9 +71,9 @@ class SmartLengthInputFilterTest { "bOPeanGMBmeI9YRdiD4MmuTUkJfVLkA9rrpRtiEYw8RS3Jf9iqDkTpES9aLQODMip5xTsT4liIcUbLo0Z1d" + "NhHk7YKubigNQIm1mmh2iU3Q0ZEm8TraDpKu2o27gIwSKbAnTllrOokprPxWQWDVrN9bIliwGHzgTKPI5z8" + "gUybaqewxUYe12GvxnzqpfPFvvHricyZAC9i6Fkil5VmFdae75tLFWRBfE8Wfep0dSjL751m2yzvzZTc6uZ" + - "RTcUiipvl42DaY8Z5eG2b6xPVhvXshMORvHzwhJhPkHSbnwXX5K1" - ) - ) + "RTcUiipvl42DaY8Z5eG2b6xPVhvXshMORvHzwhJhPkHSbnwXX5K1", + ), + ), ) } @@ -95,9 +95,9 @@ class SmartLengthInputFilterTest { "mmqPwQgtatbMykTW4RZdKTE46nzlbD3mXHdWQkf4uVPYhVT1CMvVbCPMaimfQ0xuU8CpxyVqA8a6lCL3YX9" + "pNnZjD7DoCg2FCejANnjXsTF6vuqPSHjQZDjy696nSAFy95p9kBeJkc70fHzX5TcfUqSaNtvx3LUtpIkwh4" + "q2EYmKISPsxlANaspEMPuX6r9fSACiEwmHsitZkp4RMKZq5NqRsGPCiAXcNIN3jj9fCYVGxUwVxVeCescDG" + - "5naEEszIR3FT1RO4MSn9c2ZZi0UdLizd8ciJAIuwwmcVyYyyM4" - ) - ) + "5naEEszIR3FT1RO4MSn9c2ZZi0UdLizd8ciJAIuwwmcVyYyyM4", + ), + ), ) } } diff --git a/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/Main.kt b/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/Main.kt index 0950df4af..e563e2313 100644 --- a/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/Main.kt +++ b/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/Main.kt @@ -54,7 +54,7 @@ data class Language( val displayName: String, /** Name of the language in English */ - val displayNameEnglish: String + val displayNameEnglish: String, ) { companion object { private val toTitle = CaseMap.toTitle() @@ -63,7 +63,7 @@ data class Language( fun from(locale: ULocale) = Language( locale.name.replace("_", "-"), toTitle.apply(locale.toLocale(), null, locale.getDisplayName(locale)), - locale.getDisplayName(ULocale.ENGLISH) + locale.getDisplayName(ULocale.ENGLISH), ) } } diff --git a/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/ValuesParser.kt b/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/ValuesParser.kt index a3e53d3c5..e16292b7d 100644 --- a/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/ValuesParser.kt +++ b/tools/mklanguages/src/main/kotlin/app/pachli/mklanguages/ValuesParser.kt @@ -83,7 +83,7 @@ class ValuesParser : Grammar() { Locale( lang = this.t1.text.split("+")[1], script = this.t2.getOrNull(0)?.text?.split("+")?.get(1), - region = this.t2.getOrNull(1)?.text?.split("+")?.get(1) + region = this.t2.getOrNull(1)?.text?.split("+")?.get(1), ) } @@ -113,7 +113,7 @@ class ValuesParser : Grammar() { private val qualifierParser by qualifier use { ConfigurationQualifier( mobileCodes = this.t1, - locale = this.t2 + locale = this.t2, ) } diff --git a/tools/mklanguages/src/test/kotlin/app/pachli/mklanguages/ValuesParserTest.kt b/tools/mklanguages/src/test/kotlin/app/pachli/mklanguages/ValuesParserTest.kt index 0958eb291..d048642de 100644 --- a/tools/mklanguages/src/test/kotlin/app/pachli/mklanguages/ValuesParserTest.kt +++ b/tools/mklanguages/src/test/kotlin/app/pachli/mklanguages/ValuesParserTest.kt @@ -42,7 +42,7 @@ internal class ValuesParserTest { Params("values-en-rGB", Locale(lang = "en", region = "GB")), Params("values-b+tzm+Tfng", Locale(lang = "tzm", script = "Tfng")), Params("values-mcc001", null), - Params("values-land", null) + Params("values-land", null), ) }