Implement feature to hide "Local" badge from library manga (#5202)

This commit is contained in:
Hunter Nickel 2021-05-26 16:10:20 -06:00 committed by GitHub
parent d9c27e7109
commit 8dcd919ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 4 deletions

View File

@ -193,6 +193,8 @@ object PreferenceKeys {
const val unreadBadge = "display_unread_badge" const val unreadBadge = "display_unread_badge"
const val localBadge = "display_local_badge"
const val categoryTabs = "display_category_tabs" const val categoryTabs = "display_category_tabs"
const val categoryNumberOfItems = "display_number_of_items" const val categoryNumberOfItems = "display_number_of_items"

View File

@ -238,6 +238,8 @@ class PreferencesHelper(val context: Context) {
fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false) fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false)
fun localBadge() = flowPrefs.getBoolean(Keys.localBadge, true)
fun downloadedOnly() = flowPrefs.getBoolean(Keys.downloadedOnly, false) fun downloadedOnly() = flowPrefs.getBoolean(Keys.downloadedOnly, false)
fun unreadBadge() = flowPrefs.getBoolean(Keys.unreadBadge, true) fun unreadBadge() = flowPrefs.getBoolean(Keys.unreadBadge, true)

View File

@ -50,7 +50,7 @@ class LibraryComfortableGridHolder(
text = item.downloadCount.toString() text = item.downloadCount.toString()
} }
// set local visibility if its local manga // set local visibility if its local manga
binding.localText.isVisible = item.manga.isLocal() binding.localText.isVisible = item.isLocal
// For rounded corners // For rounded corners
binding.card.clipToOutline = true binding.card.clipToOutline = true

View File

@ -48,7 +48,7 @@ open class LibraryCompactGridHolder(
text = item.downloadCount.toString() text = item.downloadCount.toString()
} }
// set local visibility if its local manga // set local visibility if its local manga
binding.localText.isVisible = item.manga.isLocal() binding.localText.isVisible = item.isLocal
// For rounded corners // For rounded corners
binding.card.clipToOutline = true binding.card.clipToOutline = true

View File

@ -28,6 +28,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryDisplayMode: Prefe
var downloadCount = -1 var downloadCount = -1
var unreadCount = -1 var unreadCount = -1
var isLocal = false
override fun getLayoutRes(): Int { override fun getLayoutRes(): Int {
return when (libraryDisplayMode.get()) { return when (libraryDisplayMode.get()) {

View File

@ -50,7 +50,7 @@ class LibraryListHolder(
text = "${item.downloadCount}" text = "${item.downloadCount}"
} }
// show local text badge if local manga // show local text badge if local manga
binding.localText.isVisible = item.manga.isLocal() binding.localText.isVisible = item.isLocal
// Create thumbnail onclick to simulate long click // Create thumbnail onclick to simulate long click
binding.thumbnail.setOnClickListener { binding.thumbnail.setOnClickListener {

View File

@ -195,6 +195,7 @@ class LibraryPresenter(
private fun setBadges(map: LibraryMap) { private fun setBadges(map: LibraryMap) {
val showDownloadBadges = preferences.downloadBadge().get() val showDownloadBadges = preferences.downloadBadge().get()
val showUnreadBadges = preferences.unreadBadge().get() val showUnreadBadges = preferences.unreadBadge().get()
val showLocalBadges = preferences.localBadge().get()
for ((_, itemList) in map) { for ((_, itemList) in map) {
for (item in itemList) { for (item in itemList) {
@ -211,6 +212,13 @@ class LibraryPresenter(
// Unset unread count if not enabled // Unset unread count if not enabled
-1 -1
} }
item.isLocal = if (showLocalBadges) {
item.manga.isLocal()
} else {
// Hide / Unset local badge if not enabled
false
}
} }
} }
} }

View File

@ -276,14 +276,16 @@ class LibrarySettingsSheet(
inner class BadgeGroup : Group { inner class BadgeGroup : Group {
private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this) private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this)
private val unreadBadge = Item.CheckboxGroup(R.string.action_display_unread_badge, this) private val unreadBadge = Item.CheckboxGroup(R.string.action_display_unread_badge, this)
private val localBadge = Item.CheckboxGroup(R.string.action_display_local_badge, this)
override val header = Item.Header(R.string.badges_header) override val header = Item.Header(R.string.badges_header)
override val items = listOf(downloadBadge, unreadBadge) override val items = listOf(downloadBadge, unreadBadge, localBadge)
override val footer = null override val footer = null
override fun initModels() { override fun initModels() {
downloadBadge.checked = preferences.downloadBadge().get() downloadBadge.checked = preferences.downloadBadge().get()
unreadBadge.checked = preferences.unreadBadge().get() unreadBadge.checked = preferences.unreadBadge().get()
localBadge.checked = preferences.localBadge().get()
} }
override fun onItemClicked(item: Item) { override fun onItemClicked(item: Item) {
@ -292,6 +294,7 @@ class LibrarySettingsSheet(
when (item) { when (item) {
downloadBadge -> preferences.downloadBadge().set((item.checked)) downloadBadge -> preferences.downloadBadge().set((item.checked))
unreadBadge -> preferences.unreadBadge().set((item.checked)) unreadBadge -> preferences.unreadBadge().set((item.checked))
localBadge -> preferences.localBadge().set((item.checked))
} }
adapter.notifyItemChanged(item) adapter.notifyItemChanged(item)
} }

View File

@ -95,6 +95,7 @@
<string name="action_display_comfortable_grid">Comfortable grid</string> <string name="action_display_comfortable_grid">Comfortable grid</string>
<string name="action_display_download_badge">Download badges</string> <string name="action_display_download_badge">Download badges</string>
<string name="action_display_unread_badge">Unread badges</string> <string name="action_display_unread_badge">Unread badges</string>
<string name="action_display_local_badge">Local badges</string>
<string name="action_display_show_tabs">Show category tabs</string> <string name="action_display_show_tabs">Show category tabs</string>
<string name="action_display_show_number_of_items">Show number of items</string> <string name="action_display_show_number_of_items">Show number of items</string>
<string name="action_disable">Disable</string> <string name="action_disable">Disable</string>