From 53fa56bbb48f09289c5b05b24d3ea9c2e8ce2f43 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Sun, 31 Mar 2024 00:03:32 +0100 Subject: [PATCH] feat: Support adding "Favourites" to a tab (#578) --- .../main/java/app/pachli/TabPreferenceActivity.kt | 12 ++++++++---- app/src/main/java/app/pachli/TabViewData.kt | 7 ++++++- .../main/res/drawable/ic_favourite_filled_24dp.xml | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/ic_favourite_filled_24dp.xml diff --git a/app/src/main/java/app/pachli/TabPreferenceActivity.kt b/app/src/main/java/app/pachli/TabPreferenceActivity.kt index d9e74f75a..acabb7f88 100644 --- a/app/src/main/java/app/pachli/TabPreferenceActivity.kt +++ b/app/src/main/java/app/pachli/TabPreferenceActivity.kt @@ -369,6 +369,14 @@ class TabPreferenceActivity : BaseActivity(), ItemInteractionListener { if (!currentTabs.contains(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) if (!currentTabs.contains(trendingTagsTab)) { addableTabs.add(trendingTagsTab) @@ -381,10 +389,6 @@ class TabPreferenceActivity : BaseActivity(), ItemInteractionListener { if (!currentTabs.contains(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.UserList("", ""))) diff --git a/app/src/main/java/app/pachli/TabViewData.kt b/app/src/main/java/app/pachli/TabViewData.kt index c7c03d9b7..638579f64 100644 --- a/app/src/main/java/app/pachli/TabViewData.kt +++ b/app/src/main/java/app/pachli/TabViewData.kt @@ -135,7 +135,12 @@ data class TabViewData( icon = R.drawable.ic_bookmark_active_24dp, 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.Posts -> throw IllegalArgumentException("can't add to tab: $timeline") is Timeline.User.Replies -> throw IllegalArgumentException("can't add to tab: $timeline") diff --git a/app/src/main/res/drawable/ic_favourite_filled_24dp.xml b/app/src/main/res/drawable/ic_favourite_filled_24dp.xml new file mode 100644 index 000000000..333cefebd --- /dev/null +++ b/app/src/main/res/drawable/ic_favourite_filled_24dp.xml @@ -0,0 +1,5 @@ + + + + +