mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 14:11:50 +01:00
Cover only grid added to library (#6528)
* No title grid added to library and source * Else added to display title in case image is null or empty * No title grid renamed and now only available in library * Spanish strings about cover only grid removed Co-authored-by: micaelagimenez <micaela.gimenez@ext.prosegur.com>
This commit is contained in:
parent
790d7b9170
commit
44b055c019
@ -222,7 +222,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
(layoutManager as GridLayoutManager).spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
(layoutManager as GridLayoutManager).spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||||
override fun getSpanSize(position: Int): Int {
|
override fun getSpanSize(position: Int): Int {
|
||||||
return when (adapter?.getItemViewType(position)) {
|
return when (adapter?.getItemViewType(position)) {
|
||||||
R.layout.source_compact_grid_item, R.layout.source_comfortable_grid_item, null -> 1
|
R.layout.source_compact_grid_item, R.layout.source_comfortable_grid_item -> 1
|
||||||
else -> spanCount
|
else -> spanCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,9 +273,9 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
)
|
)
|
||||||
|
|
||||||
val displayItem = when (preferences.sourceDisplayMode().get()) {
|
val displayItem = when (preferences.sourceDisplayMode().get()) {
|
||||||
DisplayModeSetting.COMPACT_GRID -> R.id.action_compact_grid
|
|
||||||
DisplayModeSetting.COMFORTABLE_GRID -> R.id.action_comfortable_grid
|
|
||||||
DisplayModeSetting.LIST -> R.id.action_list
|
DisplayModeSetting.LIST -> R.id.action_list
|
||||||
|
DisplayModeSetting.COMFORTABLE_GRID -> R.id.action_comfortable_grid
|
||||||
|
else -> R.id.action_compact_grid
|
||||||
}
|
}
|
||||||
menu.findItem(displayItem).isChecked = true
|
menu.findItem(displayItem).isChecked = true
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
|||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
return when (displayMode.get()) {
|
return when (displayMode.get()) {
|
||||||
DisplayModeSetting.COMPACT_GRID -> R.layout.source_compact_grid_item
|
|
||||||
DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
|
||||||
DisplayModeSetting.LIST -> R.layout.source_list_item
|
DisplayModeSetting.LIST -> R.layout.source_list_item
|
||||||
|
DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
||||||
|
else -> R.layout.source_compact_grid_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,22 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
|||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||||
): SourceHolder<*> {
|
): SourceHolder<*> {
|
||||||
return when (displayMode.get()) {
|
return when (displayMode.get()) {
|
||||||
DisplayModeSetting.COMPACT_GRID -> {
|
DisplayModeSetting.LIST -> {
|
||||||
|
SourceListHolder(view, adapter)
|
||||||
|
}
|
||||||
|
DisplayModeSetting.COMFORTABLE_GRID -> {
|
||||||
|
val binding = SourceComfortableGridItemBinding.bind(view)
|
||||||
|
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||||
|
val coverHeight = parent.itemWidth / 3 * 4
|
||||||
|
view.apply {
|
||||||
|
binding.card.layoutParams = ConstraintLayout.LayoutParams(
|
||||||
|
MATCH_PARENT,
|
||||||
|
coverHeight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SourceComfortableGridHolder(view, adapter)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
val binding = SourceCompactGridItemBinding.bind(view)
|
val binding = SourceCompactGridItemBinding.bind(view)
|
||||||
val parent = adapter.recyclerView as AutofitRecyclerView
|
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||||
val coverHeight = parent.itemWidth / 3 * 4
|
val coverHeight = parent.itemWidth / 3 * 4
|
||||||
@ -50,21 +65,6 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
|||||||
}
|
}
|
||||||
SourceCompactGridHolder(view, adapter)
|
SourceCompactGridHolder(view, adapter)
|
||||||
}
|
}
|
||||||
DisplayModeSetting.COMFORTABLE_GRID -> {
|
|
||||||
val binding = SourceComfortableGridItemBinding.bind(view)
|
|
||||||
val parent = adapter.recyclerView as AutofitRecyclerView
|
|
||||||
val coverHeight = parent.itemWidth / 3 * 4
|
|
||||||
view.apply {
|
|
||||||
binding.card.layoutParams = ConstraintLayout.LayoutParams(
|
|
||||||
MATCH_PARENT,
|
|
||||||
coverHeight
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SourceComfortableGridHolder(view, adapter)
|
|
||||||
}
|
|
||||||
DisplayModeSetting.LIST -> {
|
|
||||||
SourceListHolder(view, adapter)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import coil.clear
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.tachiyomi.databinding.SourceCoverOnlyGridItemBinding
|
||||||
|
import eu.kanade.tachiyomi.util.view.loadAnyAutoPause
|
||||||
|
|
||||||
|
class LibraryCoverOnlyGridHolder(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||||
|
) : LibraryHolder<SourceCoverOnlyGridItemBinding>(view, adapter) {
|
||||||
|
|
||||||
|
override val binding = SourceCoverOnlyGridItemBinding.bind(view)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this
|
||||||
|
* holder with the given manga.
|
||||||
|
*
|
||||||
|
* @param item the manga item to bind.
|
||||||
|
*/
|
||||||
|
override fun onSetValues(item: LibraryItem) {
|
||||||
|
// For rounded corners
|
||||||
|
binding.badges.leftBadges.clipToOutline = true
|
||||||
|
binding.badges.rightBadges.clipToOutline = true
|
||||||
|
|
||||||
|
// Update the unread count and its visibility.
|
||||||
|
with(binding.badges.unreadText) {
|
||||||
|
isVisible = item.unreadCount > 0
|
||||||
|
text = item.unreadCount.toString()
|
||||||
|
}
|
||||||
|
// Update the download count and its visibility.
|
||||||
|
with(binding.badges.downloadText) {
|
||||||
|
isVisible = item.downloadCount > 0
|
||||||
|
text = item.downloadCount.toString()
|
||||||
|
}
|
||||||
|
// Update the source language and its visibility
|
||||||
|
with(binding.badges.languageText) {
|
||||||
|
isVisible = item.sourceLanguage.isNotEmpty()
|
||||||
|
text = item.sourceLanguage
|
||||||
|
}
|
||||||
|
// set local visibility if its local manga
|
||||||
|
binding.badges.localText.isVisible = item.isLocal
|
||||||
|
|
||||||
|
// For rounded corners
|
||||||
|
binding.card.clipToOutline = true
|
||||||
|
|
||||||
|
// Update the cover.
|
||||||
|
binding.thumbnail.clear()
|
||||||
|
if (!item.manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
|
binding.thumbnail.loadAnyAutoPause(item.manga)
|
||||||
|
} else {
|
||||||
|
// Set manga title
|
||||||
|
binding.title.text = item.manga.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
|
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
|
||||||
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
|
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
|
||||||
|
import eu.kanade.tachiyomi.databinding.SourceCoverOnlyGridItemBinding
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
@ -48,6 +49,7 @@ class LibraryItem(
|
|||||||
return when (getDisplayMode()) {
|
return when (getDisplayMode()) {
|
||||||
DisplayModeSetting.COMPACT_GRID -> R.layout.source_compact_grid_item
|
DisplayModeSetting.COMPACT_GRID -> R.layout.source_compact_grid_item
|
||||||
DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
||||||
|
DisplayModeSetting.COVER_ONLY_GRID -> R.layout.source_cover_only_grid_item
|
||||||
DisplayModeSetting.LIST -> R.layout.source_list_item
|
DisplayModeSetting.LIST -> R.layout.source_list_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,6 +82,18 @@ class LibraryItem(
|
|||||||
}
|
}
|
||||||
LibraryComfortableGridHolder(view, adapter)
|
LibraryComfortableGridHolder(view, adapter)
|
||||||
}
|
}
|
||||||
|
DisplayModeSetting.COVER_ONLY_GRID -> {
|
||||||
|
val binding = SourceCoverOnlyGridItemBinding.bind(view)
|
||||||
|
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||||
|
val coverHeight = parent.itemWidth / 3 * 4
|
||||||
|
view.apply {
|
||||||
|
binding.card.layoutParams = ConstraintLayout.LayoutParams(
|
||||||
|
MATCH_PARENT,
|
||||||
|
coverHeight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
LibraryCoverOnlyGridHolder(view, adapter)
|
||||||
|
}
|
||||||
DisplayModeSetting.LIST -> {
|
DisplayModeSetting.LIST -> {
|
||||||
LibraryListHolder(view, adapter)
|
LibraryListHolder(view, adapter)
|
||||||
}
|
}
|
||||||
|
@ -315,10 +315,11 @@ class LibrarySettingsSheet(
|
|||||||
|
|
||||||
private val compactGrid = Item.Radio(R.string.action_display_grid, this)
|
private val compactGrid = Item.Radio(R.string.action_display_grid, this)
|
||||||
private val comfortableGrid = Item.Radio(R.string.action_display_comfortable_grid, this)
|
private val comfortableGrid = Item.Radio(R.string.action_display_comfortable_grid, this)
|
||||||
|
private val coverOnlyGrid = Item.Radio(R.string.action_display_cover_only_grid, this)
|
||||||
private val list = Item.Radio(R.string.action_display_list, this)
|
private val list = Item.Radio(R.string.action_display_list, this)
|
||||||
|
|
||||||
override val header = Item.Header(R.string.action_display_mode)
|
override val header = Item.Header(R.string.action_display_mode)
|
||||||
override val items = listOf(compactGrid, comfortableGrid, list)
|
override val items = listOf(compactGrid, comfortableGrid, coverOnlyGrid, list)
|
||||||
override val footer = null
|
override val footer = null
|
||||||
|
|
||||||
override fun initModels() {
|
override fun initModels() {
|
||||||
@ -342,6 +343,7 @@ class LibrarySettingsSheet(
|
|||||||
fun setGroupSelections(mode: DisplayModeSetting) {
|
fun setGroupSelections(mode: DisplayModeSetting) {
|
||||||
compactGrid.checked = mode == DisplayModeSetting.COMPACT_GRID
|
compactGrid.checked = mode == DisplayModeSetting.COMPACT_GRID
|
||||||
comfortableGrid.checked = mode == DisplayModeSetting.COMFORTABLE_GRID
|
comfortableGrid.checked = mode == DisplayModeSetting.COMFORTABLE_GRID
|
||||||
|
coverOnlyGrid.checked = mode == DisplayModeSetting.COVER_ONLY_GRID
|
||||||
list.checked = mode == DisplayModeSetting.LIST
|
list.checked = mode == DisplayModeSetting.LIST
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,6 +351,7 @@ class LibrarySettingsSheet(
|
|||||||
val flag = when (item) {
|
val flag = when (item) {
|
||||||
compactGrid -> DisplayModeSetting.COMPACT_GRID
|
compactGrid -> DisplayModeSetting.COMPACT_GRID
|
||||||
comfortableGrid -> DisplayModeSetting.COMFORTABLE_GRID
|
comfortableGrid -> DisplayModeSetting.COMFORTABLE_GRID
|
||||||
|
coverOnlyGrid -> DisplayModeSetting.COVER_ONLY_GRID
|
||||||
list -> DisplayModeSetting.LIST
|
list -> DisplayModeSetting.LIST
|
||||||
else -> throw NotImplementedError("Unknown display mode")
|
else -> throw NotImplementedError("Unknown display mode")
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.library.setting
|
|||||||
enum class DisplayModeSetting(val flag: Int) {
|
enum class DisplayModeSetting(val flag: Int) {
|
||||||
COMPACT_GRID(0b00000000),
|
COMPACT_GRID(0b00000000),
|
||||||
COMFORTABLE_GRID(0b00000001),
|
COMFORTABLE_GRID(0b00000001),
|
||||||
LIST(0b00000010);
|
LIST(0b00000010),
|
||||||
|
COVER_ONLY_GRID(0b00000100);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MASK = 0b00000011
|
const val MASK = 0b00000111
|
||||||
|
|
||||||
fun fromFlag(flag: Int?): DisplayModeSetting {
|
fun fromFlag(flag: Int?): DisplayModeSetting {
|
||||||
return values()
|
return values()
|
||||||
|
68
app/src/main/res/layout/source_cover_only_grid_item.xml
Normal file
68
app/src/main/res/layout/source_cover_only_grid_item.xml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="2dp"
|
||||||
|
android:background="@drawable/library_item_selector"
|
||||||
|
android:foreground="@drawable/library_item_selector_overlay"
|
||||||
|
android:padding="4dp">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/card"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="220dp"
|
||||||
|
android:background="@drawable/rounded_rectangle"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/thumbnail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorSurface"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:ignore="ContentDescription"
|
||||||
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:shadowColor="@color/md_black_1000"
|
||||||
|
android:shadowDx="0"
|
||||||
|
android:shadowDy="0"
|
||||||
|
android:shadowRadius="4"
|
||||||
|
android:textAppearance="?attr/textAppearanceTitleSmall"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/md_white_1000"
|
||||||
|
tools:text="Sample name" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/badges"
|
||||||
|
layout="@layout/source_grid_item_badges" />
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||||
|
android:id="@+id/progress"
|
||||||
|
style="@style/Widget.Tachiyomi.CircularProgressIndicator.Small"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
@ -91,6 +91,7 @@
|
|||||||
<string name="action_display_grid">Compact grid</string>
|
<string name="action_display_grid">Compact grid</string>
|
||||||
<string name="action_display_comfortable_grid">Comfortable grid</string>
|
<string name="action_display_comfortable_grid">Comfortable grid</string>
|
||||||
<string name="action_display_list">List</string>
|
<string name="action_display_list">List</string>
|
||||||
|
<string name="action_display_cover_only_grid">Cover only grid</string>
|
||||||
<string name="action_display_download_badge">Downloaded chapters</string>
|
<string name="action_display_download_badge">Downloaded chapters</string>
|
||||||
<string name="action_display_unread_badge">Unread chapters</string>
|
<string name="action_display_unread_badge">Unread chapters</string>
|
||||||
<string name="action_display_local_badge">Local manga</string>
|
<string name="action_display_local_badge">Local manga</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user