From d839f18267197fe88d7c8137f6720d697a67dbd4 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 13 Mar 2023 13:16:39 +0100 Subject: [PATCH] update ktlint plugin to 11.3.1, format code (#3442) --- .../com/keylesspalace/tusky/AboutActivity.kt | 1 - .../tusky/AccountsInListFragment.kt | 6 +- .../tusky/BottomSheetActivity.kt | 2 +- .../tusky/EditProfileActivity.kt | 1 - .../keylesspalace/tusky/LicenseActivity.kt | 1 - .../com/keylesspalace/tusky/ListsActivity.kt | 14 ++- .../com/keylesspalace/tusky/MainActivity.kt | 15 ++- .../keylesspalace/tusky/StatusListActivity.kt | 6 +- .../tusky/TabPreferenceActivity.kt | 3 +- .../keylesspalace/tusky/ViewMediaActivity.kt | 3 +- .../tusky/adapter/ListSelectionAdapter.kt | 1 - .../tusky/adapter/PollAdapter.kt | 1 - .../adapter/ReportNotificationViewHolder.kt | 2 +- .../tusky/adapter/TrendingDateViewHolder.kt | 2 +- .../tusky/adapter/TrendingTagViewHolder.kt | 2 +- .../components/account/AccountActivity.kt | 21 +++-- .../components/account/AccountViewModel.kt | 31 ++++--- .../account/list/ListsForAccountFragment.kt | 4 +- .../account/list/ListsForAccountViewModel.kt | 12 +-- .../account/media/AccountMediaPagingSource.kt | 1 - .../media/AccountMediaRemoteMediator.kt | 1 - .../accountlist/AccountListFragment.kt | 3 +- .../accountlist/adapter/AccountAdapter.kt | 2 +- .../accountlist/adapter/BlocksAdapter.kt | 2 +- .../adapter/FollowRequestsAdapter.kt | 4 +- .../announcements/AnnouncementsViewModel.kt | 3 +- .../components/compose/ComposeActivity.kt | 61 +++++++----- .../components/compose/ComposeViewModel.kt | 20 ++-- .../components/compose/ImageDownsizer.kt | 1 - .../components/compose/MediaPreviewAdapter.kt | 8 +- .../tusky/components/compose/MediaUploader.kt | 4 +- .../compose/dialog/AddPollDialog.kt | 1 - .../compose/dialog/CaptionDialog.kt | 11 ++- .../compose/view/FocusIndicatorView.kt | 12 ++- .../components/compose/view/TootButton.kt | 1 - .../conversation/ConversationEntity.kt | 10 +- .../conversation/ConversationViewData.kt | 2 +- .../ConversationsRemoteMediator.kt | 4 +- .../tusky/components/drafts/DraftHelper.kt | 4 +- .../components/drafts/DraftMediaAdapter.kt | 8 +- .../tusky/components/drafts/DraftsAdapter.kt | 1 - .../components/filters/EditFilterActivity.kt | 6 +- .../components/filters/EditFilterViewModel.kt | 6 +- .../components/filters/FiltersViewModel.kt | 2 +- .../followedtags/FollowedTagsAdapter.kt | 2 +- .../FollowedTagsRemoteMediator.kt | 2 +- .../adapter/DomainMutesAdapter.kt | 3 +- .../tusky/components/login/LoginActivity.kt | 19 +++- .../components/login/LoginWebViewActivity.kt | 2 +- .../notifications/FollowViewHolder.kt | 2 +- .../notifications/PushNotificationHelper.kt | 12 ++- .../preference/AccountPreferencesFragment.kt | 1 - .../report/adapter/StatusViewHolder.kt | 13 ++- .../report/adapter/StatusesAdapter.kt | 5 +- .../report/fragments/ReportNoteFragment.kt | 3 +- .../tusky/components/search/SearchActivity.kt | 2 +- .../search/adapter/SearchPagingSource.kt | 1 - .../fragments/SearchStatusesFragment.kt | 11 ++- .../components/timeline/TimelineFragment.kt | 12 ++- .../timeline/TimelinePagingAdapter.kt | 4 +- .../timeline/TimelineTypeMappers.kt | 10 +- .../viewmodel/CachedTimelineRemoteMediator.kt | 1 - .../viewmodel/CachedTimelineViewModel.kt | 1 - .../viewmodel/NetworkTimelinePagingSource.kt | 1 - .../NetworkTimelineRemoteMediator.kt | 2 - .../viewmodel/NetworkTimelineViewModel.kt | 2 +- .../timeline/viewmodel/TimelineViewModel.kt | 2 +- .../components/trending/TrendingAdapter.kt | 2 +- .../components/trending/TrendingFragment.kt | 9 +- .../components/viewthread/ThreadAdapter.kt | 4 +- .../viewthread/ViewThreadViewModel.kt | 2 +- .../keylesspalace/tusky/db/AccountEntity.kt | 2 +- .../keylesspalace/tusky/db/AccountManager.kt | 9 +- .../com/keylesspalace/tusky/db/DraftEntity.kt | 2 +- .../tusky/db/TimelineStatusEntity.kt | 2 +- .../com/keylesspalace/tusky/di/AppModule.kt | 2 +- .../com/keylesspalace/tusky/entity/Account.kt | 6 +- .../keylesspalace/tusky/entity/Attachment.kt | 6 +- .../tusky/entity/DeletedStatus.kt | 2 +- .../com/keylesspalace/tusky/entity/Filter.kt | 2 +- .../tusky/entity/FilterKeyword.kt | 2 +- .../tusky/entity/FilterResult.kt | 2 +- .../keylesspalace/tusky/entity/FilterV1.kt | 2 +- .../keylesspalace/tusky/entity/Instance.kt | 8 +- .../keylesspalace/tusky/entity/NewStatus.kt | 4 +- .../tusky/entity/Notification.kt | 11 ++- .../entity/NotificationSubscribeResult.kt | 2 +- .../com/keylesspalace/tusky/entity/Report.kt | 2 +- .../com/keylesspalace/tusky/entity/Status.kt | 8 +- .../tusky/entity/StatusSource.kt | 2 +- .../tusky/entity/TimelineAccount.kt | 6 +- .../tusky/entity/TrendingTagsResult.kt | 4 +- .../keylesspalace/tusky/fragment/SFragment.kt | 4 +- .../tusky/fragment/ViewImageFragment.kt | 6 +- .../tusky/fragment/ViewMediaFragment.kt | 1 + .../keylesspalace/tusky/json/Iso8601Utils.kt | 1 - .../tusky/network/FilterModel.kt | 3 +- .../network/InstanceSwitchAuthInterceptor.kt | 1 - .../tusky/network/MastodonApi.kt | 20 ++-- .../receiver/SendStatusBroadcastReceiver.kt | 2 +- .../tusky/service/SendStatusService.kt | 21 ++--- .../settings/AccountPreferenceHandler.kt | 2 +- .../tusky/settings/ProxyConfiguration.kt | 10 +- .../tusky/util/CustomEmojiHelper.kt | 4 +- .../tusky/util/HttpHeaderLink.kt | 4 +- .../com/keylesspalace/tusky/util/IOUtils.kt | 2 +- .../tusky/util/ImageLoadingHelper.kt | 1 - .../util/ListStatusAccessibilityDelegate.kt | 6 +- .../keylesspalace/tusky/util/LocaleManager.kt | 1 - .../keylesspalace/tusky/util/MediaUtils.kt | 10 +- .../tusky/util/NotificationTypeConverter.kt | 3 +- .../tusky/util/ShareShortcutHelper.kt | 3 - .../tusky/util/SmartLengthInputFilter.kt | 1 - .../com/keylesspalace/tusky/util/SpanUtils.kt | 2 +- .../tusky/util/StatusParsingHelper.kt | 1 + .../tusky/util/StatusViewHelper.kt | 23 +++-- .../keylesspalace/tusky/util/ViewDataUtils.kt | 4 +- .../com/keylesspalace/tusky/view/GraphView.kt | 72 ++++++++++---- .../keylesspalace/tusky/view/LicenseCard.kt | 7 +- .../tusky/view/MediaPreviewImageView.kt | 9 +- .../tusky/viewdata/PollViewData.kt | 2 +- .../tusky/viewdata/StatusViewData.kt | 2 +- .../tusky/viewdata/TrendingViewData.kt | 2 +- .../tusky/viewmodel/EditProfileViewModel.kt | 5 +- .../tusky/viewmodel/ListsViewModel.kt | 7 +- .../tusky/BottomSheetActivityTest.kt | 3 +- .../com/keylesspalace/tusky/FilterV1Test.kt | 14 ++- .../keylesspalace/tusky/FocalPointUtilTest.kt | 93 +++++++++++++------ .../keylesspalace/tusky/MainActivityTest.kt | 4 +- .../keylesspalace/tusky/StringUtilsTest.kt | 2 +- .../CachedTimelineRemoteMediatorTest.kt | 32 +++---- .../NetworkTimelineRemoteMediatorTest.kt | 38 ++++---- .../tusky/components/timeline/StatusMocker.kt | 4 +- .../viewthread/ViewThreadViewModelTest.kt | 18 ++-- .../keylesspalace/tusky/db/TimelineDaoTest.kt | 16 ++-- .../InstanceSwitchAuthInterceptorTest.kt | 1 - .../tusky/usecase/TimelineCasesTest.kt | 3 +- .../tusky/util/LinkHelperTest.kt | 16 ++-- .../tusky/util/LocaleUtilsTest.kt | 2 +- .../keylesspalace/tusky/util/RickRollTest.kt | 5 +- gradle/libs.versions.toml | 2 +- 141 files changed, 589 insertions(+), 428 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt index fc8b3db2b..7c2eedccd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt @@ -51,7 +51,6 @@ class AboutActivity : BottomSheetActivity(), Injectable { } private fun TextView.setClickableTextWithoutUnderlines(@StringRes textId: Int) { - val text = SpannableString(context.getText(textId)) Linkify.addLinks(text, Linkify.WEB_URLS) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt index 2235958c7..7821630b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt @@ -153,12 +153,14 @@ class AccountsInListFragment : DialogFragment(), Injectable { if (error is IOException) { binding.messageView.setup( R.drawable.elephant_offline, - R.string.error_network, retryAction + R.string.error_network, + retryAction ) } else { binding.messageView.setup( R.drawable.elephant_error, - R.string.error_generic, retryAction + R.string.error_generic, + retryAction ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt index 8df0c6617..d62b5c1d1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt @@ -177,5 +177,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 715c45fb0..190421e69 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -136,7 +136,6 @@ class EditProfileActivity : BaseActivity(), Injectable { is Success -> { val me = profileRes.data if (me != null) { - binding.displayNameEditText.setText(me.displayName) binding.noteEditText.setText(me.source?.note) binding.lockedCheckBox.isChecked = me.locked diff --git a/app/src/main/java/com/keylesspalace/tusky/LicenseActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LicenseActivity.kt index 3099bd009..ca81d244a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LicenseActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LicenseActivity.kt @@ -44,7 +44,6 @@ class LicenseActivity : BaseActivity() { } private fun loadFileIntoTextView(@RawRes fileId: Int, textView: TextView) { - val sb = StringBuilder() val br = BufferedReader(InputStreamReader(resources.openRawResource(fileId))) diff --git a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt index ec241c204..e5c043d7a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt @@ -134,8 +134,11 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { val dialog = AlertDialog.Builder(this) .setView(layout) .setPositiveButton( - if (list == null) R.string.action_create_list - else R.string.action_rename_list + if (list == null) { + R.string.action_create_list + } else { + R.string.action_rename_list + } ) { _, _ -> onPickedDialogName(editText.text, list?.id) } @@ -181,7 +184,8 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { if (state.lists.isEmpty()) { binding.messageView.show() binding.messageView.setup( - R.drawable.elephant_friend_empty, R.string.message_empty, + R.drawable.elephant_friend_empty, + R.string.message_empty, null ) } else { @@ -192,7 +196,9 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { private fun showMessage(@StringRes messageId: Int) { Snackbar.make( - binding.listsRecycler, messageId, Snackbar.LENGTH_SHORT + binding.listsRecycler, + messageId, + Snackbar.LENGTH_SHORT ).show() } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index 6b8978def..dbf710a18 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -215,7 +215,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje } else { // No account was provided, show the chooser showAccountChooserDialog( - getString(R.string.action_share_as), true, + getString(R.string.action_share_as), + true, object : AccountSelectionListener { override fun onAccountSelected(account: AccountEntity) { val requestedId = account.id @@ -295,7 +296,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje is MainTabsChangedEvent -> { refreshMainDrawerItems( addSearchButton = hideTopToolbar, - addTrendingButton = !event.newTabs.hasTab(TRENDING), + addTrendingButton = !event.newTabs.hasTab(TRENDING) ) setupTabs(false) @@ -407,7 +408,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje // FIXME: blackberry keyONE raises SHIFT key event even CTRL IS PRESSED when (keyCode) { KeyEvent.KEYCODE_N -> { - // open compose activity by pressing SHIFT + N (or CTRL + N) val composeIntent = Intent(applicationContext, ComposeActivity::class.java) startActivity(composeIntent) @@ -444,7 +444,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje addSearchButton: Boolean, addTrendingButton: Boolean ) { - val drawerOpenClickListener = View.OnClickListener { binding.mainDrawerLayout.open() } binding.mainToolbar.setNavigationOnClickListener(drawerOpenClickListener) @@ -708,7 +707,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje tabAdapter.notifyItemRangeChanged(0, tabs.size) tabLayoutMediator = TabLayoutMediator(activeTabLayout, binding.viewPager, true) { - tab: TabLayout.Tab, position: Int -> + tab: TabLayout.Tab, position: Int -> tab.icon = AppCompatResources.getDrawable(this@MainActivity, tabs[position].icon) tab.contentDescription = when (tabs[position].id) { LIST -> tabs[position].arguments[1] @@ -881,7 +880,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje } private fun loadDrawerAvatar(avatarUrl: String, showPlaceholder: Boolean) { - val hideTopToolbar = preferences.getBoolean(PrefKeys.HIDE_TOP_TOOLBAR, false) val animateAvatars = preferences.getBoolean("animateGifAvatars", false) @@ -909,7 +907,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje .into(avatarView) } } else { - binding.bottomNavAvatar.hide() binding.topNavAvatar.hide() @@ -1040,7 +1037,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje header.setActiveProfile(accountManager.activeAccount!!.id) binding.mainToolbar.subtitle = if (accountManager.shouldDisplaySelfUsername(this)) { accountManager.activeAccount!!.fullName - } else null + } else { + null + } } override fun getActionButton() = binding.composeButton diff --git a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt index 260924376..c055043d1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt @@ -225,7 +225,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) { @@ -276,7 +276,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) @@ -291,7 +291,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) diff --git a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt index ad4ade735..0bbeda5a6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt @@ -59,6 +59,7 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene @Inject lateinit var mastodonApi: MastodonApi + @Inject lateinit var eventHub: EventHub @@ -161,7 +162,6 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene } override fun onTabAdded(tab: TabData) { - if (currentTabs.size >= MAX_TAB_COUNT) { return } @@ -223,7 +223,6 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene } private fun showAddHashtagDialog(tab: TabData? = null, tabPosition: Int = 0) { - val frameLayout = FrameLayout(this) val padding = Utils.dpToPx(this, 8) frameLayout.updatePadding(left = padding, right = padding) diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index 8c7dff594..7f81dd9c1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -306,8 +306,9 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener isCreating = false invalidateOptionsMenu() binding.progressBarShare.visibility = View.GONE - if (result) + if (result) { shareFile(file, "image/png") + } }, { error -> isCreating = false diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt index d64784274..7c2a16935 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt @@ -26,7 +26,6 @@ import com.keylesspalace.tusky.entity.MastoList class ListSelectionAdapter(context: Context) : ArrayAdapter(context, R.layout.item_picker_list) { override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { - val binding = if (convertView == null) { ItemPickerListBinding.inflate(LayoutInflater.from(context), parent, false) } else { 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 596c9432d..3e4e1dad9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt @@ -75,7 +75,6 @@ class PollAdapter : RecyclerView.Adapter>() { override fun getItemCount() = pollOptions.size override fun onBindViewHolder(holder: BindingHolder, position: Int) { - val option = pollOptions[position] val resultTextView = holder.binding.statusPollOptionResult 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 d4712159a..7502c24e9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/ReportNotificationViewHolder.kt @@ -35,7 +35,7 @@ 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( diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingDateViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingDateViewHolder.kt index 88ec17d1f..481573068 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingDateViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/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 { diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingTagViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingTagViewHolder.kt index 270ede6c6..f852c46b8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingTagViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/TrendingTagViewHolder.kt @@ -32,7 +32,7 @@ class TrendingTagViewHolder( fun setup( tagViewData: TrendingViewData.Tag, maxTrendingValue: Long, - trendingListener: LinkListener, + trendingListener: LinkListener ) { val reversedHistory = tagViewData.tag.history.reversed() setGraph(reversedHistory, maxTrendingValue) 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 561e5fc0e..ea9075210 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 @@ -107,8 +107,10 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide @Inject lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector + @Inject lateinit var viewModelFactory: ViewModelFactory + @Inject lateinit var draftsAlert: DraftsAlert @@ -134,14 +136,18 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide // fields for scroll animation private var hideFab: Boolean = false private var oldOffset: Int = 0 + @ColorInt private var toolbarColor: Int = 0 + @ColorInt private var statusBarColorTransparent: Int = 0 + @ColorInt private var statusBarColorOpaque: Int = 0 private var avatarSize: Float = 0f + @Px private var titleVisibleHeight: Int = 0 private lateinit var domain: String @@ -342,7 +348,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide binding.accountAppBarLayout.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener { override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) { - if (verticalOffset == oldOffset) { return } @@ -650,10 +655,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide binding.accountSubscribeButton.setOnClickListener { viewModel.changeSubscribingState() } - if (relation.notifying != null) + if (relation.notifying != null) { subscribing = relation.notifying - else if (relation.subscribing != null) + } else if (relation.subscribing != null) { subscribing = relation.subscribing + } } // remove the listener so it doesn't fire on non-user changes @@ -717,7 +723,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide invalidateOptionsMenu() if (loadedAccount?.moved == null) { - binding.accountFollowButton.show() updateFollowButton() updateSubscribeButton() @@ -750,7 +755,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide } if (!viewModel.isSelf) { - val block = menu.findItem(R.id.action_block) block.title = if (blocking) { getString(R.string.action_unblock) @@ -908,7 +912,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide R.id.action_open_as -> { loadedAccount?.let { loadedAccount -> showAccountChooserDialog( - item.title, false, + item.title, + false, object : AccountSelectionListener { override fun onAccountSelected(account: AccountEntity) { openAsAccount(loadedAccount.url, account) @@ -979,7 +984,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide override fun getActionButton(): FloatingActionButton? { return if (!blocking) { binding.accountFloatingActionButton - } else null + } else { + null + } } private fun getFullUsername(account: Account): String { 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 1b4aa7f02..3b85915fa 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 @@ -80,7 +80,6 @@ class AccountViewModel @Inject constructor( private fun obtainRelationship(reload: Boolean = false) { if (relationshipData.value == null || reload) { - relationshipData.postValue(Loading()) mastodonApi.relationships(listOf(accountId)) @@ -209,14 +208,18 @@ class AccountViewModel @Inject constructor( RelationShipAction.MUTE -> relation.copy(muting = true) RelationShipAction.UNMUTE -> relation.copy(muting = false) RelationShipAction.SUBSCRIBE -> { - if (isMastodon) + if (isMastodon) { relation.copy(notifying = true) - else relation.copy(subscribing = true) + } else { + relation.copy(subscribing = true) + } } RelationShipAction.UNSUBSCRIBE -> { - if (isMastodon) + if (isMastodon) { relation.copy(notifying = false) - else relation.copy(subscribing = false) + } else { + relation.copy(subscribing = false) + } } } relationshipData.postValue(Loading(newRelation)) @@ -238,14 +241,18 @@ class AccountViewModel @Inject constructor( ) RelationShipAction.UNMUTE -> mastodonApi.unmuteAccount(accountId) RelationShipAction.SUBSCRIBE -> { - if (isMastodon) + if (isMastodon) { mastodonApi.followAccount(accountId, notify = true) - else mastodonApi.subscribeAccount(accountId) + } else { + mastodonApi.subscribeAccount(accountId) + } } RelationShipAction.UNSUBSCRIBE -> { - if (isMastodon) + if (isMastodon) { mastodonApi.followAccount(accountId, notify = false) - else mastodonApi.unsubscribeAccount(accountId) + } else { + mastodonApi.unsubscribeAccount(accountId) + } } } @@ -294,12 +301,14 @@ class AccountViewModel @Inject constructor( } private fun reload(isReload: Boolean = false) { - if (isDataLoading) + if (isDataLoading) { return + } accountId.let { obtainAccount(isReload) - if (!isSelf) + if (!isSelf) { obtainRelationship(isReload) + } } } 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 874d4b9f2..d527f613d 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 @@ -65,7 +65,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable { dialog?.apply { window?.setLayout( LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT ) } } @@ -172,7 +172,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 b571390e5..110096966 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,14 +75,14 @@ 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 } ) } ) 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 60c767436..0ed67cf45 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 @@ -26,7 +26,6 @@ class AccountMediaPagingSource( override fun getRefreshKey(state: PagingState): String? = null override suspend fun load(params: LoadParams): LoadResult { - return if (params is LoadParams.Refresh) { val list = viewModel.attachmentData.toList() LoadResult.Page(list, null, list.lastOrNull()?.statusId) 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 81865b0fe..315b0380c 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 @@ -34,7 +34,6 @@ class AccountMediaRemoteMediator( loadType: LoadType, state: PagingState ): MediatorResult { - try { val statusResponse = when (loadType) { LoadType.REFRESH -> { 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 2649cbfe6..eab95b13a 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 @@ -63,6 +63,7 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct @Inject lateinit var api: MastodonApi + @Inject lateinit var accountManager: AccountManager @@ -83,7 +84,6 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - binding.recyclerView.setHasFixedSize(true) val layoutManager = LinearLayoutManager(view.context) binding.recyclerView.layoutManager = layoutManager @@ -227,7 +227,6 @@ class AccountListFragment : Fragment(R.layout.fragment_account_list), AccountAct accountId: String, position: Int ) { - if (accept) { api.authorizeFollowRequest(accountId) } else { 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 55a37cfb4..7d050e7e4 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 @@ -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 f769af344..2ef520d5e 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,7 +30,7 @@ class BlocksAdapter( accountActionListener: AccountActionListener, animateAvatar: Boolean, animateEmojis: Boolean, - showBotOverlay: Boolean, + showBotOverlay: Boolean ) : AccountAdapter>( accountActionListener = accountActionListener, animateAvatar = animateAvatar, 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 ab20d748a..a6bde57b9 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 @@ -36,7 +36,9 @@ class FollowRequestsAdapter( override fun createAccountViewHolder(parent: ViewGroup): FollowRequestViewHolder { val binding = ItemFollowRequestBinding.inflate( - LayoutInflater.from(parent.context), parent, false + LayoutInflater.from(parent.context), + parent, + false ) return FollowRequestViewHolder( binding, 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 c7e6781a1..8abad91ac 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 @@ -107,8 +107,7 @@ class AnnouncementsViewModel @Inject constructor( } else { listOf( *announcement.reactions.toTypedArray(), - emojis.value!!.find { emoji -> emoji.shortcode == name } - !!.run { + emojis.value!!.find { emoji -> emoji.shortcode == name }!!.run { Announcement.Reaction( name, 1, 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 daacc711d..56d38abc9 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 @@ -812,25 +812,26 @@ class ComposeActivity : } private fun onMediaPick() { - addMediaBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { - override fun onStateChanged(bottomSheet: View, newState: Int) { - // Wait until bottom sheet is not collapsed and show next screen after - if (newState == BottomSheetBehavior.STATE_COLLAPSED) { - addMediaBehavior.removeBottomSheetCallback(this) - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission(this@ComposeActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions( - this@ComposeActivity, - arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), - PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE - ) - } else { - pickMediaFile.launch(true) + addMediaBehavior.addBottomSheetCallback( + object : BottomSheetBehavior.BottomSheetCallback() { + override fun onStateChanged(bottomSheet: View, newState: Int) { + // Wait until bottom sheet is not collapsed and show next screen after + if (newState == BottomSheetBehavior.STATE_COLLAPSED) { + addMediaBehavior.removeBottomSheetCallback(this) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission(this@ComposeActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + this@ComposeActivity, + arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), + PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE + ) + } else { + pickMediaFile.launch(true) + } } } - } - override fun onSlide(bottomSheet: View, slideOffset: Float) {} - } + override fun onSlide(bottomSheet: View, slideOffset: Float) {} + } ) addMediaBehavior.state = BottomSheetBehavior.STATE_COLLAPSED } @@ -953,7 +954,6 @@ class ComposeActivity : binding.composeEditField.error = getString(R.string.error_empty) enableButtons(true, viewModel.editing) } else if (characterCount <= maximumTootCharacters) { - lifecycleScope.launch { viewModel.sendStatus(contentText, spoilerText) deleteDraftAndFinish() @@ -972,7 +972,8 @@ class ComposeActivity : pickMediaFile.launch(true) } else { Snackbar.make( - binding.activityCompose, R.string.error_media_upload_permission, + binding.activityCompose, + R.string.error_media_upload_permission, Snackbar.LENGTH_SHORT ).apply { setAction(R.string.action_retry) { onMediaPick() } @@ -1006,9 +1007,13 @@ class ComposeActivity : private fun enableButton(button: ImageButton, clickable: Boolean, colorActive: Boolean) { button.isEnabled = clickable setDrawableTint( - this, button.drawable, - if (colorActive) android.R.attr.textColorTertiary - else R.attr.textColorDisabled + this, + button.drawable, + if (colorActive) { + android.R.attr.textColorTertiary + } else { + R.attr.textColorDisabled + } ) } @@ -1016,8 +1021,11 @@ class ComposeActivity : binding.addPollTextActionTextView.isEnabled = enable val textColor = MaterialColors.getColor( binding.addPollTextActionTextView, - if (enable) android.R.attr.textColorTertiary - else R.attr.textColorDisabled + if (enable) { + android.R.attr.textColorTertiary + } else { + R.attr.textColorDisabled + } ) binding.addPollTextActionTextView.setTextColor(textColor) binding.addPollTextActionTextView.compoundDrawablesRelative[0].colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) @@ -1193,8 +1201,11 @@ class ComposeActivity : lifecycleScope.launch { val dialog = if (viewModel.shouldShowSaveDraftDialog()) { ProgressDialog.show( - this@ComposeActivity, null, - getString(R.string.saving_draft), true, false + this@ComposeActivity, + null, + getString(R.string.saving_draft), + true, + false ) } else { null 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 81304c412..40b15bc78 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 @@ -274,7 +274,7 @@ class ComposeViewModel @Inject constructor( failedToSendAlert = false, scheduledAt = scheduledAt.value, language = postLanguage, - statusId = originalStatusId, + statusId = originalStatusId ) } @@ -286,7 +286,6 @@ class ComposeViewModel @Inject constructor( content: String, spoilerText: String ) { - if (!scheduledTootId.isNullOrEmpty()) { api.deleteScheduledStatus(scheduledTootId!!) } @@ -405,7 +404,6 @@ class ComposeViewModel @Inject constructor( } fun setup(composeOptions: ComposeActivity.ComposeOptions?) { - if (setupComplete) { return } @@ -440,14 +438,16 @@ class ComposeViewModel @Inject constructor( pickMedia(attachment.uri, attachment.description, attachment.focus) } } - } else composeOptions?.mediaAttachments?.forEach { a -> - // when coming from redraft or ScheduledTootActivity - val mediaType = when (a.type) { - Attachment.Type.VIDEO, Attachment.Type.GIFV -> QueuedMedia.Type.VIDEO - Attachment.Type.UNKNOWN, Attachment.Type.IMAGE -> QueuedMedia.Type.IMAGE - Attachment.Type.AUDIO -> QueuedMedia.Type.AUDIO + } else { + composeOptions?.mediaAttachments?.forEach { a -> + // when coming from redraft or ScheduledTootActivity + val mediaType = when (a.type) { + Attachment.Type.VIDEO, Attachment.Type.GIFV -> QueuedMedia.Type.VIDEO + Attachment.Type.UNKNOWN, Attachment.Type.IMAGE -> QueuedMedia.Type.IMAGE + Attachment.Type.AUDIO -> QueuedMedia.Type.AUDIO + } + addUploadedMedia(a.id, mediaType, a.url.toUri(), a.description, a.meta?.focus) } - addUploadedMedia(a.id, mediaType, a.url.toUri(), a.description, a.meta?.focus) } draftId = composeOptions?.draftId ?: 0 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 4976ae0c5..39b444688 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 @@ -41,7 +41,6 @@ fun downsizeImage( contentResolver: ContentResolver, tempFile: File ): Boolean { - val decodeBoundsInputStream = try { contentResolver.openInputStream(uri) } catch (e: FileNotFoundException) { 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 16daa6dc4..6cd590d7e 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 @@ -90,10 +90,11 @@ class MediaPreviewAdapter( val imageView = holder.progressImageView val focus = item.focus - if (focus != null) + if (focus != null) { imageView.setFocalPoint(focus) - else + } else { imageView.removeFocalPoint() // Probably unnecessary since we have no UI for removal once added. + } var glide = Glide.with(holder.itemView.context) .load(item.uri) @@ -101,8 +102,9 @@ class MediaPreviewAdapter( .dontAnimate() .centerInside() - if (focus != null) + if (focus != null) { glide = glide.addListener(imageView) + } glide.into(imageView) } 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 eac6d93fa..58c3cf2a0 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 @@ -159,7 +159,6 @@ class MediaUploader @Inject constructor( try { when (inUri.scheme) { ContentResolver.SCHEME_CONTENT -> { - mimeType = contentResolver.getType(uri) val suffix = "." + MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType ?: "tmp") @@ -278,7 +277,8 @@ class MediaUploader @Inject constructor( var lastProgress = -1 val fileBody = ProgressRequestBody( - stream!!, media.mediaSize, + stream!!, + media.mediaSize, mimeType.toMediaTypeOrNull()!! ) { percentage -> if (percentage != lastProgress) { 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 4d7c0f818..35dc7a192 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 @@ -35,7 +35,6 @@ fun showAddPollDialog( maxDuration: Int, onUpdatePoll: (NewPoll) -> Unit ) { - val binding = DialogAddPollBinding.inflate(LayoutInflater.from(context)) val dialog = AlertDialog.Builder(context) 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 d5ece95f4..3234f4be3 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 @@ -67,7 +67,8 @@ class CaptionDialog : DialogFragment() { input = EditText(context) input.hint = resources.getQuantityString( R.plurals.hint_describe_for_visually_impaired, - MEDIA_DESCRIPTION_CHARACTER_LIMIT, MEDIA_DESCRIPTION_CHARACTER_LIMIT + MEDIA_DESCRIPTION_CHARACTER_LIMIT, + MEDIA_DESCRIPTION_CHARACTER_LIMIT ) dialogLayout.addView(input) (input.layoutParams as LinearLayout.LayoutParams).setMargins(margin, margin, margin, margin) @@ -105,7 +106,7 @@ class CaptionDialog : DialogFragment() { override fun onResourceReady( resource: Drawable, - transition: Transition?, + transition: Transition? ) { imageView.setImageDrawable(resource) } @@ -122,7 +123,7 @@ class CaptionDialog : DialogFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?, + savedInstanceState: Bundle? ): View? { savedInstanceState?.getString(DESCRIPTION_KEY)?.let { input.setText(it) @@ -143,12 +144,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/view/FocusIndicatorView.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/FocusIndicatorView.kt index 477c015c8..6e0b83dc5 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 @@ -27,14 +27,16 @@ class FocusIndicatorView fun setImageSize(width: Int, height: Int) { this.imageSize = Point(width, height) - if (focus != null) + if (focus != null) { invalidate() + } } fun setFocus(focus: Attachment.Focus) { this.focus = focus - if (imageSize != null) + if (imageSize != null) { invalidate() + } } // Assumes setFocus called first @@ -46,8 +48,9 @@ class FocusIndicatorView // so base it on the view width/height whenever the first access occurs. private fun getCircleRadius(): Float { val circleRadius = this.circleRadius - if (circleRadius != null) + if (circleRadius != null) { return circleRadius + } val newCircleRadius = min(this.width, this.height).toFloat() / 4.0f this.circleRadius = newCircleRadius return newCircleRadius @@ -67,8 +70,9 @@ class FocusIndicatorView @SuppressLint("ClickableViewAccessibility") // Android Studio wants us to implement PerformClick for accessibility, but that unfortunately cannot be made meaningful for this widget. override fun onTouchEvent(event: MotionEvent): Boolean { - if (event.actionMasked == MotionEvent.ACTION_CANCEL) + if (event.actionMasked == MotionEvent.ACTION_CANCEL) { return false + } val imageSize = this.imageSize ?: return false 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 24f4130b2..43e8f6ef9 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 @@ -48,7 +48,6 @@ class TootButton fun setStatusVisibility(visibility: Status.Visibility) { if (!smallStyle) { - icon = when (visibility) { Status.Visibility.PUBLIC -> { setText(R.string.action_send_public) 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 876a71ef2..dae0f1631 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 @@ -66,7 +66,7 @@ data class ConversationAccountEntity( displayName = displayName, url = "", avatar = avatar, - emojis = emojis, + emojis = emojis ) } } @@ -96,7 +96,7 @@ data class ConversationStatusEntity( val collapsed: Boolean, val muted: Boolean, val poll: Poll?, - val language: String?, + val language: String? ) { fun toViewData(): StatusViewData.Concrete { @@ -130,11 +130,11 @@ data class ConversationStatusEntity( poll = poll, card = null, language = language, - filtered = null, + filtered = null ), isExpanded = expanded, isShowingContent = showingHiddenContent, - isCollapsed = collapsed, + isCollapsed = collapsed ) } } @@ -178,7 +178,7 @@ fun Status.toEntity( collapsed = contentCollapsed, muted = muted ?: false, poll = poll, - language = language, + language = language ) fun Conversation.toEntity( 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 04e69d4c4..b197084df 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 @@ -87,6 +87,6 @@ fun StatusViewData.Concrete.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/ConversationsRemoteMediator.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRemoteMediator.kt index 921d694b2..b00c99a95 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 @@ -28,7 +28,6 @@ class ConversationsRemoteMediator( loadType: LoadType, state: PagingState ): MediatorResult { - if (loadType == LoadType.PREPEND) { return MediatorResult.Success(endOfPaginationReached = true) } @@ -47,7 +46,6 @@ class ConversationsRemoteMediator( } db.withTransaction { - if (loadType == LoadType.REFRESH) { db.conversationDao().deleteForAccount(activeAccount.id) } 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 b9757a801..2dc802e6a 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 @@ -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") @@ -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 98a288b42..2165f7e0c 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 @@ -51,18 +51,20 @@ class DraftMediaAdapter( holder.imageView.clearFocus() holder.imageView.setImageResource(R.drawable.ic_music_box_preview_24dp) } else { - if (attachment.focus != null) + if (attachment.focus != null) { holder.imageView.setFocalPoint(attachment.focus) - else + } else { holder.imageView.clearFocus() + } var glide = Glide.with(holder.itemView.context) .load(attachment.uri) .diskCacheStrategy(DiskCacheStrategy.NONE) .dontAnimate() .centerInside() - if (attachment.focus != null) + if (attachment.focus != null) { glide = glide.addListener(holder.imageView) + } glide.into(holder.imageView) } 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 18621fd3f..1edf354d6 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 @@ -48,7 +48,6 @@ class DraftsAdapter( ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder { - val binding = ItemDraftBinding.inflate(LayoutInflater.from(parent.context), parent, false) val viewHolder = BindingHolder(binding) 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 41cd2fed4..a7570bc0a 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 @@ -55,7 +55,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 ) } @@ -213,7 +213,7 @@ class EditFilterActivity : BaseActivity() { FilterKeyword( "", binding.phraseEditText.text.toString(), - binding.phraseWholeWord.isChecked, + binding.phraseWholeWord.isChecked ) ) } @@ -234,7 +234,7 @@ class EditFilterActivity : BaseActivity() { keyword, keyword.copy( keyword = binding.phraseEditText.text.toString(), - wholeWord = binding.phraseWholeWord.isChecked, + wholeWord = binding.phraseWholeWord.isChecked ) ) } 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 07e6d25c8..d33031d65 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 @@ -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 @@ -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/FiltersViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt index 7fb07a075..f4791d145 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 @@ -62,7 +62,7 @@ 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() 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 682d39a8a..4cdc9f97a 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 649ca583e..00239a75f 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,7 +13,7 @@ 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, 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 509c9561d..13d8f2d83 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 @@ -30,8 +30,9 @@ class DomainMutesAdapter( override fun getItemCount(): Int { var count = instances.size - if (bottomLoading) + if (bottomLoading) { ++count + } return count } 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 443395be6..7e0476896 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 @@ -99,7 +99,8 @@ class LoginActivity : BaseActivity(), Injectable { } preferences = getSharedPreferences( - getString(R.string.preferences_file_key), Context.MODE_PRIVATE + getString(R.string.preferences_file_key), + Context.MODE_PRIVATE ) binding.loginButton.setOnClickListener { onLoginClick(true) } @@ -168,8 +169,11 @@ class LoginActivity : BaseActivity(), Injectable { lifecycleScope.launch { mastodonApi.authenticateApp( - domain, getString(R.string.app_name), oauthRedirectUri, - OAUTH_SCOPES, getString(R.string.tusky_website) + domain, + getString(R.string.app_name), + oauthRedirectUri, + OAUTH_SCOPES, + getString(R.string.tusky_website) ).fold( { credentials -> // Before we open browser page we save the data. @@ -273,7 +277,12 @@ class LoginActivity : BaseActivity(), Injectable { setLoading(true) mastodonApi.fetchOAuthToken( - domain, clientId, clientSecret, oauthRedirectUri, code, "authorization_code" + domain, + clientId, + clientSecret, + oauthRedirectUri, + code, + "authorization_code" ).fold( { accessToken -> fetchAccountDetails(accessToken, domain, clientId, clientSecret) @@ -293,7 +302,6 @@ class LoginActivity : BaseActivity(), Injectable { clientId: String, clientSecret: String ) { - mastodonApi.accountVerifyCredentials( domain = domain, auth = "Bearer ${accessToken.accessToken}" @@ -349,6 +357,7 @@ class LoginActivity : BaseActivity(), Injectable { const val MODE_DEFAULT = 0 const val MODE_ADDITIONAL_LOGIN = 1 + // "Migration" is used to update the OAuth scope granted to the client const val MODE_MIGRATION = 2 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 b69f81e76..367eab5b8 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 @@ -85,7 +85,7 @@ class OauthLogin : ActivityResultContract() { data class LoginData( val domain: String, val url: Uri, - val oauthRedirectUrl: Uri, + val oauthRedirectUrl: Uri ) : Parcelable sealed class LoginResult : Parcelable { 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 ca19455ba..80cfeded9 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 @@ -30,7 +30,7 @@ import com.keylesspalace.tusky.viewdata.NotificationViewData class FollowViewHolder( private val binding: ItemFollowBinding, - private val notificationActionListener: NotificationActionListener, + private val notificationActionListener: NotificationActionListener ) : NotificationsPagingAdapter.ViewHolder, RecyclerView.ViewHolder(binding.root) { private val avatarRadius42dp = itemView.context.resources.getDimensionPixelSize( R.dimen.avatar_radius_42dp 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 6745579ed..c06d659d0 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 @@ -14,6 +14,7 @@ * see . */ @file:JvmName("PushNotificationHelper") + package com.keylesspalace.tusky.components.notifications import android.app.NotificationManager @@ -163,7 +164,6 @@ suspend fun registerUnifiedPushEndpoint( account: AccountEntity, endpoint: String ) = withContext(Dispatchers.IO) { - // Generate a prime256v1 key pair for WebPush // Decryption is unimplemented for now, since Mastodon uses an old WebPush // standard which does not send needed information for decryption in the payload @@ -173,8 +173,11 @@ suspend fun registerUnifiedPushEndpoint( val auth = CryptoUtil.secureRandomBytesEncoded(16) api.subscribePushNotifications( - "Bearer ${account.accessToken}", account.domain, - endpoint, keyPair.pubkey, auth, + "Bearer ${account.accessToken}", + account.domain, + endpoint, + keyPair.pubkey, + auth, buildSubscriptionData(context, account) ).onFailure { throwable -> Log.w(TAG, "Error setting push endpoint for account ${account.id}", throwable) @@ -195,7 +198,8 @@ suspend fun registerUnifiedPushEndpoint( suspend fun updateUnifiedPushSubscription(context: Context, api: MastodonApi, accountManager: AccountManager, account: AccountEntity) { withContext(Dispatchers.IO) { api.updatePushNotificationSubscription( - "Bearer ${account.accessToken}", account.domain, + "Bearer ${account.accessToken}", + account.domain, 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/preference/AccountPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt index fa1d7392f..d776ec01f 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 @@ -300,7 +300,6 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { 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 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 4212046ad..0ee7ec5db 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 @@ -85,8 +85,11 @@ class StatusViewHolder( val sensitive = viewData.status.sensitive statusViewHelper.setMediasPreview( - statusDisplayOptions, viewData.status.attachments, - sensitive, previewListener, viewState.isMediaShow(viewData.id, viewData.status.sensitive), + statusDisplayOptions, + viewData.status.attachments, + sensitive, + previewListener, + viewState.isMediaShow(viewData.id, viewData.status.sensitive), mediaViewHeight ) @@ -97,8 +100,10 @@ class StatusViewHolder( private fun updateTextView() { viewdata()?.let { viewdata -> setupCollapsedState( - shouldTrimStatus(viewdata.content), viewState.isCollapsed(viewdata.id, true), - viewState.isContentShow(viewdata.id, viewdata.status.sensitive), viewdata.spoilerText + shouldTrimStatus(viewdata.content), + viewState.isCollapsed(viewdata.id, true), + viewState.isContentShow(viewdata.id, viewdata.status.sensitive), + viewdata.spoilerText ) if (viewdata.spoilerText.isBlank()) { 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 314513eb9..7e2c24174 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 @@ -38,7 +38,10 @@ class StatusesAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatusViewHolder { val binding = ItemReportStatusBinding.inflate(LayoutInflater.from(parent.context), parent, false) return StatusViewHolder( - binding, statusDisplayOptions, statusViewState, adapterHandler, + binding, + statusDisplayOptions, + statusViewState, + adapterHandler, statusForPosition ) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportNoteFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportNoteFragment.kt index 74b40fb93..d77685e64 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportNoteFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/fragments/ReportNoteFragment.kt @@ -72,8 +72,9 @@ class ReportNoteFragment : Fragment(R.layout.fragment_report_note), Injectable { binding.reportDescriptionRemoteInstance.hide() } - if (viewModel.isRemoteAccount) + if (viewModel.isRemoteAccount) { binding.checkIsNotifyRemote.text = getString(R.string.report_remote_instance, viewModel.remoteServer) + } binding.checkIsNotifyRemote.isChecked = viewModel.isRemoteNotify } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchActivity.kt index ca60e95c4..176fb8079 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchActivity.kt @@ -75,7 +75,7 @@ class SearchActivity : BottomSheetActivity(), HasAndroidInjector, MenuProvider { binding.pages.isUserInputEnabled = enableSwipeForTabs TabLayoutMediator(binding.tabs, binding.pages) { - tab, position -> + tab, position -> tab.text = getPageTitle(position) }.attach() } 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 5ced44037..10339536a 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 @@ -54,7 +54,6 @@ class SearchPagingSource( val currentKey = params.key ?: 0 try { - val data = mastodonApi.searchObservable( query = searchRequest, type = searchType.apiParameter, 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 23ebbef60..3ee103055 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 @@ -133,7 +133,8 @@ class SearchStatusesFragment : SearchFragment(), Status Attachment.Type.GIFV, Attachment.Type.VIDEO, Attachment.Type.IMAGE, Attachment.Type.AUDIO -> { val attachments = AttachmentViewData.list(actionable) val intent = ViewMediaActivity.newIntent( - context, attachments, + context, + attachments, attachmentIndex ) if (view != null) { @@ -141,7 +142,8 @@ class SearchStatusesFragment : SearchFragment(), Status ViewCompat.setTransitionName(view, url) val options = ActivityOptionsCompat.makeSceneTransitionAnimation( requireActivity(), - view, url + view, + url ) startActivity(intent, options.toBundle()) } else { @@ -399,7 +401,8 @@ class SearchStatusesFragment : SearchFragment(), Status private fun showOpenAsDialog(statusUrl: String, dialogTitle: CharSequence?) { bottomSheetActivity?.showAccountChooserDialog( - dialogTitle, false, + dialogTitle, + false, object : AccountSelectionListener { override fun onAccountSelected(account: AccountEntity) { bottomSheetActivity?.openAsAccount(statusUrl, account) @@ -515,7 +518,7 @@ class SearchStatusesFragment : SearchFragment(), Status 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)) }, 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 b0ae1cf77..90c12307f 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 @@ -170,7 +170,7 @@ class TimelineFragment : viewModel.init( kind, id, - tags, + tags ) isSwipeToRefreshEnabled = arguments.getBoolean(ARG_ENABLE_SWIPE_TO_REFRESH, true) @@ -188,7 +188,11 @@ class TimelineFragment : PrefKeys.SHOW_CARDS_IN_TIMELINES, false ) - ) CardViewMode.INDENTED else CardViewMode.NONE, + ) { + CardViewMode.INDENTED + } else { + CardViewMode.NONE + }, confirmReblogs = preferences.getBoolean(PrefKeys.CONFIRM_REBLOGS, true), confirmFavourites = preferences.getBoolean(PrefKeys.CONFIRM_FAVOURITES, false), hideStats = preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false), @@ -255,7 +259,9 @@ class TimelineFragment : if (getView() != null) { if (isSwipeToRefreshEnabled) { binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) - } else binding.recyclerView.scrollToPosition(0) + } else { + binding.recyclerView.scrollToPosition(0) + } } } } 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 09557a50e..a232989b3 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 @@ -131,8 +131,10 @@ class TimelinePagingAdapter( return if (oldItem == newItem) { // If items are equal - update timestamp only listOf(StatusBaseViewHolder.Key.KEY_CREATED) - } else // If items are different - update the whole view holder + } else { + // If items are different - update the whole view holder null + } } } } 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 d154caaab..04be236ee 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 @@ -105,7 +105,7 @@ fun Placeholder.toEntity(timelineUserId: Long): TimelineStatusEntity { card = null, repliesCount = 0, language = null, - filtered = null, + filtered = null ) } @@ -150,7 +150,7 @@ fun Status.toEntity( card = actionableStatus.card?.let(gson::toJson), repliesCount = actionableStatus.repliesCount, language = actionableStatus.language, - filtered = actionableStatus.filtered, + filtered = actionableStatus.filtered ) } @@ -198,7 +198,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) { @@ -231,7 +231,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( @@ -263,7 +263,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.Concrete( 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 a15577646..89afefecd 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 @@ -49,7 +49,6 @@ class CachedTimelineRemoteMediator( loadType: LoadType, state: PagingState ): MediatorResult { - if (!activeAccount.isLoggedIn()) { return MediatorResult.Success(endOfPaginationReached = true) } 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 7bc47e925..b4cf7b890 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 @@ -204,7 +204,6 @@ class CachedTimelineViewModel @Inject constructor( } db.withTransaction { - timelineDao.delete(activeAccount.id, placeholderId) val overlappedStatuses = if (statuses.isNotEmpty()) { 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 56236ecf8..d1c9ce24e 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 @@ -26,7 +26,6 @@ class NetworkTimelinePagingSource( override fun getRefreshKey(state: PagingState): String? = null override suspend fun load(params: LoadParams): LoadResult { - return if (params is LoadParams.Refresh) { val list = viewModel.statusData.toList() LoadResult.Page(list, null, viewModel.nextKey) 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 82cfd41d4..98da15bea 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 @@ -36,7 +36,6 @@ class NetworkTimelineRemoteMediator( loadType: LoadType, state: PagingState ): MediatorResult { - try { val statusResponse = when (loadType) { LoadType.REFRESH -> { @@ -80,7 +79,6 @@ class NetworkTimelineRemoteMediator( } if (loadType == LoadType.REFRESH && viewModel.statusData.isNotEmpty()) { - val insertPlaceholder = if (statuses.isNotEmpty()) { !viewModel.statusData.removeAll { statusViewData -> statuses.any { status -> status.id == statusViewData.asStatusOrNull()?.id } 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 91d28d803..fde43acf9 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 @@ -183,7 +183,7 @@ class NetworkTimelineViewModel @Inject constructor( .copy( isShowingContent = oldStatus!!.isShowingContent, isExpanded = oldStatus.isExpanded, - isCollapsed = oldStatus.isCollapsed, + isCollapsed = oldStatus.isCollapsed ) } 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 c31606a4d..438939a59 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 @@ -302,7 +302,7 @@ abstract class TimelineViewModel( } else { Log.e(TAG, "Error getting filters", throwable) } - }, + } ) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingAdapter.kt index 3e6f03416..6f405e2f4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingAdapter.kt @@ -28,7 +28,7 @@ import com.keylesspalace.tusky.interfaces.LinkListener import com.keylesspalace.tusky.viewdata.TrendingViewData class TrendingAdapter( - private val trendingListener: LinkListener, + private val trendingListener: LinkListener ) : ListAdapter(TrendingDifferCallback) { init { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingFragment.kt index 41e404a90..4148a1086 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingFragment.kt @@ -95,7 +95,7 @@ class TrendingFragment : super.onCreate(savedInstanceState) adapter = TrendingAdapter( - this, + this ) } @@ -208,7 +208,8 @@ class TrendingFragment : binding.recyclerView.hide() binding.messageView.show() binding.messageView.setup( - R.drawable.elephant_friend_empty, R.string.message_empty, + R.drawable.elephant_friend_empty, + R.string.message_empty, null ) } else { @@ -242,7 +243,7 @@ class TrendingFragment : binding.swipeRefreshLayout.isRefreshing = false binding.messageView.setup( R.drawable.elephant_offline, - R.string.error_network, + R.string.error_network ) { refreshContent() } } @@ -254,7 +255,7 @@ class TrendingFragment : binding.swipeRefreshLayout.isRefreshing = false binding.messageView.setup( R.drawable.elephant_error, - R.string.error_generic, + R.string.error_generic ) { refreshContent() } } 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 3abd47d01..1edffcaf9 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 @@ -93,8 +93,10 @@ class ThreadAdapter( return if (oldItem == newItem) { // If items are equal - update timestamp only listOf(StatusBaseViewHolder.Key.KEY_CREATED) - } else // If items are different - update the whole view holder + } else { + // If items are different - update the whole view holder null + } } } } 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 327931026..7a60c59f5 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 @@ -167,7 +167,7 @@ class ViewThreadViewModel @Inject constructor( _uiState.value = ThreadUiState.Success( statusViewData = listOf(detailedStatus), detailedStatusPosition = 0, - revealButton = RevealButtonState.NO_BUTTON, + revealButton = RevealButtonState.NO_BUTTON ) }) } 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 418c77e32..333920c6c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/AccountEntity.kt @@ -82,7 +82,7 @@ data class AccountEntity( var pushPubKey: String = "", var pushPrivKey: String = "", var pushAuth: String = "", - var pushServerKey: String = "", + var pushServerKey: String = "" ) { 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 eaa36bb72..46805861b 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,6 @@ class AccountManager @Inject constructor(db: AppDatabase) { oauthScopes: String, newAccount: Account ) { - activeAccount?.let { it.isActive = false Log.d(TAG, "addAccount: saving account with id " + it.id) @@ -121,7 +120,6 @@ class AccountManager @Inject constructor(db: AppDatabase) { * @return the new active account, or null if no other account was found */ fun logActiveAccountOut(): AccountEntity? { - return activeAccount?.let { account -> account.logout() @@ -167,7 +165,6 @@ class AccountManager @Inject constructor(db: AppDatabase) { * @param accountId the database id of the new active account */ fun setActiveAccount(accountId: Long) { - val newActiveAccount = accounts.find { (id) -> id == accountId } ?: return // invalid accountId passed, do nothing @@ -237,10 +234,12 @@ class AccountManager @Inject constructor(db: AppDatabase) { fun shouldDisplaySelfUsername(context: Context): Boolean { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val showUsernamePreference = sharedPreferences.getString(PrefKeys.SHOW_SELF_USERNAME, "disambiguate") - if (showUsernamePreference == "always") + if (showUsernamePreference == "always") { return true - if (showUsernamePreference == "never") + } + if (showUsernamePreference == "never") { return false + } return accounts.size > 1 // "disambiguate" } 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 0b38385ae..2a479ab34 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? ) /** 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 0b5fcfb1a..f0f7f98ed 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/TimelineStatusEntity.kt @@ -85,7 +85,7 @@ data class TimelineStatusEntity( val pinned: Boolean, val card: String?, val language: String?, - val filtered: List?, + val filtered: List? ) { val isPlaceholder: Boolean get() = this.authorServerId == null 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 758f8d24c..bc2c7d753 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt @@ -68,7 +68,7 @@ class AppModule { AppDatabase.MIGRATION_38_39, AppDatabase.MIGRATION_39_40, AppDatabase.MIGRATION_40_41, AppDatabase.MIGRATION_41_42, AppDatabase.MIGRATION_42_43, AppDatabase.MIGRATION_43_44, AppDatabase.MIGRATION_44_45, AppDatabase.MIGRATION_45_46, AppDatabase.MIGRATION_46_47, - AppDatabase.MIGRATION_47_48, + AppDatabase.MIGRATION_47_48 ) .build() } 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 fdad077a0..43b9bd9c9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt @@ -43,7 +43,9 @@ data class Account( val name: String get() = if (displayName.isNullOrEmpty()) { localUsername - } else displayName + } else { + displayName + } fun isRemote(): Boolean = this.username != this.localUsername } @@ -53,7 +55,7 @@ data class AccountSource( val sensitive: Boolean?, val note: String?, val fields: List?, - val language: String?, + val language: String? ) data class Field( 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 fa0b978fc..0ebd9c370 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Attachment.kt @@ -39,12 +39,16 @@ data class Attachment( enum class Type { @SerializedName("image") IMAGE, + @SerializedName("gifv") GIFV, + @SerializedName("video") VIDEO, + @SerializedName("audio") AUDIO, + @SerializedName("unknown") UNKNOWN } @@ -70,7 +74,7 @@ data class Attachment( val focus: Focus?, val duration: Float?, val original: Size?, - val small: Size?, + val small: Size? ) : Parcelable /** 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 a653cc587..872379138 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/DeletedStatus.kt @@ -28,7 +28,7 @@ data class DeletedStatus( @SerializedName("media_attachments") val attachments: ArrayList?, 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/Filter.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt index 3e529bfe0..236e216e1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Filter.kt @@ -12,7 +12,7 @@ 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) { 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 131540c14..c62ac4090 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 79179bd05..fa2fa92b3 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: String?, + @SerializedName("status_matches") val statusMatches: String? ) 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 c5b2d1695..a93ccff5e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/FilterV1.kt @@ -57,7 +57,7 @@ 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 67ae89128..77864cfeb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt @@ -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,7 +75,7 @@ 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( 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 9577caef1..1a353eadf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/NewStatus.kt @@ -29,7 +29,7 @@ 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 @@ -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 1bad6697b..a7007e57c 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 */ @@ -70,8 +70,9 @@ data class Notification( @JvmStatic fun byString(s: String): Type { values().forEach { - if (s == it.presentation) + if (s == it.presentation) { return it + } } return UNKNOWN } @@ -115,7 +116,11 @@ data class Notification( return if (status.mentions.any { it.id == accountId } - ) this else copy(type = Type.STATUS) + ) { + this + } else { + copy(type = Type.STATUS) + } } return this } 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 c6eb09bec..6bdaa1438 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/Report.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Report.kt index 0330c102c..8de7b957d 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/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index b6c26f891..f95997461 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -51,7 +51,7 @@ data class Status( val poll: Poll?, val card: Card?, val language: String?, - val filtered: List?, + val filtered: List? ) { val actionableId: String @@ -69,12 +69,16 @@ data class Status( enum class Visibility(val num: Int) { UNKNOWN(0), + @SerializedName("public") PUBLIC(1), + @SerializedName("unlisted") UNLISTED(2), + @SerializedName("private") PRIVATE(3), + @SerializedName("direct") DIRECT(4); @@ -134,7 +138,7 @@ data class Status( attachments = attachments, poll = poll, createdAt = createdAt, - language = language, + language = language ) } 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 aea6bdd47..98a01d8b9 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 224129feb..ba57abb90 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/TimelineAccount.kt @@ -29,11 +29,13 @@ data class TimelineAccount( val url: String, val avatar: String, val bot: Boolean = false, - val emojis: List? = emptyList(), // nullable for backward compatibility + val emojis: List? = emptyList() // nullable for backward compatibility ) { val name: String get() = if (displayName.isNullOrEmpty()) { localUsername - } else displayName + } else { + displayName + } } 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 1c20a5e90..7baca6fe0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/TrendingTagsResult.kt @@ -29,7 +29,7 @@ data class TrendingTag( val name: String, val url: String, val history: List, - val following: Boolean, + val following: Boolean ) /** @@ -42,7 +42,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/fragment/SFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt index b4284b39f..046b54c54 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt @@ -309,7 +309,6 @@ abstract class SFragment : Fragment(), Injectable { } private fun onMute(accountId: String, accountUsername: String) { - showMuteAccountDialog(this.requireActivity(), accountUsername) { notifications: Boolean?, duration: Int? -> lifecycleScope.launch { timelineCases.mute(accountId, notifications == true, duration) @@ -339,7 +338,8 @@ abstract class SFragment : Fragment(), Injectable { view.transitionName = url val options = ActivityOptionsCompat.makeSceneTransitionAnimation( requireActivity(), - view, url + view, + url ) startActivity(intent, options.toBundle()) } else { 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 28cf64ca3..688ce7c58 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt @@ -207,7 +207,7 @@ class ViewImageFragment : ViewMediaFragment() { .dontAnimate() .onlyRetrieveFromCache(true) .let { - if (previewUrl != null) + if (previewUrl != null) { it.thumbnail( glide .load(previewUrl) @@ -216,7 +216,9 @@ class ViewImageFragment : ViewMediaFragment() { .centerInside() .addListener(ImageRequestListener(true, isThumbnailRequest = true)) ) - else it + } else { + it + } } // Request image from the network on fail load image from cache .error( 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 686e4fdfe..2f8aaf1d9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt @@ -42,6 +42,7 @@ abstract class ViewMediaFragment : Fragment() { @JvmStatic protected val ARG_ATTACHMENT = "attach" + @JvmStatic protected val ARG_SINGLE_IMAGE_URL = "singleImageUrl" 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 bd8df6b5e..983333a9c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/json/Iso8601Utils.kt @@ -108,7 +108,6 @@ internal fun String.parseIsoDate(): Date { return GregorianCalendar(year, month - 1, day).time } if (hasT) { - // extract hours, minutes, seconds and milliseconds hour = parseInt(this, 1.let { offset += it; offset }, 2.let { offset += it; offset }) if (checkOffset(this, offset, ':')) { diff --git a/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt b/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt index 0d13373a8..26a7141ec 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt @@ -29,8 +29,9 @@ class FilterModel @Inject constructor() { // Patterns are expensive and thread-safe, matchers are neither. val matcher = pattern?.matcher("") ?: return Filter.Action.NONE - if (status.poll?.options?.any { matcher.reset(it.title).find() } == true) + if (status.poll?.options?.any { matcher.reset(it.title).find() } == true) { return Filter.Action.HIDE + } val spoilerText = status.actionableStatus.spoilerText val attachmentsDescriptions = status.attachments.mapNotNull { it.description } diff --git a/app/src/main/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptor.kt b/app/src/main/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptor.kt index 3ca7a8116..6033165f9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptor.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptor.kt @@ -34,7 +34,6 @@ class InstanceSwitchAuthInterceptor(private val accountManager: AccountManager) // only switch domains if the request comes from retrofit return if (originalRequest.url.host == MastodonApi.PLACEHOLDER_DOMAIN) { - val builder: Request.Builder = originalRequest.newBuilder() val instanceHeader = originalRequest.header(MastodonApi.DOMAIN_HEADER) 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 88f5480e4..62b52492f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt @@ -194,7 +194,7 @@ 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}") @@ -298,7 +298,7 @@ interface MastodonApi { @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 @@ -306,7 +306,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 @@ -607,7 +607,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 @@ -617,7 +617,7 @@ 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}") @@ -630,7 +630,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 @@ -638,12 +638,12 @@ 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 @@ -751,7 +751,7 @@ interface MastodonApi { @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}") @@ -762,7 +762,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/receiver/SendStatusBroadcastReceiver.kt b/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt index 0c1d0e37c..3ab941e9d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt +++ b/app/src/main/java/com/keylesspalace/tusky/receiver/SendStatusBroadcastReceiver.kt @@ -97,7 +97,7 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() { idempotencyKey = randomAlphanumericString(16), retries = 0, language = null, - statusId = null, + statusId = null ) ) 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 fd7d32d01..a7b893884 100644 --- a/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt @@ -53,12 +53,16 @@ class SendStatusService : Service(), Injectable { @Inject lateinit var mastodonApi: MastodonApi + @Inject lateinit var accountManager: AccountManager + @Inject lateinit var eventHub: EventHub + @Inject lateinit var draftHelper: DraftHelper + @Inject lateinit var mediaUploader: MediaUploader @@ -111,7 +115,6 @@ class SendStatusService : Service(), Injectable { statusesToSend[sendingNotificationId] = statusToSend sendStatus(sendingNotificationId--) } else { - if (intent.hasExtra(KEY_CANCEL)) { cancelSending(intent.getIntExtra(KEY_CANCEL, 0)) } @@ -121,7 +124,6 @@ class SendStatusService : Service(), Injectable { } private fun sendStatus(statusId: Int) { - // when statusToSend == null, sending has been canceled val statusToSend = statusesToSend[statusId] ?: return @@ -138,7 +140,6 @@ class SendStatusService : Service(), Injectable { statusToSend.retries++ sendJobs[statusId] = serviceScope.launch { - // first, wait for media uploads to finish val media = statusToSend.media.map { mediaItem -> if (mediaItem.id == null) { @@ -174,7 +175,7 @@ class SendStatusService : Service(), Injectable { } } } - mediaCheckRetries ++ + mediaCheckRetries++ } } catch (e: Exception) { Log.w(TAG, "failed getting media status", e) @@ -198,9 +199,9 @@ class SendStatusService : Service(), Injectable { id = media.id!!, description = media.description, focus = media.focus?.toMastodonApiString(), - thumbnail = null, + thumbnail = null ) - }, + } ) val editing = (statusToSend.statusId != null) @@ -266,7 +267,6 @@ class SendStatusService : Service(), Injectable { } private fun stopSelfWhenDone() { - if (statusesToSend.isEmpty()) { ServiceCompat.stopForeground(this@SendStatusService, ServiceCompat.STOP_FOREGROUND_REMOVE) stopSelf() @@ -276,7 +276,6 @@ class SendStatusService : Service(), Injectable { private suspend fun failSending(statusId: Int) { val failedStatus = statusesToSend.remove(statusId) if (failedStatus != null) { - mediaUploader.cancelUploadScope(*failedStatus.media.map { it.localId }.toIntArray()) saveStatusToDrafts(failedStatus, failedToSendAlert = true) @@ -296,7 +295,6 @@ class SendStatusService : Service(), Injectable { private fun cancelSending(statusId: Int) = serviceScope.launch { val statusToCancel = statusesToSend.remove(statusId) if (statusToCancel != null) { - mediaUploader.cancelUploadScope(*statusToCancel.media.map { it.localId }.toIntArray()) val sendJob = sendJobs.remove(statusId) @@ -336,7 +334,7 @@ class SendStatusService : Service(), Injectable { failedToSendAlert = failedToSendAlert, scheduledAt = status.scheduledAt, language = status.language, - statusId = status.statusId, + statusId = status.statusId ) } @@ -357,7 +355,6 @@ class SendStatusService : Service(), Injectable { accountId: Long, statusId: Int ): Notification { - val intent = Intent(this, MainActivity::class.java) intent.putExtra(NotificationHelper.ACCOUNT_ID, accountId) intent.putExtra(MainActivity.OPEN_DRAFTS, true) @@ -442,7 +439,7 @@ data class StatusToSend( val idempotencyKey: String, var retries: Int, val language: String?, - val statusId: String?, + val statusId: String? ) : Parcelable @Parcelize diff --git a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceHandler.kt b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceHandler.kt index 3d6b0c15f..802f0ba8f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceHandler.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/AccountPreferenceHandler.kt @@ -9,7 +9,7 @@ import com.keylesspalace.tusky.db.AccountManager class AccountPreferenceHandler( private val account: AccountEntity, private val accountManager: AccountManager, - private val eventHub: EventHub, + private val eventHub: EventHub ) : PreferenceDataStore() { override fun getBoolean(key: String, defValue: Boolean): Boolean { 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 f1e04bd56..fbe8084bc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt +++ b/app/src/main/java/com/keylesspalace/tusky/settings/ProxyConfiguration.kt @@ -14,9 +14,13 @@ class ProxyConfiguration private constructor( return null } fun isValidProxyPort(value: Any): Boolean = when (value) { - is String -> if (value == "") true else value.runCatching(String::toInt).map( - PROXY_RANGE::contains - ).getOrDefault(false) + is String -> if (value == "") { + true + } else { + value.runCatching(String::toInt).map( + PROXY_RANGE::contains + ).getOrDefault(false) + } is Int -> PROXY_RANGE.contains(value) else -> false } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt index b36329044..f53aae37a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt @@ -14,6 +14,7 @@ * see . */ @file:JvmName("CustomEmojiHelper") + package com.keylesspalace.tusky.util import android.graphics.Canvas @@ -39,8 +40,9 @@ import java.util.regex.Pattern * @return the text with the shortcodes replaced by EmojiSpans */ fun CharSequence.emojify(emojis: List?, view: View, animate: Boolean): CharSequence { - if (emojis.isNullOrEmpty()) + if (emojis.isNullOrEmpty()) { return this + } val builder = SpannableStringBuilder.valueOf(this) 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 4f5e9920b..a5ccd35be 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/HttpHeaderLink.kt @@ -24,7 +24,9 @@ import androidx.core.net.toUri * * @see [RFC5988](https://tools.ietf.org/html/rfc5988) */ -class HttpHeaderLink @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) constructor( +class HttpHeaderLink +@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) +constructor( uri: String ) { data class Parameter(val name: String, val value: String?) 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 005554bfa..ece76bdfd 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 1cd9b99ac..1430801c2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ImageLoadingHelper.kt @@ -14,7 +14,6 @@ import com.keylesspalace.tusky.R private val centerCropTransformation = CenterCrop() fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boolean) { - if (url.isNullOrBlank()) { Glide.with(imageView) .load(R.drawable.avatar_default) 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 80deb344c..9402edd03 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ListStatusAccessibilityDelegate.kt @@ -196,7 +196,8 @@ class ListStatusAccessibilityDelegate( .setAdapter( ArrayAdapter( host.context, - android.R.layout.simple_list_item_1, stringMentions + android.R.layout.simple_list_item_1, + stringMentions ) ) { _, which -> statusActionListener.onViewAccount(mentions[which].id) @@ -213,7 +214,8 @@ class ListStatusAccessibilityDelegate( .setAdapter( ArrayAdapter( host.context, - android.R.layout.simple_list_item_1, tags + android.R.layout.simple_list_item_1, + tags ) ) { _, which -> statusActionListener.onViewTag(tags[which].toString()) 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 6795317b2..8a5dc3d26 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/LocaleManager.kt @@ -54,7 +54,6 @@ class LocaleManager @Inject constructor( } override fun putString(key: String?, value: String?) { - // if we are on Android < 13 we have to save the selected language so we can apply it at appstart // on Android 13+ the system handles it for us if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { 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 408f64535..b01200bb5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.kt @@ -87,7 +87,6 @@ fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeig var inSampleSize = 1 if (height > reqHeight || width > reqWidth) { - val halfHeight = height / 2 val halfWidth = width / 2 @@ -130,8 +129,13 @@ fun reorientBitmap(bitmap: Bitmap?, orientation: Int): Bitmap? { return try { val result = Bitmap.createBitmap( - bitmap, 0, 0, bitmap.width, - bitmap.height, matrix, true + bitmap, + 0, + 0, + bitmap.width, + bitmap.height, + matrix, + true ) if (!bitmap.sameAs(result)) { bitmap.recycle() diff --git a/app/src/main/java/com/keylesspalace/tusky/util/NotificationTypeConverter.kt b/app/src/main/java/com/keylesspalace/tusky/util/NotificationTypeConverter.kt index 34e8924f8..969deba47 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/NotificationTypeConverter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/NotificationTypeConverter.kt @@ -37,8 +37,9 @@ fun deserialize(data: String?): Set { for (i in 0 until array.length()) { val item = array.getString(i) val type = Notification.Type.byString(item) - if (type != Notification.Type.UNKNOWN) + if (type != Notification.Type.UNKNOWN) { ret.add(type) + } } } return ret diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ShareShortcutHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/ShareShortcutHelper.kt index ee6874964..9d8e4b238 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ShareShortcutHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ShareShortcutHelper.kt @@ -35,9 +35,7 @@ import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.schedulers.Schedulers fun updateShortcut(context: Context, account: AccountEntity) { - Single.fromCallable { - val innerSize = context.resources.getDimensionPixelSize(R.dimen.adaptive_bitmap_inner_size) val outerSize = context.resources.getDimensionPixelSize(R.dimen.adaptive_bitmap_outer_size) @@ -94,6 +92,5 @@ fun updateShortcut(context: Context, account: AccountEntity) { } fun removeShortcut(context: Context, account: AccountEntity) { - ShortcutManagerCompat.removeDynamicShortcuts(context, listOf(account.id.toString())) } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt index 5e5100341..c7b583e57 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt @@ -89,7 +89,6 @@ object SmartLengthInputFilter : InputFilter { keep = boundary } else { - // If no runway is allowed simply remove whitespace if present while (source[keep - 1].isWhitespace()) { --keep 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 9bb3b41a9..cba176131 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt @@ -43,7 +43,7 @@ private enum class FoundMatchType { HTTP_URL, HTTPS_URL, TAG, - MENTION, + MENTION } private class FindCharsResult { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StatusParsingHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/StatusParsingHelper.kt index 18c95c8ad..b8c3c6a0d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusParsingHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusParsingHelper.kt @@ -14,6 +14,7 @@ * see . */ @file:JvmName("StatusParsingHelper") + package com.keylesspalace.tusky.util import android.text.Html.TagHandler 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 7594e8ed6..2148a3b4c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt @@ -53,7 +53,6 @@ class StatusViewHelper(private val itemView: View) { showingContent: Boolean, mediaPreviewHeight: Int ) { - val context = itemView.context val mediaPreviews = arrayOf( itemView.findViewById(R.id.status_media_preview_0), @@ -110,9 +109,11 @@ class StatusViewHelper(private val itemView: View) { .centerInside() .into(mediaPreviews[i]) } else { - val placeholder = if (attachment.blurhash != null) + val placeholder = if (attachment.blurhash != null) { decodeBlurHash(context, attachment.blurhash) - else mediaPreviewUnloaded + } else { + mediaPreviewUnloaded + } val meta = attachment.meta val focus = meta?.focus if (showingContent) { @@ -185,8 +186,12 @@ class StatusViewHelper(private val itemView: View) { v.visibility = View.GONE sensitiveMediaWarning.visibility = View.VISIBLE setMediasPreview( - statusDisplayOptions, attachments, sensitive, previewListener, - false, mediaPreviewHeight + statusDisplayOptions, + attachments, + sensitive, + previewListener, + false, + mediaPreviewHeight ) } sensitiveMediaWarning.setOnClickListener { v -> @@ -194,8 +199,12 @@ class StatusViewHelper(private val itemView: View) { v.visibility = View.GONE sensitiveMediaShow.visibility = View.VISIBLE setMediasPreview( - statusDisplayOptions, attachments, sensitive, previewListener, - true, mediaPreviewHeight + statusDisplayOptions, + attachments, + sensitive, + previewListener, + true, + mediaPreviewHeight ) } } 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 37e0854be..1d630f39b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.kt @@ -67,13 +67,13 @@ fun Notification.toViewData( this.id, this.account, this.status?.toViewData(isShowingContent, isExpanded, isCollapsed), - this.report, + this.report ) } @JvmName("tagToViewData") fun TrendingTag.toViewData(): TrendingViewData.Tag { return TrendingViewData.Tag( - tag = this, + tag = this ) } 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 cc779432d..565d58a30 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt @@ -34,7 +34,7 @@ class GraphView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, - defStyleRes: Int = 0, + defStyleRes: Int = 0 ) : AppCompatImageView(context, attrs, defStyleAttr) { @get:ColorInt @ColorInt @@ -69,22 +69,54 @@ class GraphView @JvmOverloads constructor( private var secondaryLinePath: Path = Path() var maxTrendingValue: Long = 300 - var primaryLineData: List = if (isInEditMode) listOf( - 30, 60, 70, 80, 130, 190, 80, - ) else listOf( - 1, 1, 1, 1, 1, 1, 1, - ) + var primaryLineData: List = if (isInEditMode) { + listOf( + 30, + 60, + 70, + 80, + 130, + 190, + 80 + ) + } else { + listOf( + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ) + } set(value) { field = value.map { max(1, it) } primaryLinePath.reset() invalidate() } - var secondaryLineData: List = if (isInEditMode) listOf( - 10, 20, 40, 60, 100, 132, 20, - ) else listOf( - 1, 1, 1, 1, 1, 1, 1, - ) + var secondaryLineData: List = if (isInEditMode) { + listOf( + 10, + 20, + 40, + 60, + 100, + 132, + 20 + ) + } else { + listOf( + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ) + } set(value) { field = value.map { max(1, it) } secondaryLinePath.reset() @@ -101,7 +133,7 @@ class GraphView @JvmOverloads constructor( context, a.getResourceId( R.styleable.GraphView_primaryLineColor, - R.color.tusky_blue, + R.color.tusky_blue ) ) @@ -109,7 +141,7 @@ class GraphView @JvmOverloads constructor( context, a.getResourceId( R.styleable.GraphView_secondaryLineColor, - R.color.tusky_red, + R.color.tusky_red ) ) @@ -122,7 +154,7 @@ class GraphView @JvmOverloads constructor( context, a.getResourceId( R.styleable.GraphView_graphColor, - R.color.colorBackground, + R.color.colorBackground ) ) @@ -130,13 +162,13 @@ class GraphView @JvmOverloads constructor( context, a.getResourceId( R.styleable.GraphView_metaColor, - R.color.dividerColor, + R.color.dividerColor ) ) proportionalTrending = a.getBoolean( R.styleable.GraphView_proportionalTrending, - proportionalTrending, + proportionalTrending ) } @@ -271,14 +303,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 ) } } @@ -288,12 +320,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 6d553a26c..394cd3692 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/LicenseCard.kt @@ -40,12 +40,15 @@ class LicenseCard setCardBackgroundColor(MaterialColors.getColor(context, com.google.android.material.R.attr.colorSurface, Color.BLACK)) val (name, license, link) = context.theme.obtainStyledAttributes( - attrs, R.styleable.LicenseCard, 0, 0 + attrs, + R.styleable.LicenseCard, + 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 dc149e4be..717bd1441 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/MediaPreviewImageView.kt @@ -119,9 +119,12 @@ open class MediaPreviewImageView if (drawable != null && focus != null && focalMatrix != null) { scaleType = ScaleType.MATRIX FocalPointUtil.updateFocalPointMatrix( - width.toFloat(), height.toFloat(), - drawable.intrinsicWidth.toFloat(), drawable.intrinsicHeight.toFloat(), - focus as Attachment.Focus, focalMatrix as Matrix + width.toFloat(), + height.toFloat(), + drawable.intrinsicWidth.toFloat(), + drawable.intrinsicHeight.toFloat(), + focus as Attachment.Focus, + focalMatrix as Matrix ) imageMatrix = focalMatrix } 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 3dc5ca10c..7281bf060 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt @@ -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 ) } 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 b4ce41857..5ef3ef373 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt @@ -43,7 +43,7 @@ sealed class StatusViewData { * @return Whether the post is collapsed or fully expanded. */ val isCollapsed: Boolean, - val isDetailed: Boolean = false, + val isDetailed: Boolean = false ) : StatusViewData() { override 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 3c5965125..c018aebce 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/TrendingViewData.kt @@ -25,7 +25,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() 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 887766065..fe5110381 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt @@ -72,7 +72,6 @@ class EditProfileViewModel @Inject constructor( fun obtainProfile() = viewModelScope.launch { if (profileData.value == null || profileData.value is Error) { - profileData.postValue(Loading()) mastodonApi.accountVerifyCredentials().fold( @@ -100,7 +99,6 @@ class EditProfileViewModel @Inject constructor( } fun save(newDisplayName: String, newNote: String, newLocked: Boolean, newFields: List) { - if (saveData.value is Loading || profileData.value !is Success) { return } @@ -176,7 +174,8 @@ class EditProfileViewModel @Inject constructor( val newProfileSource = profileData.value?.data?.source?.copy(note = newNote, fields = newFields) val newProfile = profileData.value?.data?.copy( displayName = newDisplayName, - locked = newLocked, source = newProfileSource + locked = newLocked, + source = newProfileSource ) profileData.postValue(Success(newProfile)) 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 4c755f868..f701847c6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt @@ -72,8 +72,11 @@ internal class ListsViewModel @Inject constructor(private val api: MastodonApi) { err -> updateState { copy( - loadingState = if (err is IOException || err is ConnectException) - LoadingState.ERROR_NETWORK else LoadingState.ERROR_OTHER + loadingState = if (err is IOException || err is ConnectException) { + LoadingState.ERROR_NETWORK + } else { + LoadingState.ERROR_OTHER + } ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt index 0c655262e..bbc5c9305 100644 --- a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt @@ -90,13 +90,12 @@ class BottomSheetActivityTest { poll = null, card = null, language = null, - filtered = null, + filtered = null ) private val statusSingle = Single.just(SearchResult(emptyList(), listOf(status), emptyList())) @Before fun setup() { - RxJavaPlugins.setIoSchedulerHandler { testScheduler } RxAndroidPlugins.setMainThreadSchedulerHandler { testScheduler } diff --git a/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt b/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt index f51c9f0b6..a3e5c8979 100644 --- a/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt +++ b/app/src/test/java/com/keylesspalace/tusky/FilterV1Test.kt @@ -100,7 +100,7 @@ class FilterV1Test { expiresAt = null, irreversible = false, wholeWord = false - ), + ) ) filterModel.initWithFilters(filters) @@ -191,7 +191,7 @@ 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") ) ) ) @@ -314,7 +314,9 @@ class FilterV1Test { ) } ) - } else arrayListOf(), + } else { + arrayListOf() + }, mentions = listOf(), tags = listOf(), application = null, @@ -334,10 +336,12 @@ class FilterV1Test { voted = false, ownVotes = null ) - } else 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 444da0619..89bcf7add 100644 --- a/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/FocalPointUtilTest.kt @@ -29,14 +29,17 @@ class FocalPointUtilTest { fun positiveFocalXToCoordinateTest() { assertEquals(FocalPointUtil.focalXToCoordinate(0.4f), 0.7f, eps) } + @Test fun negativeFocalXToCoordinateTest() { assertEquals(FocalPointUtil.focalXToCoordinate(-0.8f), 0.1f, eps) } + @Test fun positiveFocalYToCoordinateTest() { assertEquals(FocalPointUtil.focalYToCoordinate(-0.2f), 0.6f, eps) } + @Test fun negativeFocalYToCoordinateTest() { assertEquals(FocalPointUtil.focalYToCoordinate(0.0f), 0.5f, eps) @@ -47,25 +50,33 @@ class FocalPointUtilTest { fun isVerticalCropTest() { assertTrue( FocalPointUtil.isVerticalCrop( - 2f, 1f, - 1f, 2f + 2f, + 1f, + 1f, + 2f ) ) } + @Test fun isHorizontalCropTest() { assertFalse( FocalPointUtil.isVerticalCrop( - 1f, 2f, - 2f, 1f + 1f, + 2f, + 2f, + 1f ) ) } + @Test fun isPerfectFitTest() { // Doesn't matter what it returns, just check it doesn't crash FocalPointUtil.isVerticalCrop( - 3f, 1f, - 6f, 2f + 3f, + 1f, + 6f, + 2f ) } @@ -74,60 +85,83 @@ class FocalPointUtilTest { fun perfectFitScaleDownTest() { assertEquals( FocalPointUtil.calculateScaling( - 2f, 5f, - 5f, 12.5f + 2f, + 5f, + 5f, + 12.5f ), - 0.4f, eps + 0.4f, + eps ) } + @Test fun perfectFitScaleUpTest() { assertEquals( FocalPointUtil.calculateScaling( - 2f, 5f, - 1f, 2.5f + 2f, + 5f, + 1f, + 2.5f ), - 2f, eps + 2f, + eps ) } + @Test fun verticalCropScaleUpTest() { assertEquals( FocalPointUtil.calculateScaling( - 2f, 1f, - 1f, 2f + 2f, + 1f, + 1f, + 2f ), - 2f, eps + 2f, + eps ) } + @Test fun verticalCropScaleDownTest() { assertEquals( FocalPointUtil.calculateScaling( - 4f, 3f, - 8f, 24f + 4f, + 3f, + 8f, + 24f ), - 0.5f, eps + 0.5f, + eps ) } + @Test fun horizontalCropScaleUpTest() { assertEquals( FocalPointUtil.calculateScaling( - 1f, 2f, - 2f, 1f + 1f, + 2f, + 2f, + 1f ), - 2f, eps + 2f, + eps ) } + @Test fun horizontalCropScaleDownTest() { assertEquals( FocalPointUtil.calculateScaling( - 3f, 4f, - 24f, 8f + 3f, + 4f, + 24f, + 8f ), - 0.5f, eps + 0.5f, + eps ) } @@ -136,21 +170,26 @@ class FocalPointUtilTest { fun toLowFocalOffsetTest() { assertEquals( FocalPointUtil.focalOffset(2f, 8f, 1f, 0.05f), - 0f, eps + 0f, + eps ) } + @Test fun toHighFocalOffsetTest() { assertEquals( FocalPointUtil.focalOffset(2f, 4f, 2f, 0.95f), - -6f, eps + -6f, + eps ) } + @Test fun possibleFocalOffsetTest() { assertEquals( FocalPointUtil.focalOffset(2f, 4f, 2f, 0.7f), - -4.6f, eps + -4.6f, + eps ) } } diff --git a/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt index 09927d209..73ce0c1f5 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, @@ -104,7 +104,7 @@ class MainActivityTest { avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg" ), status = null, - report = null, + report = null ), accountEntity, true diff --git a/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt index 6910a365f..518af95f6 100644 --- a/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/StringUtilsTest.kt @@ -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/timeline/CachedTimelineRemoteMediatorTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/timeline/CachedTimelineRemoteMediatorTest.kt index 00802caba..ad7bffd38 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 @@ -74,7 +74,6 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should return error when network call returns error code`() { - val remoteMediator = CachedTimelineRemoteMediator( accountManager = accountManager, api = mock { @@ -94,7 +93,6 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should return error when network call fails`() { - val remoteMediator = CachedTimelineRemoteMediator( accountManager = accountManager, api = mock { @@ -113,7 +111,6 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should not prepend statuses`() { - val remoteMediator = CachedTimelineRemoteMediator( accountManager = accountManager, api = mock(), @@ -142,11 +139,10 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should refresh and insert placeholder when a whole page with no overlap to existing statuses is loaded`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) db.insert(statusesAlreadyInDb) @@ -198,7 +194,7 @@ class CachedTimelineRemoteMediatorTest { ), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) ) } @@ -206,11 +202,10 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should refresh and not insert placeholder when less than a whole page is loaded`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) db.insert(statusesAlreadyInDb) @@ -259,7 +254,7 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("5"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) ) } @@ -267,11 +262,10 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should refresh and not insert placeholders when there is overlap with existing statuses`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) db.insert(statusesAlreadyInDb) @@ -320,7 +314,7 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("4"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) ) } @@ -328,7 +322,6 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should not try to refresh already cached statuses when db is empty`() { - val remoteMediator = CachedTimelineRemoteMediator( accountManager = accountManager, api = mock { @@ -371,11 +364,10 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should remove deleted status from db and keep state of other cached statuses`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("3", expanded = true), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1", expanded = false), + mockStatusEntityWithAccount("1", expanded = false) ) db.insert(statusesAlreadyInDb) @@ -422,12 +414,11 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should not remove placeholder in timeline`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("8"), mockStatusEntityWithAccount("7"), mockPlaceholderEntityWithAccount("6"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) db.insert(statusesAlreadyInDb) @@ -474,7 +465,7 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("8"), mockStatusEntityWithAccount("7"), mockPlaceholderEntityWithAccount("6"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) ) } @@ -482,11 +473,10 @@ class CachedTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should append statuses`() { - val statusesAlreadyInDb = listOf( mockStatusEntityWithAccount("8"), mockStatusEntityWithAccount("7"), - mockStatusEntityWithAccount("5"), + mockStatusEntityWithAccount("5") ) db.insert(statusesAlreadyInDb) @@ -527,7 +517,7 @@ class CachedTimelineRemoteMediatorTest { mockStatusEntityWithAccount("5"), mockStatusEntityWithAccount("3"), mockStatusEntityWithAccount("2"), - mockStatusEntityWithAccount("1"), + mockStatusEntityWithAccount("1") ) ) } 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 808540dec..9722fa5a8 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 @@ -47,7 +47,6 @@ class NetworkTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should return error when network call returns error code`() { - val timelineViewModel: NetworkTimelineViewModel = mock { on { statusData } doReturn mutableListOf() onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doReturn Response.error(500, "".toResponseBody()) @@ -65,7 +64,6 @@ class NetworkTimelineRemoteMediatorTest { @Test @ExperimentalPagingApi fun `should return error when network call fails`() { - val timelineViewModel: NetworkTimelineViewModel = mock { on { statusData } doReturn mutableListOf() onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doThrow IOException() @@ -94,7 +92,8 @@ class NetworkTimelineRemoteMediatorTest { mockStatus("5") ), Headers.headersOf( - "Link", "; rel=\"next\", ; rel=\"prev\"" + "Link", + "; rel=\"next\", ; rel=\"prev\"" ) ) } @@ -116,7 +115,7 @@ class NetworkTimelineRemoteMediatorTest { val newStatusData = mutableListOf( mockStatusViewData("7"), mockStatusViewData("6"), - mockStatusViewData("5"), + mockStatusViewData("5") ) verify(timelineViewModel).nextKey = "4" @@ -131,7 +130,7 @@ class NetworkTimelineRemoteMediatorTest { val statuses: MutableList = mutableListOf( mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) val timelineViewModel: NetworkTimelineViewModel = mock { @@ -154,7 +153,7 @@ class NetworkTimelineRemoteMediatorTest { data = listOf( mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ), prevKey = null, nextKey = "0" @@ -169,7 +168,7 @@ class NetworkTimelineRemoteMediatorTest { mockStatusViewData("4"), mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) assertTrue(result is RemoteMediator.MediatorResult.Success) @@ -183,7 +182,7 @@ class NetworkTimelineRemoteMediatorTest { val statuses: MutableList = mutableListOf( mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) val timelineViewModel: NetworkTimelineViewModel = mock { @@ -206,7 +205,7 @@ class NetworkTimelineRemoteMediatorTest { data = listOf( mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ), prevKey = null, nextKey = "0" @@ -222,7 +221,7 @@ class NetworkTimelineRemoteMediatorTest { StatusViewData.Placeholder("7", false), mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) assertTrue(result is RemoteMediator.MediatorResult.Success) @@ -236,7 +235,7 @@ class NetworkTimelineRemoteMediatorTest { val statuses: MutableList = mutableListOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ) val timelineViewModel: NetworkTimelineViewModel = mock { @@ -259,7 +258,7 @@ class NetworkTimelineRemoteMediatorTest { data = listOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ), prevKey = null, nextKey = "3" @@ -275,7 +274,7 @@ class NetworkTimelineRemoteMediatorTest { mockStatusViewData("5"), mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) assertTrue(result is RemoteMediator.MediatorResult.Success) @@ -289,7 +288,7 @@ class NetworkTimelineRemoteMediatorTest { val statuses: MutableList = mutableListOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ) val timelineViewModel: NetworkTimelineViewModel = mock { @@ -302,7 +301,8 @@ class NetworkTimelineRemoteMediatorTest { mockStatus("1") ), Headers.headersOf( - "Link", "; rel=\"next\", ; rel=\"prev\"" + "Link", + "; rel=\"next\", ; rel=\"prev\"" ) ) } @@ -315,7 +315,7 @@ class NetworkTimelineRemoteMediatorTest { data = listOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ), prevKey = null, nextKey = "3" @@ -331,7 +331,7 @@ class NetworkTimelineRemoteMediatorTest { mockStatusViewData("5"), mockStatusViewData("3"), mockStatusViewData("2"), - mockStatusViewData("1"), + mockStatusViewData("1") ) verify(timelineViewModel).nextKey = "0" assertTrue(result is RemoteMediator.MediatorResult.Success) @@ -345,7 +345,7 @@ class NetworkTimelineRemoteMediatorTest { val statuses: MutableList = mutableListOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ) val timelineViewModel: NetworkTimelineViewModel = mock { @@ -361,7 +361,7 @@ class NetworkTimelineRemoteMediatorTest { data = listOf( mockStatusViewData("8"), mockStatusViewData("7"), - mockStatusViewData("5"), + mockStatusViewData("5") ), prevKey = null, nextKey = null 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 47f4dbf00..282884976 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 @@ -54,7 +54,7 @@ fun mockStatus( poll = null, card = null, language = null, - filtered = null, + filtered = null ) fun mockStatusViewData( @@ -110,7 +110,7 @@ fun mockStatusEntityWithAccount( fun mockPlaceholderEntityWithAccount( id: String, - userId: Long = 1, + userId: Long = 1 ): TimelineStatusWithAccount { return TimelineStatusWithAccount( status = Placeholder(id, false).toEntity(userId) 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 d48322b2c..fcc49c7cb 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 @@ -146,7 +146,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true) ), detailedStatusPosition = 0, - revealButton = RevealButtonState.NO_BUTTON, + revealButton = RevealButtonState.NO_BUTTON ), viewModel.uiState.first() ) @@ -208,7 +208,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", isExpanded = true) ), detailedStatusPosition = 1, - revealButton = RevealButtonState.HIDE, + revealButton = RevealButtonState.HIDE ), viewModel.uiState.first() ) @@ -232,7 +232,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -256,7 +256,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -280,7 +280,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", bookmarked = false) ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -303,7 +303,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -330,7 +330,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -357,7 +357,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) @@ -384,7 +384,7 @@ class ViewThreadViewModelTest { mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test") ), detailedStatusPosition = 1, - revealButton = RevealButtonState.REVEAL, + revealButton = RevealButtonState.REVEAL ), viewModel.uiState.first() ) 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 4332361a0..ca3bcfa4e 100644 --- a/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/db/TimelineDaoTest.kt @@ -65,7 +65,6 @@ class TimelineDaoTest { @Test fun cleanup() = runBlocking { - val statusesBeforeCleanup = listOf( makeStatus(statusId = 100), makeStatus(statusId = 10, authorServerId = "3"), @@ -80,7 +79,7 @@ class TimelineDaoTest { 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) { @@ -123,7 +122,6 @@ class TimelineDaoTest { @Test fun overwriteDeletedStatus() = runBlocking { - val oldStatuses = listOf( makeStatus(statusId = 3), makeStatus(statusId = 2), @@ -217,7 +215,6 @@ class TimelineDaoTest { @Test fun deleteAllForInstance() = runBlocking { - val statusWithRedDomain1 = makeStatus( statusId = 15, accountId = 1, @@ -283,7 +280,6 @@ class TimelineDaoTest { @Test fun `should return correct topId`() = runBlocking { - val statusData = listOf( makeStatus( statusId = 4, @@ -318,7 +314,6 @@ class TimelineDaoTest { @Test fun `should return correct placeholderId after other ids`() = runBlocking { - val statusData = listOf( makeStatus(statusId = 1000), makePlaceholder(id = 99), @@ -345,7 +340,6 @@ class TimelineDaoTest { @Test fun `should return correct top placeholderId`() = runBlocking { - val statusData = listOf( makeStatus(statusId = 1000), makePlaceholder(id = 99), @@ -398,7 +392,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, @@ -424,7 +418,9 @@ class TimelineDaoTest { emojis = "[]", bot = false ) - } else null + } else { + null + } val card = when (cardUrl) { null -> null @@ -465,7 +461,7 @@ class TimelineDaoTest { pinned = false, card = card, language = null, - filtered = null, + filtered = null ) return Triple(status, author, reblogAuthor) } 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 aa070489d..9a4f737d1 100644 --- a/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/network/InstanceSwitchAuthInterceptorTest.kt @@ -30,7 +30,6 @@ class InstanceSwitchAuthInterceptorTest { @Test fun `should make regular request when requested`() { - mockWebServer.enqueue(MockResponse()) val accountManager: AccountManager = mock { 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 ae62aedcc..e87e2d5f2 100644 --- a/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt @@ -30,7 +30,6 @@ class TimelineCasesTest { @Before fun setup() { - api = mock() eventHub = EventHub() timelineCases = TimelineCases(api, eventHub) @@ -97,7 +96,7 @@ class TimelineCasesTest { poll = null, card = null, language = null, - filtered = null, + filtered = null ) } } 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 bfc4e965c..3b053d017 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)) } @@ -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 da4c48d55..3622770a7 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/LocaleUtilsTest.kt @@ -73,7 +73,7 @@ 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/RickRollTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt index c5bfad426..9a5e8f819 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt @@ -14,6 +14,7 @@ import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) class RickRollTest { private lateinit var activity: Activity + @Before fun setupActivity() { val controller = Robolectric.buildActivity(Activity::class.java) @@ -23,12 +24,12 @@ class RickRollTest { @Test fun testShouldRickRoll() { listOf("gab.Com", "social.gab.ai", "whatever.GAB.com").forEach { - rollableDomain -> + rollableDomain -> assertTrue(shouldRickRoll(activity, rollableDomain)) } listOf("chaos.social", "notgab.com").forEach { - notRollableDomain -> + notRollableDomain -> assertFalse(shouldRickRoll(activity, notRollableDomain)) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 246b63f31..6cb54a410 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -58,7 +58,7 @@ android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } -ktlint = "org.jlleitschuh.gradle.ktlint:11.0.0" +ktlint = "org.jlleitschuh.gradle.ktlint:11.3.1" [libraries] android-material = { module = "com.google.android.material:material", version.ref = "material" }