Move unread chapters badge setting to General section

This commit is contained in:
arkon 2021-10-30 12:42:59 -04:00
parent 90b312a56e
commit 709de81814
9 changed files with 19 additions and 15 deletions

View File

@ -291,7 +291,7 @@ class LibraryUpdateService(
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
val hasDownloads = AtomicBoolean(false)
val loggedServices by lazy { trackManager.services.filter { it.isLogged } }
val currentUnreadUpdatesCount = preferences.libraryUnreadUpdatesCount().get()
val currentUnreadUpdatesCount = preferences.unreadUpdatesCount().get()
withIOContext {
mangaToUpdate.groupBy { it.source }
@ -356,7 +356,7 @@ class LibraryUpdateService(
if (newUpdates.isNotEmpty()) {
notifier.showUpdateNotifications(newUpdates)
val newChapterCount = newUpdates.sumOf { it.second.size }
preferences.libraryUnreadUpdatesCount().set(currentUnreadUpdatesCount + newChapterCount)
preferences.unreadUpdatesCount().set(currentUnreadUpdatesCount + newChapterCount)
if (hasDownloads.get()) {
DownloadService.start(this)
}

View File

@ -133,7 +133,7 @@ object PreferenceKeys {
const val libraryUpdateRestriction = "library_update_restriction"
const val libraryUpdateShowTabBadge = "library_update_show_tab_badge"
const val showUpdatesNavBadge = "library_update_show_tab_badge"
const val libraryUpdateCategories = "library_update_categories"
const val libraryUpdateCategoriesExclude = "library_update_categories_exclude"

View File

@ -238,8 +238,8 @@ class PreferencesHelper(val context: Context) {
fun libraryUpdateRestriction() = flowPrefs.getStringSet(Keys.libraryUpdateRestriction, setOf(ONLY_ON_WIFI))
fun libraryUpdateShowTabBadge() = flowPrefs.getBoolean(Keys.libraryUpdateShowTabBadge, true)
fun libraryUnreadUpdatesCount() = flowPrefs.getInt("library_unread_updates_count", 0)
fun showUpdatesNavBadge() = flowPrefs.getBoolean(Keys.showUpdatesNavBadge, true)
fun unreadUpdatesCount() = flowPrefs.getInt("library_unread_updates_count", 0)
fun libraryUpdateCategories() = flowPrefs.getStringSet(Keys.libraryUpdateCategories, emptySet())
fun libraryUpdateCategoriesExclude() = flowPrefs.getStringSet(Keys.libraryUpdateCategoriesExclude, emptySet())

View File

@ -228,7 +228,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
}
merge(preferences.libraryUpdateShowTabBadge().asFlow(), preferences.libraryUnreadUpdatesCount().asFlow())
merge(preferences.showUpdatesNavBadge().asFlow(), preferences.unreadUpdatesCount().asFlow())
.onEach { setUnreadUpdatesBadge() }
.launchIn(lifecycleScope)
@ -355,7 +355,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
private fun setUnreadUpdatesBadge() {
val updates = if (preferences.libraryUpdateShowTabBadge().get()) preferences.libraryUnreadUpdatesCount().get() else 0
val updates = if (preferences.showUpdatesNavBadge().get()) preferences.unreadUpdatesCount().get() else 0
if (updates > 0) {
nav.getOrCreateBadge(R.id.nav_updates).number = updates
} else {

View File

@ -107,7 +107,7 @@ class UpdatesPresenter : BasePresenter<UpdatesController>() {
chapters = list
// Set unread chapter count for bottom bar badge
preferences.libraryUnreadUpdatesCount().set(list.count { !it.read })
preferences.unreadUpdatesCount().set(list.count { !it.read })
}
}

View File

@ -32,6 +32,11 @@ class SettingsGeneralController : SettingsController() {
defaultValue = "1"
summary = "%s"
}
switchPreference {
key = Keys.showUpdatesNavBadge
titleRes = R.string.pref_library_update_show_tab_badge
defaultValue = true
}
switchPreference {
key = Keys.confirmExit
titleRes = R.string.pref_confirm_exit

View File

@ -199,11 +199,6 @@ class SettingsLibraryController : SettingsController() {
titleRes = R.string.pref_update_only_non_completed
defaultValue = false
}
switchPreference {
key = Keys.libraryUpdateShowTabBadge
titleRes = R.string.pref_library_update_show_tab_badge
defaultValue = true
}
preference {
key = Keys.libraryUpdateCategories
titleRes = R.string.categories

View File

@ -0,0 +1,4 @@
package eu.kanade.tachiyomi.widget.preference
class ButtonToggleGroupPreference {
}

View File

@ -223,7 +223,7 @@
<string name="charging">Charging</string>
<string name="restrictions">Restrictions: %s</string>
<string name="pref_update_only_non_completed">Only update ongoing manga</string>
<string name="pref_library_update_show_tab_badge">Show update count on bottom bar</string>
<string name="pref_library_update_show_tab_badge">Show unread count on Updates icon</string>
<string name="pref_library_update_refresh_metadata">Automatically refresh metadata</string>
<string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
<string name="pref_library_update_refresh_trackers">Automatically refresh trackers</string>