From 5764efa5d4ad6191bce3eb34b6809720926f05e0 Mon Sep 17 00:00:00 2001 From: Mike Haynes Date: Thu, 24 Aug 2023 07:21:43 -0700 Subject: [PATCH] Allow the user to add a "bookmarks" tab (#3983) Fixes #2368 --- app/src/main/java/com/keylesspalace/tusky/TabData.kt | 7 +++++++ .../java/com/keylesspalace/tusky/TabPreferenceActivity.kt | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/TabData.kt b/app/src/main/java/com/keylesspalace/tusky/TabData.kt index 58969292f..4760bd5d5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabData.kt @@ -36,6 +36,7 @@ const val DIRECT = "Direct" const val TRENDING_TAGS = "TrendingTags" const val HASHTAG = "Hashtag" const val LIST = "List" +const val BOOKMARKS = "Bookmarks" data class TabData( val id: String, @@ -114,6 +115,12 @@ fun createTabDataFromId(id: String, arguments: List = emptyList()): TabD arguments = arguments, title = { arguments.getOrNull(1).orEmpty() } ) + BOOKMARKS -> TabData( + id = BOOKMARKS, + text = R.string.title_bookmarks, + icon = R.drawable.ic_bookmark_active_24dp, + fragment = { TimelineFragment.newInstance(TimelineViewModel.Kind.BOOKMARKS) } + ) else -> throw IllegalArgumentException("unknown tab type") } } diff --git a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt index 5f85f7375..29611074e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt @@ -382,6 +382,10 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene if (!currentTabs.contains(trendingTagsTab)) { addableTabs.add(trendingTagsTab) } + val bookmarksTab = createTabDataFromId(BOOKMARKS) + if (!currentTabs.contains(trendingTagsTab)) { + addableTabs.add(bookmarksTab) + } addableTabs.add(createTabDataFromId(HASHTAG)) addableTabs.add(createTabDataFromId(LIST))