[5893] - Implemented Language Badge (#6050)
* Implemented language badge on library items * Added left margin for better viewing the badge on list view * Adjusting borders on badges, cleaning string interpolation and cleaning code * Improving readability on Holders and removing unused background and text on grid items
This commit is contained in:
parent
f32f1eeaa5
commit
918502742d
14 changed files with 244 additions and 123 deletions
|
@ -197,6 +197,8 @@ object PreferenceKeys {
|
|||
|
||||
const val unreadBadge = "display_unread_badge"
|
||||
|
||||
const val languageBadge = "display_language_badge"
|
||||
|
||||
const val localBadge = "display_local_badge"
|
||||
|
||||
const val categoryTabs = "display_category_tabs"
|
||||
|
|
|
@ -253,6 +253,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun unreadBadge() = flowPrefs.getBoolean(Keys.unreadBadge, true)
|
||||
|
||||
fun languageBadge() = flowPrefs.getBoolean(Keys.languageBadge, false)
|
||||
|
||||
fun categoryTabs() = flowPrefs.getBoolean(Keys.categoryTabs, true)
|
||||
|
||||
fun categoryNumberOfItems() = flowPrefs.getBoolean(Keys.categoryNumberOfItems, false)
|
||||
|
|
|
@ -39,7 +39,8 @@ class SourceComfortableGridHolder(private val view: View, private val adapter: F
|
|||
binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
|
||||
|
||||
// For rounded corners
|
||||
binding.badges.clipToOutline = true
|
||||
binding.leftBadges.clipToOutline = true
|
||||
binding.rightBadges.clipToOutline = true
|
||||
|
||||
// Set favorite badge
|
||||
binding.favoriteText.isVisible = manga.favorite
|
||||
|
|
|
@ -39,7 +39,8 @@ open class SourceGridHolder(private val view: View, private val adapter: Flexibl
|
|||
binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
|
||||
|
||||
// For rounded corners
|
||||
binding.badges.clipToOutline = true
|
||||
binding.leftBadges.clipToOutline = true
|
||||
binding.rightBadges.clipToOutline = true
|
||||
|
||||
// Set favorite badge
|
||||
binding.favoriteText.isVisible = manga.favorite
|
||||
|
|
|
@ -36,7 +36,8 @@ class LibraryComfortableGridHolder(
|
|||
binding.title.text = item.manga.title
|
||||
|
||||
// For rounded corners
|
||||
binding.badges.clipToOutline = true
|
||||
binding.leftBadges.clipToOutline = true
|
||||
binding.rightBadges.clipToOutline = true
|
||||
|
||||
// Update the unread count and its visibility.
|
||||
with(binding.unreadText) {
|
||||
|
@ -48,6 +49,11 @@ class LibraryComfortableGridHolder(
|
|||
isVisible = item.downloadCount > 0
|
||||
text = item.downloadCount.toString()
|
||||
}
|
||||
// Update the source language and its visibility
|
||||
with(binding.languageText) {
|
||||
isVisible = item.sourceLanguage.isNotEmpty()
|
||||
text = item.sourceLanguage
|
||||
}
|
||||
// set local visibility if its local manga
|
||||
binding.localText.isVisible = item.isLocal
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ open class LibraryCompactGridHolder(
|
|||
binding.title.text = item.manga.title
|
||||
|
||||
// For rounded corners
|
||||
binding.badges.clipToOutline = true
|
||||
binding.leftBadges.clipToOutline = true
|
||||
binding.rightBadges.clipToOutline = true
|
||||
|
||||
// Update the unread count and its visibility.
|
||||
with(binding.unreadText) {
|
||||
|
@ -46,6 +47,11 @@ open class LibraryCompactGridHolder(
|
|||
isVisible = item.downloadCount > 0
|
||||
text = item.downloadCount.toString()
|
||||
}
|
||||
// Update the source language and its visibility
|
||||
with(binding.languageText) {
|
||||
isVisible = item.sourceLanguage.isNotEmpty()
|
||||
text = item.sourceLanguage
|
||||
}
|
||||
// set local visibility if its local manga
|
||||
binding.localText.isVisible = item.isLocal
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class LibraryItem(
|
|||
var downloadCount = -1
|
||||
var unreadCount = -1
|
||||
var isLocal = false
|
||||
var sourceLanguage = ""
|
||||
|
||||
private fun getDisplayMode(): DisplayModeSetting {
|
||||
return if (shouldSetFromCategory.get() && manga.category != 0) {
|
||||
|
|
|
@ -46,6 +46,11 @@ class LibraryListHolder(
|
|||
isVisible = item.downloadCount > 0
|
||||
text = "${item.downloadCount}"
|
||||
}
|
||||
// Update the source language and its visibility
|
||||
with(binding.languageText) {
|
||||
isVisible = item.sourceLanguage.isNotEmpty()
|
||||
text = item.sourceLanguage
|
||||
}
|
||||
// show local text badge if local manga
|
||||
binding.localText.isVisible = item.isLocal
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ class LibraryPresenter(
|
|||
val showDownloadBadges = preferences.downloadBadge().get()
|
||||
val showUnreadBadges = preferences.unreadBadge().get()
|
||||
val showLocalBadges = preferences.localBadge().get()
|
||||
val showLanguageBadges = preferences.languageBadge().get()
|
||||
|
||||
for ((_, itemList) in map) {
|
||||
for (item in itemList) {
|
||||
|
@ -223,6 +224,13 @@ class LibraryPresenter(
|
|||
// Hide / Unset local badge if not enabled
|
||||
false
|
||||
}
|
||||
|
||||
item.sourceLanguage = if (showLanguageBadges) {
|
||||
sourceManager.getOrStub(item.manga.source).lang.uppercase()
|
||||
} else {
|
||||
// Unset source language if not enabled
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,15 +367,17 @@ class LibrarySettingsSheet(
|
|||
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 localBadge = Item.CheckboxGroup(R.string.action_display_local_badge, this)
|
||||
private val languageBadge = Item.CheckboxGroup(R.string.action_display_language_badge, this)
|
||||
|
||||
override val header = Item.Header(R.string.badges_header)
|
||||
override val items = listOf(downloadBadge, unreadBadge, localBadge)
|
||||
override val items = listOf(downloadBadge, unreadBadge, localBadge, languageBadge)
|
||||
override val footer = null
|
||||
|
||||
override fun initModels() {
|
||||
downloadBadge.checked = preferences.downloadBadge().get()
|
||||
unreadBadge.checked = preferences.unreadBadge().get()
|
||||
localBadge.checked = preferences.localBadge().get()
|
||||
languageBadge.checked = preferences.languageBadge().get()
|
||||
}
|
||||
|
||||
override fun onItemClicked(item: Item) {
|
||||
|
@ -385,6 +387,7 @@ class LibrarySettingsSheet(
|
|||
downloadBadge -> preferences.downloadBadge().set((item.checked))
|
||||
unreadBadge -> preferences.unreadBadge().set((item.checked))
|
||||
localBadge -> preferences.localBadge().set((item.checked))
|
||||
languageBadge -> preferences.languageBadge().set((item.checked))
|
||||
}
|
||||
adapter.notifyItemChanged(item)
|
||||
}
|
||||
|
|
|
@ -37,6 +37,12 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/left_badges"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_rectangle">
|
||||
|
||||
<TextView
|
||||
|
@ -102,9 +108,38 @@
|
|||
android:textColor="?attr/colorOnSecondary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/right_badges"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_rectangle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/language_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorTertiary"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="3dp"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingBottom="1dp"
|
||||
tools:text="EN"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:textColor="?attr/colorOnTertiary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/progress"
|
||||
style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small"
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/left_badges"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_rectangle">
|
||||
|
||||
<TextView
|
||||
|
@ -101,7 +107,35 @@
|
|||
android:textColor="?attr/colorOnSecondary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/right_badges"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_rectangle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/language_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorTertiary"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="3dp"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingBottom="1dp"
|
||||
tools:text="EN"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:textColor="?attr/colorOnTertiary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -112,6 +112,22 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/language_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorTertiary"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="3dp"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingBottom="1dp"
|
||||
tools:text="EN"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:textColor="?attr/colorOnTertiary"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
<string name="action_display_download_badge">Download badges</string>
|
||||
<string name="action_display_unread_badge">Unread badges</string>
|
||||
<string name="action_display_local_badge">Local badges</string>
|
||||
<string name="action_display_language_badge">Language badges</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_disable">Disable</string>
|
||||
|
|
Reference in a new issue