From 46c7307c0dfdebc2a72dc847e0c7e4af74b5bf59 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 10 Jun 2024 17:40:23 +0200 Subject: [PATCH] refactor: Move LinkListener to core.ui (#732) --- app/src/main/java/app/pachli/adapter/AccountViewHolder.kt | 2 +- app/src/main/java/app/pachli/adapter/FollowRequestViewHolder.kt | 2 +- .../main/java/app/pachli/components/account/AccountActivity.kt | 2 +- .../java/app/pachli/components/account/AccountFieldAdapter.kt | 2 +- .../app/pachli/components/accountlist/AccountListFragment.kt | 2 +- .../components/accountlist/adapter/FollowRequestsAdapter.kt | 2 +- .../app/pachli/components/announcements/AnnouncementAdapter.kt | 2 +- .../app/pachli/components/notifications/FollowViewHolder.kt | 2 +- .../components/notifications/StatusNotificationViewHolder.kt | 2 +- .../java/app/pachli/components/report/adapter/AdapterHandler.kt | 2 +- .../app/pachli/components/report/adapter/StatusViewHolder.kt | 2 +- .../pachli/components/search/adapter/SearchAccountsAdapter.kt | 2 +- .../pachli/components/search/adapter/SearchHashtagsAdapter.kt | 2 +- .../app/pachli/components/search/fragments/SearchFragment.kt | 2 +- .../app/pachli/components/viewthread/edits/ViewEditsAdapter.kt | 2 +- .../app/pachli/components/viewthread/edits/ViewEditsFragment.kt | 2 +- app/src/main/java/app/pachli/interfaces/StatusActionListener.kt | 1 + app/src/main/java/app/pachli/util/LinkHelper.kt | 2 +- app/src/test/java/app/pachli/util/LinkHelperTest.kt | 2 +- .../ui/src/main/kotlin/app/pachli/core/ui}/LinkListener.kt | 2 +- 20 files changed, 20 insertions(+), 19 deletions(-) rename {app/src/main/java/app/pachli/interfaces => core/ui/src/main/kotlin/app/pachli/core/ui}/LinkListener.kt (96%) diff --git a/app/src/main/java/app/pachli/adapter/AccountViewHolder.kt b/app/src/main/java/app/pachli/adapter/AccountViewHolder.kt index 8b9796cf1..7d27d4e06 100644 --- a/app/src/main/java/app/pachli/adapter/AccountViewHolder.kt +++ b/app/src/main/java/app/pachli/adapter/AccountViewHolder.kt @@ -24,9 +24,9 @@ import app.pachli.core.activity.loadAvatar import app.pachli.core.common.extensions.visible import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.TimelineAccount +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemAccountBinding import app.pachli.interfaces.AccountActionListener -import app.pachli.interfaces.LinkListener class AccountViewHolder( private val binding: ItemAccountBinding, diff --git a/app/src/main/java/app/pachli/adapter/FollowRequestViewHolder.kt b/app/src/main/java/app/pachli/adapter/FollowRequestViewHolder.kt index a190fb6d1..4762577cc 100644 --- a/app/src/main/java/app/pachli/adapter/FollowRequestViewHolder.kt +++ b/app/src/main/java/app/pachli/adapter/FollowRequestViewHolder.kt @@ -34,9 +34,9 @@ import app.pachli.core.data.model.StatusDisplayOptions import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.TimelineAccount import app.pachli.core.network.parseAsMastodonHtml +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemFollowRequestBinding import app.pachli.interfaces.AccountActionListener -import app.pachli.interfaces.LinkListener import app.pachli.util.setClickableText import app.pachli.viewdata.NotificationViewData diff --git a/app/src/main/java/app/pachli/components/account/AccountActivity.kt b/app/src/main/java/app/pachli/components/account/AccountActivity.kt index 607e209a6..01485e704 100644 --- a/app/src/main/java/app/pachli/components/account/AccountActivity.kt +++ b/app/src/main/java/app/pachli/components/account/AccountActivity.kt @@ -80,12 +80,12 @@ import app.pachli.core.network.model.Relationship import app.pachli.core.network.parseAsMastodonHtml import app.pachli.core.preferences.AppTheme import app.pachli.core.preferences.PrefKeys +import app.pachli.core.ui.LinkListener import app.pachli.core.ui.extensions.reduceSwipeSensitivity import app.pachli.databinding.ActivityAccountBinding import app.pachli.db.DraftsAlert import app.pachli.feature.lists.ListsForAccountFragment import app.pachli.interfaces.ActionButtonActivity -import app.pachli.interfaces.LinkListener import app.pachli.interfaces.ReselectableFragment import app.pachli.util.Error import app.pachli.util.Loading diff --git a/app/src/main/java/app/pachli/components/account/AccountFieldAdapter.kt b/app/src/main/java/app/pachli/components/account/AccountFieldAdapter.kt index 354b2d2b2..8cb0d938d 100644 --- a/app/src/main/java/app/pachli/components/account/AccountFieldAdapter.kt +++ b/app/src/main/java/app/pachli/components/account/AccountFieldAdapter.kt @@ -25,8 +25,8 @@ import app.pachli.core.network.model.Emoji import app.pachli.core.network.model.Field import app.pachli.core.network.parseAsMastodonHtml import app.pachli.core.ui.BindingHolder +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemAccountFieldBinding -import app.pachli.interfaces.LinkListener import app.pachli.util.setClickableText class AccountFieldAdapter( diff --git a/app/src/main/java/app/pachli/components/accountlist/AccountListFragment.kt b/app/src/main/java/app/pachli/components/accountlist/AccountListFragment.kt index 8a0deba1e..2f1a7416b 100644 --- a/app/src/main/java/app/pachli/components/accountlist/AccountListFragment.kt +++ b/app/src/main/java/app/pachli/components/accountlist/AccountListFragment.kt @@ -55,10 +55,10 @@ import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.preferences.PrefKeys import app.pachli.core.preferences.SharedPreferencesRepository import app.pachli.core.ui.BackgroundMessage +import app.pachli.core.ui.LinkListener import app.pachli.databinding.FragmentAccountListBinding import app.pachli.interfaces.AccountActionListener import app.pachli.interfaces.AppBarLayoutHost -import app.pachli.interfaces.LinkListener import app.pachli.view.EndlessOnScrollListener import at.connyduck.calladapter.networkresult.fold import com.google.android.material.color.MaterialColors diff --git a/app/src/main/java/app/pachli/components/accountlist/adapter/FollowRequestsAdapter.kt b/app/src/main/java/app/pachli/components/accountlist/adapter/FollowRequestsAdapter.kt index 77af3d4cb..95c25204b 100644 --- a/app/src/main/java/app/pachli/components/accountlist/adapter/FollowRequestsAdapter.kt +++ b/app/src/main/java/app/pachli/components/accountlist/adapter/FollowRequestsAdapter.kt @@ -19,9 +19,9 @@ package app.pachli.components.accountlist.adapter import android.view.LayoutInflater import android.view.ViewGroup import app.pachli.adapter.FollowRequestViewHolder +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemFollowRequestBinding import app.pachli.interfaces.AccountActionListener -import app.pachli.interfaces.LinkListener /** Displays a list of follow requests with accept/reject buttons. */ class FollowRequestsAdapter( diff --git a/app/src/main/java/app/pachli/components/announcements/AnnouncementAdapter.kt b/app/src/main/java/app/pachli/components/announcements/AnnouncementAdapter.kt index a5325fc87..20ae3302f 100644 --- a/app/src/main/java/app/pachli/components/announcements/AnnouncementAdapter.kt +++ b/app/src/main/java/app/pachli/components/announcements/AnnouncementAdapter.kt @@ -32,8 +32,8 @@ import app.pachli.core.common.util.AbsoluteTimeFormatter import app.pachli.core.network.model.Announcement import app.pachli.core.network.parseAsMastodonHtml import app.pachli.core.ui.BindingHolder +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemAnnouncementBinding -import app.pachli.interfaces.LinkListener import app.pachli.util.equalByMinute import app.pachli.util.getRelativeTimeSpanString import app.pachli.util.setClickableText diff --git a/app/src/main/java/app/pachli/components/notifications/FollowViewHolder.kt b/app/src/main/java/app/pachli/components/notifications/FollowViewHolder.kt index ae9ccda46..e32e03af1 100644 --- a/app/src/main/java/app/pachli/components/notifications/FollowViewHolder.kt +++ b/app/src/main/java/app/pachli/components/notifications/FollowViewHolder.kt @@ -27,8 +27,8 @@ import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.Notification import app.pachli.core.network.model.TimelineAccount import app.pachli.core.network.parseAsMastodonHtml +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemFollowBinding -import app.pachli.interfaces.LinkListener import app.pachli.util.setClickableText import app.pachli.viewdata.NotificationViewData diff --git a/app/src/main/java/app/pachli/components/notifications/StatusNotificationViewHolder.kt b/app/src/main/java/app/pachli/components/notifications/StatusNotificationViewHolder.kt index f4af28f1e..88d9dd5ba 100644 --- a/app/src/main/java/app/pachli/components/notifications/StatusNotificationViewHolder.kt +++ b/app/src/main/java/app/pachli/components/notifications/StatusNotificationViewHolder.kt @@ -42,8 +42,8 @@ import app.pachli.core.data.model.StatusDisplayOptions import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.Emoji import app.pachli.core.network.model.Notification +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemStatusNotificationBinding -import app.pachli.interfaces.LinkListener import app.pachli.interfaces.StatusActionListener import app.pachli.util.SmartLengthInputFilter import app.pachli.util.getRelativeTimeSpanString diff --git a/app/src/main/java/app/pachli/components/report/adapter/AdapterHandler.kt b/app/src/main/java/app/pachli/components/report/adapter/AdapterHandler.kt index 65b80f0d2..abf9333e8 100644 --- a/app/src/main/java/app/pachli/components/report/adapter/AdapterHandler.kt +++ b/app/src/main/java/app/pachli/components/report/adapter/AdapterHandler.kt @@ -18,7 +18,7 @@ package app.pachli.components.report.adapter import android.view.View import app.pachli.core.network.model.Status -import app.pachli.interfaces.LinkListener +import app.pachli.core.ui.LinkListener interface AdapterHandler : LinkListener { fun showMedia(v: View?, status: Status?, idx: Int) diff --git a/app/src/main/java/app/pachli/components/report/adapter/StatusViewHolder.kt b/app/src/main/java/app/pachli/components/report/adapter/StatusViewHolder.kt index ab9747a1c..6f49e8a17 100644 --- a/app/src/main/java/app/pachli/components/report/adapter/StatusViewHolder.kt +++ b/app/src/main/java/app/pachli/components/report/adapter/StatusViewHolder.kt @@ -31,8 +31,8 @@ import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.Emoji import app.pachli.core.network.model.HashTag import app.pachli.core.network.model.Status +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemReportStatusBinding -import app.pachli.interfaces.LinkListener import app.pachli.util.StatusViewHelper import app.pachli.util.StatusViewHelper.Companion.COLLAPSE_INPUT_FILTER import app.pachli.util.StatusViewHelper.Companion.NO_INPUT_FILTER diff --git a/app/src/main/java/app/pachli/components/search/adapter/SearchAccountsAdapter.kt b/app/src/main/java/app/pachli/components/search/adapter/SearchAccountsAdapter.kt index 07104bf9b..6168d3c31 100644 --- a/app/src/main/java/app/pachli/components/search/adapter/SearchAccountsAdapter.kt +++ b/app/src/main/java/app/pachli/components/search/adapter/SearchAccountsAdapter.kt @@ -22,8 +22,8 @@ import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import app.pachli.adapter.AccountViewHolder import app.pachli.core.network.model.TimelineAccount +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemAccountBinding -import app.pachli.interfaces.LinkListener class SearchAccountsAdapter(private val linkListener: LinkListener, private val animateAvatars: Boolean, private val animateEmojis: Boolean, private val showBotOverlay: Boolean) : PagingDataAdapter(ACCOUNT_COMPARATOR) { diff --git a/app/src/main/java/app/pachli/components/search/adapter/SearchHashtagsAdapter.kt b/app/src/main/java/app/pachli/components/search/adapter/SearchHashtagsAdapter.kt index 1dfd0c00a..3c07f7c25 100644 --- a/app/src/main/java/app/pachli/components/search/adapter/SearchHashtagsAdapter.kt +++ b/app/src/main/java/app/pachli/components/search/adapter/SearchHashtagsAdapter.kt @@ -22,8 +22,8 @@ import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import app.pachli.core.network.model.HashTag import app.pachli.core.ui.BindingHolder +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemHashtagBinding -import app.pachli.interfaces.LinkListener class SearchHashtagsAdapter(private val linkListener: LinkListener) : PagingDataAdapter>(HASHTAG_COMPARATOR) { diff --git a/app/src/main/java/app/pachli/components/search/fragments/SearchFragment.kt b/app/src/main/java/app/pachli/components/search/fragments/SearchFragment.kt index d9730929c..26c994596 100644 --- a/app/src/main/java/app/pachli/components/search/fragments/SearchFragment.kt +++ b/app/src/main/java/app/pachli/components/search/fragments/SearchFragment.kt @@ -25,8 +25,8 @@ import app.pachli.core.common.extensions.visible import app.pachli.core.navigation.AccountActivityIntent import app.pachli.core.navigation.TimelineActivityIntent import app.pachli.core.network.retrofit.MastodonApi +import app.pachli.core.ui.LinkListener import app.pachli.databinding.FragmentSearchBinding -import app.pachli.interfaces.LinkListener import com.google.android.material.color.MaterialColors import com.google.android.material.snackbar.Snackbar import com.mikepenz.iconics.IconicsDrawable diff --git a/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsAdapter.kt b/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsAdapter.kt index b7a64b70e..a1e75312a 100644 --- a/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsAdapter.kt +++ b/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsAdapter.kt @@ -31,8 +31,8 @@ import app.pachli.core.designsystem.R as DR import app.pachli.core.network.model.StatusEdit import app.pachli.core.network.parseAsMastodonHtml import app.pachli.core.ui.BindingHolder +import app.pachli.core.ui.LinkListener import app.pachli.databinding.ItemStatusEditBinding -import app.pachli.interfaces.LinkListener import app.pachli.util.aspectRatios import app.pachli.util.setClickableText import app.pachli.viewdata.PollOptionViewData diff --git a/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsFragment.kt b/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsFragment.kt index 6e03006c2..753f74e79 100644 --- a/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsFragment.kt +++ b/app/src/main/java/app/pachli/components/viewthread/edits/ViewEditsFragment.kt @@ -44,8 +44,8 @@ import app.pachli.core.navigation.TimelineActivityIntent import app.pachli.core.preferences.PrefKeys import app.pachli.core.preferences.SharedPreferencesRepository import app.pachli.core.ui.BackgroundMessage +import app.pachli.core.ui.LinkListener import app.pachli.databinding.FragmentViewEditsBinding -import app.pachli.interfaces.LinkListener import com.google.android.material.color.MaterialColors import com.google.android.material.divider.MaterialDividerItemDecoration import com.mikepenz.iconics.IconicsDrawable diff --git a/app/src/main/java/app/pachli/interfaces/StatusActionListener.kt b/app/src/main/java/app/pachli/interfaces/StatusActionListener.kt index d230e2eaf..7b644e740 100644 --- a/app/src/main/java/app/pachli/interfaces/StatusActionListener.kt +++ b/app/src/main/java/app/pachli/interfaces/StatusActionListener.kt @@ -20,6 +20,7 @@ package app.pachli.interfaces import android.view.View import app.pachli.core.network.model.Poll import app.pachli.core.network.model.Status +import app.pachli.core.ui.LinkListener import app.pachli.viewdata.IStatusViewData interface StatusActionListener : LinkListener { diff --git a/app/src/main/java/app/pachli/util/LinkHelper.kt b/app/src/main/java/app/pachli/util/LinkHelper.kt index 83e393102..6e9103da3 100644 --- a/app/src/main/java/app/pachli/util/LinkHelper.kt +++ b/app/src/main/java/app/pachli/util/LinkHelper.kt @@ -32,9 +32,9 @@ import app.pachli.R import app.pachli.core.activity.EmojiSpan import app.pachli.core.network.model.HashTag import app.pachli.core.network.model.Status.Mention +import app.pachli.core.ui.LinkListener import app.pachli.core.ui.MentionSpan import app.pachli.core.ui.NoUnderlineURLSpan -import app.pachli.interfaces.LinkListener import com.mikepenz.iconics.IconicsColor import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.IconicsSize diff --git a/app/src/test/java/app/pachli/util/LinkHelperTest.kt b/app/src/test/java/app/pachli/util/LinkHelperTest.kt index 33fd40ccf..243ed081c 100644 --- a/app/src/test/java/app/pachli/util/LinkHelperTest.kt +++ b/app/src/test/java/app/pachli/util/LinkHelperTest.kt @@ -10,7 +10,7 @@ import app.pachli.R import app.pachli.core.activity.BottomSheetActivity.Companion.looksLikeMastodonUrl import app.pachli.core.network.model.HashTag import app.pachli.core.network.model.Status -import app.pachli.interfaces.LinkListener +import app.pachli.core.ui.LinkListener import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith diff --git a/app/src/main/java/app/pachli/interfaces/LinkListener.kt b/core/ui/src/main/kotlin/app/pachli/core/ui/LinkListener.kt similarity index 96% rename from app/src/main/java/app/pachli/interfaces/LinkListener.kt rename to core/ui/src/main/kotlin/app/pachli/core/ui/LinkListener.kt index f7f3931d8..37d5a0cbd 100644 --- a/app/src/main/java/app/pachli/interfaces/LinkListener.kt +++ b/core/ui/src/main/kotlin/app/pachli/core/ui/LinkListener.kt @@ -14,7 +14,7 @@ * see . */ -package app.pachli.interfaces +package app.pachli.core.ui interface LinkListener { fun onViewTag(tag: String)