diff --git a/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt b/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt index ca79d847a..a3b725fc8 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt @@ -45,7 +45,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.launch import org.kodein.di.DI @@ -276,6 +275,10 @@ class Repository(override val di: DI) : DIAware { sessionStore.setResumeTime(value) } + val showTitleUnreadCount = settingsStore.showTitleUnreadCount + + fun setShowTitleUnreadCount(value: Boolean) = settingsStore.setShowTitleUnreadCount(value) + /** * Returns true if the latest sync timestamp is within the last 10 seconds */ diff --git a/app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt b/app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt index 6c55b57a4..21d6bd074 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt @@ -481,6 +481,14 @@ class SettingsStore(override val di: DI) : DIAware { } } + private val _showTitleUnreadCount = MutableStateFlow(sp.getBoolean(PREF_SHOW_TITLE_UNREAD_COUNT, false)) + val showTitleUnreadCount = _showTitleUnreadCount.asStateFlow() + + fun setShowTitleUnreadCount(value: Boolean) { + _showTitleUnreadCount.value = value + sp.edit().putBoolean(PREF_SHOW_TITLE_UNREAD_COUNT, value).apply() + } + fun getAllSettings(): Map { val all = sp.all ?: emptyMap() @@ -578,6 +586,11 @@ const val PREF_LIST_SHOW_READING_TIME = "pref_show_reading_time" */ const val PREF_READALOUD_USE_DETECT_LANGUAGE = "pref_readaloud_detect_lang" +/** + * Appearance settings + */ +const val PREF_SHOW_TITLE_UNREAD_COUNT = "pref_show_title_unread_count" + /** * Used for OPML Import/Export. Please add new (only) user configurable settings here */ diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt index e870f40e6..fefb08e51 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt @@ -996,9 +996,19 @@ fun FeedScreen( scrollBehavior = scrollBehavior, title = when (viewState.feedScreenTitle.type) { - FeedType.FEED, FeedType.TAG -> "${viewState.feedScreenTitle.title} ${stringResource(id = R.string.title_unread_count, viewState.feedScreenTitle.unreadCount)}" + FeedType.FEED, FeedType.TAG -> viewState.feedScreenTitle.title FeedType.SAVED_ARTICLES -> stringResource(id = R.string.saved_articles) - FeedType.ALL_FEEDS -> "${stringResource(id = R.string.all_feeds)} ${stringResource(id = R.string.title_unread_count, viewState.feedScreenTitle.unreadCount)}" + FeedType.ALL_FEEDS -> stringResource(id = R.string.all_feeds) + }.let { title -> + if (viewState.feedScreenTitle.type == FeedType.SAVED_ARTICLES + || !viewState.showTitleUnreadCount + || viewState.feedScreenTitle.unreadCount == 0 + || title == null + ) { + title + } else { + title + " ${stringResource(id = R.string.title_unread_count, viewState.feedScreenTitle.unreadCount)}" + } } ?: "", navigationIcon = { IconButton( diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/FeedArticleViewModel.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/FeedArticleViewModel.kt index 4cbedf4b1..c38d42b48 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/FeedArticleViewModel.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/FeedArticleViewModel.kt @@ -308,6 +308,7 @@ class FeedArticleViewModel( repository.showOnlyTitle, repository.showReadingTime, repository.syncWorkerRunning, + repository.showTitleUnreadCount, ) { params: Array -> val article = params[15] as Article @@ -374,6 +375,7 @@ class FeedArticleViewModel( }, image = article.image, articleContent = parseArticleContent(article, textToDisplay), + showTitleUnreadCount = params[28] as Boolean, ) } .stateIn( @@ -608,6 +610,7 @@ interface FeedScreenViewState { val showReadingTime: Boolean val filter: FeedListFilter val showFilterMenu: Boolean + val showTitleUnreadCount: Boolean } @Immutable @@ -739,6 +742,7 @@ data class FeedArticleScreenViewState( override val wordCount: Int = 0, override val image: ThumbnailImage? = null, override val articleContent: LinearArticle = LinearArticle(elements = emptyList()), + override val showTitleUnreadCount: Boolean = false, ) : FeedScreenViewState, ArticleScreenViewState sealed class TSSError diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/Settings.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/Settings.kt index 3202f2d52..58613d33c 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/Settings.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/Settings.kt @@ -201,6 +201,8 @@ fun SettingsScreen( onOpenAdjacent = settingsViewModel::setIsOpenAdjacent, showReadingTime = viewState.showReadingTime, onShowReadingTimeChange = settingsViewModel::setShowReadingTime, + showTitleUnreadCount = viewState.showTitleUnreadCount, + onShowTitleUnreadCountChange = settingsViewModel::setShowTitleUnreadCount, onStartActivity = { intent -> activityLauncher.startActivity(false, intent) }, @@ -268,6 +270,8 @@ private fun SettingsScreenPreview() { onOpenAdjacent = {}, showReadingTime = false, onShowReadingTimeChange = {}, + showTitleUnreadCount = false, + onShowTitleUnreadCountChange = {}, onStartActivity = {}, modifier = Modifier, ) @@ -329,6 +333,8 @@ fun SettingsList( onOpenAdjacent: (Boolean) -> Unit, showReadingTime: Boolean, onShowReadingTimeChange: (Boolean) -> Unit, + showTitleUnreadCount: Boolean, + onShowTitleUnreadCountChange: (Boolean) -> Unit, onStartActivity: (intent: Intent) -> Unit, modifier: Modifier = Modifier, ) { @@ -591,6 +597,12 @@ fun SettingsList( onCheckedChange = onShowReadingTimeChange, ) + SwitchSetting( + title = stringResource(id = R.string.show_title_unread_count), + checked = showTitleUnreadCount, + onCheckedChange = onShowTitleUnreadCountChange, + ) + HorizontalDivider(modifier = Modifier.width(dimens.maxContentWidth)) GroupTitle { innerModifier -> diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/SettingsViewModel.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/SettingsViewModel.kt index 8d6b3b806..23e15f951 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/SettingsViewModel.kt @@ -147,6 +147,10 @@ class SettingsViewModel(di: DI) : DIAwareViewModel(di) { repository.setShowReadingTime(value) } + fun setShowTitleUnreadCount(value: Boolean) { + repository.setShowTitleUnreadCount(value) + } + @OptIn(ExperimentalCoroutinesApi::class) private val immutableFeedsSettings = repository.feedNotificationSettings @@ -199,6 +203,7 @@ class SettingsViewModel(di: DI) : DIAwareViewModel(di) { repository.showOnlyTitle, repository.isOpenAdjacent, repository.showReadingTime, + repository.showTitleUnreadCount, ) { params: Array -> @Suppress("UNCHECKED_CAST") SettingsViewState( @@ -228,6 +233,7 @@ class SettingsViewModel(di: DI) : DIAwareViewModel(di) { showOnlyTitle = params[23] as Boolean, isOpenAdjacent = params[24] as Boolean, showReadingTime = params[25] as Boolean, + showTitleUnreadCount = params[26] as Boolean, ) }.collect { _viewState.value = it @@ -269,6 +275,7 @@ data class SettingsViewState( val showOnlyTitle: Boolean = false, val isOpenAdjacent: Boolean = true, val showReadingTime: Boolean = false, + val showTitleUnreadCount: Boolean = false, ) data class UIFeedSettings( diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index bddb0cf20..cbbb4b837 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -248,4 +248,5 @@ Doppelte Artikel überspringen Artikel mit Links oder Titeln, die mit bestehenden Artikeln identisch sind, werden ignoriert Kompakte Kartei - \ No newline at end of file + Zeige Anzahl ungelesener Artikel im Titel + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d61d03c4..822772809 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -263,4 +263,5 @@ Articles with links or titles identical to existing articles are ignored Touch to play audio (%1$d) + Show unread article count in title