feat: Support adding "Favourites" to a tab (#578)

This commit is contained in:
Nik Clayton 2024-03-31 00:03:32 +01:00 committed by GitHub
parent 64fae0ceb6
commit 53fa56bbb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 5 deletions

View File

@ -369,6 +369,14 @@ class TabPreferenceActivity : BaseActivity(), ItemInteractionListener {
if (!currentTabs.contains(directMessagesTab)) { if (!currentTabs.contains(directMessagesTab)) {
addableTabs.add(directMessagesTab) addableTabs.add(directMessagesTab)
} }
val bookmarksTab = TabViewData.from(Timeline.Bookmarks)
if (!currentTabs.contains(bookmarksTab)) {
addableTabs.add(bookmarksTab)
}
val favouritesTab = TabViewData.from(Timeline.Favourites)
if (!currentTabs.contains(favouritesTab)) {
addableTabs.add(favouritesTab)
}
val trendingTagsTab = TabViewData.from(Timeline.TrendingHashtags) val trendingTagsTab = TabViewData.from(Timeline.TrendingHashtags)
if (!currentTabs.contains(trendingTagsTab)) { if (!currentTabs.contains(trendingTagsTab)) {
addableTabs.add(trendingTagsTab) addableTabs.add(trendingTagsTab)
@ -381,10 +389,6 @@ class TabPreferenceActivity : BaseActivity(), ItemInteractionListener {
if (!currentTabs.contains(trendingStatusesTab)) { if (!currentTabs.contains(trendingStatusesTab)) {
addableTabs.add(trendingStatusesTab) addableTabs.add(trendingStatusesTab)
} }
val bookmarksTab = TabViewData.from(Timeline.Bookmarks)
if (!currentTabs.contains(trendingTagsTab)) {
addableTabs.add(bookmarksTab)
}
addableTabs.add(TabViewData.from(Timeline.Hashtags(emptyList()))) addableTabs.add(TabViewData.from(Timeline.Hashtags(emptyList())))
addableTabs.add(TabViewData.from(Timeline.UserList("", ""))) addableTabs.add(TabViewData.from(Timeline.UserList("", "")))

View File

@ -135,7 +135,12 @@ data class TabViewData(
icon = R.drawable.ic_bookmark_active_24dp, icon = R.drawable.ic_bookmark_active_24dp,
fragment = { TimelineFragment.newInstance(timeline) }, fragment = { TimelineFragment.newInstance(timeline) },
) )
Timeline.Favourites -> throw IllegalArgumentException("can't add to tab: $timeline") Timeline.Favourites -> TabViewData(
timeline = timeline,
text = R.string.title_favourites,
icon = R.drawable.ic_favourite_filled_24dp,
fragment = { TimelineFragment.newInstance(timeline) },
)
is Timeline.User.Pinned -> throw IllegalArgumentException("can't add to tab: $timeline") is Timeline.User.Pinned -> throw IllegalArgumentException("can't add to tab: $timeline")
is Timeline.User.Posts -> throw IllegalArgumentException("can't add to tab: $timeline") is Timeline.User.Posts -> throw IllegalArgumentException("can't add to tab: $timeline")
is Timeline.User.Replies -> throw IllegalArgumentException("can't add to tab: $timeline") is Timeline.User.Replies -> throw IllegalArgumentException("can't add to tab: $timeline")

View File

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>