diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt index 2354601929..c361cc9f41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt @@ -17,7 +17,6 @@ import com.f2prateek.rx.preferences.Preference import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.Snackbar import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents -import com.jakewharton.rxbinding.view.visible import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R @@ -239,7 +238,7 @@ open class BrowseCatalogueController(bundle: Bundle) : (layoutManager as androidx.recyclerview.widget.GridLayoutManager).spanSizeLookup = object : androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup() { override fun getSpanSize(position: Int): Int { return when (adapter?.getItemViewType(position)) { - R.layout.catalogue_mat_grid_item, null -> 1 + R.layout.catalogue_grid_item, null -> 1 else -> spanCount } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueGridHolder.kt index 0fb957f2cc..97fc021bb5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueGridHolder.kt @@ -1,51 +1,63 @@ package eu.kanade.tachiyomi.ui.catalogue.browse import android.view.View +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions +import com.bumptech.glide.signature.ObjectKey import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.glide.GlideApp +import eu.kanade.tachiyomi.ui.library.LibraryCategoryAdapter +import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.widget.StateImageViewTarget import kotlinx.android.synthetic.main.catalogue_grid_item.* -import androidx.recyclerview.widget.RecyclerView -import eu.davidea.flexibleadapter.items.IFlexible /** - * Class used to hold the displayed data of a manga in the catalogue, like the cover or the title. + * Class used to hold the displayed data of a manga in the library, like the cover or the title. * All the elements from the layout file "item_catalogue_grid" are available in this class. * * @param view the inflated view for this holder. * @param adapter the adapter handling this holder. - * @constructor creates a new catalogue holder. + * @param listener a listener to react to single tap and long tap events. + * @constructor creates a new library holder. */ -class CatalogueGridHolder(private val view: View, private val adapter: FlexibleAdapter>) : - CatalogueHolder(view, adapter) { +class CatalogueGridHolder( + private val view: View, + private val adapter: FlexibleAdapter>) : + CatalogueHolder(view, adapter) { /** - * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this + * Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this * holder with the given manga. * - * @param manga the manga to bind. + * @param manga the manga item to bind. */ override fun onSetValues(manga: Manga) { - // Set manga title - title.text = manga.originalTitle() + // Update the title of the manga. + title.text = manga.currentTitle() + subtitle.gone() - // Set alpha of thumbnail. - thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f + bookmark_text.visibility = if (manga.favorite) View.VISIBLE else View.GONE + // Update the cover. setImage(manga) } override fun setImage(manga: Manga) { - GlideApp.with(view.context).clear(thumbnail) - if (!manga.thumbnail_url.isNullOrEmpty()) { + if (manga.thumbnail_url == null) + Glide.with(view.context).clear(cover_thumbnail) + else { GlideApp.with(view.context) - .load(manga) - .diskCacheStrategy(DiskCacheStrategy.DATA) - .centerCrop() - .placeholder(android.R.color.transparent) - .into(StateImageViewTarget(thumbnail, progress)) + .load(manga) + .diskCacheStrategy(DiskCacheStrategy.DATA) + .centerCrop() + .placeholder(android.R.color.transparent) + .transition(DrawableTransitionOptions.withCrossFade()) + .into(StateImageViewTarget(cover_thumbnail, progress)) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueItem.kt index a7c2944387..071dfb2540 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueItem.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.catalogue.browse -import android.view.Gravity import android.view.View import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT @@ -13,10 +12,8 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.getOrDefault -import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.widget.AutofitRecyclerView import kotlinx.android.synthetic.main.catalogue_grid_item.view.* -import kotlinx.android.synthetic.main.catalogue_mat_grid_item.view.* class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference) : AbstractFlexibleItem() { @@ -25,7 +22,7 @@ class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference>): CatalogueHolder { @@ -37,7 +34,7 @@ class CatalogueItem(val manga: Manga, private val catalogueAsList: Preference>) : CatalogueHolder(view, adapter) { - private val favoriteColor = view.context.getResourceColor(android.R.attr.textColorHint) - private val unfavoriteColor = view.context.getResourceColor(android.R.attr.textColorPrimary) - /** * Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this * holder with the given manga. @@ -33,22 +32,26 @@ class CatalogueListHolder(private val view: View, adapter: FlexibleAdapter>) : - CatalogueHolder(view, adapter) { - - /** - * Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this - * holder with the given manga. - * - * @param manga the manga item to bind. - */ - override fun onSetValues(manga: Manga) { - // Update the title of the manga. - title.text = manga.currentTitle() - subtitle.gone() - - bookmark_text.visibility = if (manga.favorite) View.VISIBLE else View.GONE - - // Update the cover. - setImage(manga) - } - - override fun setImage(manga: Manga) { - if (manga.thumbnail_url == null) - Glide.with(view.context).clear(cover_thumbnail) - else { - GlideApp.with(view.context) - .load(manga) - .diskCacheStrategy(DiskCacheStrategy.DATA) - .centerCrop() - .placeholder(android.R.color.transparent) - .transition(DrawableTransitionOptions.withCrossFade()) - .into(StateImageViewTarget(cover_thumbnail, progress)) - } - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 69d8472033..4aa2a1f4a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -245,6 +245,11 @@ class LibraryController( } } + override fun onActivityPaused(activity: Activity) { + super.onActivityPaused(activity) + presenter.onDestroy() + } + override fun onDestroy() { presenter.onDestroy() super.onDestroy() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt index c4537e2c34..43bb338244 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt @@ -1,18 +1,17 @@ package eu.kanade.tachiyomi.ui.library import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView +import androidx.core.content.ContextCompat +import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.signature.ObjectKey -import eu.davidea.flexibleadapter.FlexibleAdapter -import eu.davidea.flexibleadapter.items.IFlexible +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.source.LocalSource -import eu.kanade.tachiyomi.util.system.dpToPx -import eu.kanade.tachiyomi.util.view.updateLayoutParams +import eu.kanade.tachiyomi.util.system.getResourceColor import kotlinx.android.synthetic.main.catalogue_grid_item.* +import kotlinx.android.synthetic.main.catalogue_grid_item.view.* /** * Class used to hold the displayed data of a manga in the library, like the cover or the title. @@ -24,9 +23,10 @@ import kotlinx.android.synthetic.main.catalogue_grid_item.* * @constructor creates a new library holder. */ class LibraryGridHolder( - private val view: View, - adapter: LibraryCategoryAdapter - + private val view: View, + adapter: LibraryCategoryAdapter, + var width:Int, + var fixedSize: Boolean ) : LibraryHolder(view, adapter) { /** @@ -37,35 +37,70 @@ class LibraryGridHolder( */ override fun onSetValues(item: LibraryItem) { // Update the title of the manga. - with(title) { - visibility = if (item.manga.hide_title) View.GONE else View.VISIBLE - text = item.manga.currentTitle() - } - gradient.visibility = if (item.manga.hide_title) View.GONE else View.VISIBLE + title.text = item.manga.currentTitle() // Update the unread count and its visibility. - with(unread_text) { - visibility = - if (item.manga.unread > 0 && item.unreadType == 1) View.VISIBLE else View.GONE - text = item.manga.unread.toString() + val unread = item.manga.unread + + // Update the subtitle of the manga with artist or the unread count + with(subtitle) { + text = when { + item.manga.unread > 0 -> when (item.unreadType) { + 1 -> view.resources.getQuantityString(R.plurals.unread_count, unread, unread) + 0 -> view.resources.getString(R.string.new_chapter) + else -> item.manga.originalAuthor() + } + else -> item.manga.originalAuthor() + } + setTextColor( + view.context.getResourceColor( + if (item.manga.unread > 0 && item.unreadType > -1) android.R.attr.colorAccent + else android.R.attr.textColorSecondary + ) + ) } - // Update the download count and its visibility. - unread_badge.visibility = - if (item.manga.unread > 0 && item.unreadType == 0) View.VISIBLE else View.GONE + play_layout.visibility = if (unread > 0) View.VISIBLE else View.GONE + play_layout.setOnClickListener { playButtonClicked() } + + // Update the download count or local status and its visibility. with(download_text) { - visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE - text = item.downloadCount.toString() + visibility = if (item.downloadCount > -1 && (item.downloadCount > 0 || item.manga + .source == LocalSource.ID)) + View.VISIBLE else View.GONE + text = if (item.manga.source == LocalSource.ID) + itemView.resources.getString(R.string.local_source_badge) + else item.downloadCount.toString() + backgroundTintList = ContextCompat.getColorStateList(itemView.context, + if (item.manga.source == LocalSource.ID) R.color.md_teal_500 + else R.color.md_red_500) } - //set local visibility if its local manga - local_text.visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE // Update the cover. - if (item.manga.thumbnail_url == null) - GlideApp.with(view.context).clear(thumbnail) - else GlideApp.with(view.context).load(item.manga) - .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) - .signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString())) - .centerCrop().into(thumbnail) + if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail) + else { + val id = item.manga.id ?: return + var glide = GlideApp.with(view.context).load(item.manga) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString())) + glide = if (fixedSize) glide.centerCrop() else glide.override(width) + glide.into(cover_thumbnail) + } + } + + private fun playButtonClicked() { + adapter.libraryListener.startReading(adapterPosition) + } + + override fun onActionStateChanged(position: Int, actionState: Int) { + super.onActionStateChanged(position, actionState) + if (actionState == 2) { + view.card.isDragged = true + } + } + + override fun onItemReleased(position: Int) { + super.onItemReleased(position) + view.card.isDragged = false } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index 396f38d8fe..381e1b7ba9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.data.database.models.LibraryManga import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.widget.AutofitRecyclerView -import kotlinx.android.synthetic.main.catalogue_mat_grid_item.view.* +import kotlinx.android.synthetic.main.catalogue_grid_item.view.* import uy.kohesive.injekt.injectLazy class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference, @@ -29,7 +29,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference return if (libraryAsList.getOrDefault()) R.layout.catalogue_list_item else - R.layout.catalogue_mat_grid_item + R.layout.catalogue_grid_item } override fun createViewHolder(view: View, adapter: FlexibleAdapter>): LibraryHolder { @@ -51,7 +51,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference cover_thumbnail.maxHeight = (parent.itemWidth / 3f * 6f).toInt() } } - LibraryMatGridHolder(view, adapter as LibraryCategoryAdapter, parent.itemWidth, fixedSize) + LibraryGridHolder(view, adapter as LibraryCategoryAdapter, parent.itemWidth, fixedSize) } else { LibraryListHolder(view, adapter as LibraryCategoryAdapter) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index df8fba1fe8..7a80328bc8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt @@ -1,22 +1,21 @@ package eu.kanade.tachiyomi.ui.library +import android.text.Html import android.view.View +import androidx.core.content.ContextCompat +import androidx.core.text.HtmlCompat +import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy -import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.source.LocalSource import kotlinx.android.synthetic.main.catalogue_list_item.* -import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.signature.ObjectKey -import eu.davidea.flexibleadapter.items.IFlexible +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.MangaImpl -import kotlinx.android.synthetic.main.catalogue_grid_item.* -import kotlinx.android.synthetic.main.catalogue_list_item.download_text -import kotlinx.android.synthetic.main.catalogue_list_item.local_text -import kotlinx.android.synthetic.main.catalogue_list_item.thumbnail +import eu.kanade.tachiyomi.util.system.getResourceColor +import kotlinx.android.synthetic.main.catalogue_list_item.subtitle import kotlinx.android.synthetic.main.catalogue_list_item.title -import kotlinx.android.synthetic.main.catalogue_list_item.unread_badge -import kotlinx.android.synthetic.main.catalogue_list_item.unread_text +import kotlinx.android.synthetic.main.catalogue_list_item.view.* /** * Class used to hold the displayed data of a manga in the library, like the cover or the title. @@ -44,37 +43,89 @@ class LibraryListHolder( title.text = item.manga.currentTitle() // Update the unread count and its visibility. - with(unread_text) { - visibility = if (item.manga.unread > 0 && item.unreadType == 1) View.VISIBLE else - View.GONE - text = item.manga.unread.toString() - } - unread_badge.visibility = - if (item.manga.unread > 0 && item.unreadType == 0) View.VISIBLE else View.GONE - // Update the download count and its visibility. - with(download_text) { - visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE - text = "${item.downloadCount}" - } - //show local text badge if local manga - local_text.visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE + val unread = item.manga.unread - // Create thumbnail onclick to simulate long click - thumbnail.setOnClickListener { - // Simulate long click on this view to enter selection mode - onLongClick(itemView) + // Update the subtitle of the manga with artist or the unread count and download count + "First Color" + val subtitleText = when { + unread > 0 -> when (item.unreadType) { + 1 -> view.resources.getQuantityString(R.plurals.unread_count, unread, unread) + 0 -> view.resources.getString(R.string.new_chapter) + else -> item.manga.originalAuthor() + } + else -> item.manga.originalAuthor() } + // Update the download count or local status and its visibility. + val downloadText = + if (item.manga.source == LocalSource.ID) + itemView.resources.getString(R.string.local_source_badge) + else view.resources.getQuantityString(R.plurals.download_count, + item.downloadCount, item.downloadCount) + + // Combine the 2 above using html + val subText = if (item.downloadCount > 0 || item.manga.source == LocalSource.ID) { + val downloadColor = convertColor(ContextCompat.getColor(itemView.context, + if (item.manga.source == LocalSource.ID) R.color.md_teal_500 + else R.color.md_red_500)) + val unreadColor = convertColor(itemView.context.getResourceColor(R.attr.colorAccent)) + when { + unread > 0 && item.unreadType > -1 -> "$downloadText | " + + "$subtitleText" + subtitleText != null -> "$downloadText | " + + subtitleText + else -> "$downloadText" + } + } + else { + subtitleText + } + with(subtitle) { + text = HtmlCompat.fromHtml(subText ?: "", HtmlCompat.FROM_HTML_MODE_LEGACY) + setTextColor( + view.context.getResourceColor( + if (item.manga.unread > 0 && item.unreadType > -1 && item.downloadCount <= 0 + && item.manga.source != LocalSource.ID) + android.R.attr.colorAccent + else android.R.attr.textColorSecondary + ) + ) + } + play_layout.visibility = if (unread > 0) View.VISIBLE else View.GONE + play_layout.setOnClickListener { playButtonClicked() } // Update the cover. - GlideApp.with(itemView.context).clear(thumbnail) - GlideApp.with(itemView.context) - .load(item.manga) - .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) - .signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString())) - .centerCrop() - .circleCrop() - .dontAnimate() - .into(thumbnail) + if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail) + else { + val id = item.manga.id ?: return + val height = itemView.context.resources.getDimensionPixelSize(R.dimen + .material_component_lists_single_line_with_avatar_height) + GlideApp.with(view.context).load(item.manga) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString())) + .override(height) + .into(cover_thumbnail) + } + } + + private fun convertColor(color: Int):String { + return Integer.toHexString(color and 0x00ffffff) + } + + private fun playButtonClicked() { + adapter.libraryListener.startReading(adapterPosition) + } + + override fun onActionStateChanged(position: Int, actionState: Int) { + super.onActionStateChanged(position, actionState) + if (actionState == 2) { + view.card.isDragged = true + } + } + + override fun onItemReleased(position: Int) { + super.onItemReleased(position) + view.card.isDragged = false } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMatGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMatGridHolder.kt deleted file mode 100644 index 406b6e78dd..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMatGridHolder.kt +++ /dev/null @@ -1,100 +0,0 @@ -package eu.kanade.tachiyomi.ui.library - -import android.view.View -import com.bumptech.glide.Glide -import com.bumptech.glide.load.engine.DiskCacheStrategy -import com.bumptech.glide.signature.ObjectKey -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.MangaImpl -import eu.kanade.tachiyomi.data.glide.GlideApp -import eu.kanade.tachiyomi.source.LocalSource -import eu.kanade.tachiyomi.util.system.getResourceColor -import kotlinx.android.synthetic.main.catalogue_mat_grid_item.* -import kotlinx.android.synthetic.main.catalogue_mat_grid_item.view.* - -/** - * Class used to hold the displayed data of a manga in the library, like the cover or the title. - * All the elements from the layout file "item_catalogue_grid" are available in this class. - * - * @param view the inflated view for this holder. - * @param adapter the adapter handling this holder. - * @param listener a listener to react to single tap and long tap events. - * @constructor creates a new library holder. - */ -class LibraryMatGridHolder( - private val view: View, - adapter: LibraryCategoryAdapter, - var width:Int, - var fixedSize: Boolean -) : LibraryHolder(view, adapter) { - - /** - * 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) { - // Update the title of the manga. - title.text = item.manga.currentTitle() - - // Update the unread count and its visibility. - val unread = item.manga.unread - - // Update the subtitle of the manga with artist or the unread count - with(subtitle) { - text = when { - item.manga.unread > 0 -> when (item.unreadType) { - 1 -> view.resources.getQuantityString(R.plurals.unread_count, unread, unread) - 0 -> view.resources.getString(R.string.new_chapter) - else -> item.manga.originalAuthor() - } - else -> item.manga.originalAuthor() - } - setTextColor( - view.context.getResourceColor( - if (item.manga.unread > 0 && item.unreadType > -1) android.R.attr.colorAccent - else android.R.attr.textColorSecondary - ) - ) - } - play_layout.visibility = if (unread > 0) View.VISIBLE else View.GONE - play_layout.setOnClickListener { playButtonClicked() } - - // Update the download count and its visibility. - with(download_text) { - visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE - text = item.downloadCount.toString() - } - // Set local visibility if its local manga - local_text.visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE - - // Update the cover. - if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail) - else { - val id = item.manga.id ?: return - var glide = GlideApp.with(view.context).load(item.manga) - .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString())) - glide = if (fixedSize) glide.centerCrop() else glide.override(width) - glide.into(cover_thumbnail) - } - } - - private fun playButtonClicked() { - adapter.libraryListener.startReading(adapterPosition) - } - - override fun onActionStateChanged(position: Int, actionState: Int) { - super.onActionStateChanged(position, actionState) - if (actionState == 2) { - view.card.isDragged = true - } - } - - override fun onItemReleased(position: Int) { - super.onItemReleased(position) - view.card.isDragged = false - } - -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index d717442774..83d268221c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -84,8 +84,6 @@ class LibraryPresenter( private var currentMangaMap:LibraryMap? = null - private var readerSubscription: Subscription? = null - fun isDownloading() = downloadManager.hasQueue() fun onDestroy() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt index 61a9a14199..82ac9a4967 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt @@ -19,20 +19,20 @@ class MangaHolder( title.text = item.manga.currentTitle() // Create thumbnail onclick to simulate long click - thumbnail.setOnClickListener { + cover_thumbnail.setOnClickListener { // Simulate long click on this view to enter selection mode onLongClick(itemView) } // Update the cover. - GlideApp.with(itemView.context).clear(thumbnail) + GlideApp.with(itemView.context).clear(cover_thumbnail) GlideApp.with(itemView.context) .load(item.manga) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .centerCrop() - .circleCrop() +// .centerCrop() +// .circleCrop() .dontAnimate() - .into(thumbnail) + .into(cover_thumbnail) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 97bb37d382..d7fec0040e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -52,6 +52,13 @@ class SettingsLibraryController : SettingsController() { } } + switchPreference { + key = Keys.libraryGridFixed + titleRes = R.string.pref_fixed_grid + summaryRes = R.string.pref_fixed_grid_summary + defaultValue = false + } + switchPreference { key = Keys.removeArticles titleRes = R.string.pref_remove_articles @@ -59,12 +66,6 @@ class SettingsLibraryController : SettingsController() { defaultValue = false } - switchPreference { - key = Keys.libraryGridFixed - titleRes = R.string.pref_fixed_grid - summaryRes = R.string.pref_fixed_grid_summary - defaultValue = false - } } val dbCategories = db.getCategories().executeAsBlocking() diff --git a/app/src/main/res/drawable-night/list_item_selector.xml b/app/src/main/res/drawable-night/list_item_selector.xml deleted file mode 100644 index ff1236a28c..0000000000 --- a/app/src/main/res/drawable-night/list_item_selector.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/library_item_selector.xml b/app/src/main/res/drawable/library_item_selector.xml index 07a4041479..658066ad8e 100644 --- a/app/src/main/res/drawable/library_item_selector.xml +++ b/app/src/main/res/drawable/library_item_selector.xml @@ -1,6 +1,6 @@ + android:color="@color/fullRippleColor"> - + - + - + diff --git a/app/src/main/res/drawable/list_item_selector.xml b/app/src/main/res/drawable/list_item_selector.xml index d219df8b1c..8f92da27e8 100644 --- a/app/src/main/res/drawable/list_item_selector.xml +++ b/app/src/main/res/drawable/list_item_selector.xml @@ -1,18 +1,21 @@ + android:color="@color/fullRippleColor"> + + + - + - + - - + + diff --git a/app/src/main/res/drawable/list_item_selector_amoled.xml b/app/src/main/res/drawable/list_item_selector_amoled.xml deleted file mode 100644 index e11e4e9e53..0000000000 --- a/app/src/main/res/drawable/list_item_selector_amoled.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/list_item_selector_dark.xml b/app/src/main/res/drawable/list_item_selector_dark.xml index fea6891057..48af7d3484 100644 --- a/app/src/main/res/drawable/list_item_selector_dark.xml +++ b/app/src/main/res/drawable/list_item_selector_dark.xml @@ -7,14 +7,16 @@ - - - - + + + - - - diff --git a/app/src/main/res/layout-land/filter_bottom_sheet.xml b/app/src/main/res/layout-land/filter_bottom_sheet.xml index 7a670bdccb..67aaa40f14 100644 --- a/app/src/main/res/layout-land/filter_bottom_sheet.xml +++ b/app/src/main/res/layout-land/filter_bottom_sheet.xml @@ -193,7 +193,7 @@ android:focusable="true" android:gravity="start|center" android:padding="5dp" - android:text="@string/action_display_unread_badge" + android:text="@string/action_display_unread_text" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" android:textColor="?android:attr/textColorPrimary" android:textSize="15sp" diff --git a/app/src/main/res/layout-sw600dp/filter_bottom_sheet.xml b/app/src/main/res/layout-sw600dp/filter_bottom_sheet.xml index 70c07ccabf..5c6fec5897 100644 --- a/app/src/main/res/layout-sw600dp/filter_bottom_sheet.xml +++ b/app/src/main/res/layout-sw600dp/filter_bottom_sheet.xml @@ -193,7 +193,7 @@ android:focusable="true" android:gravity="start|center" android:padding="5dp" - android:text="@string/action_display_unread_badge" + android:text="@string/action_display_unread_text" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" android:textColor="?android:attr/textColorPrimary" android:textSize="15sp" diff --git a/app/src/main/res/layout/catalogue_grid_item.xml b/app/src/main/res/layout/catalogue_grid_item.xml index e59629051f..83b13098e1 100644 --- a/app/src/main/res/layout/catalogue_grid_item.xml +++ b/app/src/main/res/layout/catalogue_grid_item.xml @@ -1,132 +1,169 @@ - + android:layout_gravity="bottom"> - + - - - + android:layout_marginTop="2dp" + android:layout_marginStart="6dp" + android:layout_marginEnd="6dp" + app:layout_constraintBottom_toTopOf="@+id/title" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="1.0"> - - + tools:background="?android:attr/colorBackground" + tools:ignore="ContentDescription" + tools:src="@mipmap/ic_launcher" /> + tools:text="1" /> + - + tools:visibility="visible" /> - + + + + + + + + + + + + android:singleLine="true" + android:textColor="?android:attr/textColorPrimary" + android:textSize="12sp" + app:layout_constraintBottom_toTopOf="@+id/subtitle" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + tools:text="Sample name" /> - + android:layout_marginBottom="14dp" + android:ellipsize="end" + android:lineSpacingExtra="-4dp" + android:layout_marginStart="6dp" + android:paddingEnd="6dp" + android:singleLine="true" + android:textColor="?android:attr/textColorSecondary" + android:textSize="12sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + tools:text="Sample artist" /> - - - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/catalogue_list_item.xml b/app/src/main/res/layout/catalogue_list_item.xml index 8cf6ecf2a9..40234a206d 100644 --- a/app/src/main/res/layout/catalogue_list_item.xml +++ b/app/src/main/res/layout/catalogue_list_item.xml @@ -1,132 +1,145 @@ - + android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height" + tools:layout_editor_absoluteX="0dp" + tools:layout_editor_absoluteY="25dp"> - - - + + + + + + + + + + + + android:singleLine="true" + android:textColor="?android:attr/textColorSecondary" + android:textSize="14sp" + app:layout_constrainedWidth="true" + app:layout_constraintEnd_toStartOf="@+id/extras_layout" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="@+id/title" + app:layout_constraintTop_toBottomOf="@+id/title" + app:layout_constraintVertical_bias="0.0" + tools:text="Manga artist" /> - - - - - - - - - + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + + + diff --git a/app/src/main/res/layout/catalogue_mat_grid_item.xml b/app/src/main/res/layout/catalogue_mat_grid_item.xml deleted file mode 100644 index 25a08faded..0000000000 --- a/app/src/main/res/layout/catalogue_mat_grid_item.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/catalogue_recycler_autofit.xml b/app/src/main/res/layout/catalogue_recycler_autofit.xml index 8003036795..7df2aaf743 100644 --- a/app/src/main/res/layout/catalogue_recycler_autofit.xml +++ b/app/src/main/res/layout/catalogue_recycler_autofit.xml @@ -8,4 +8,4 @@ android:layout_height="match_parent" android:columnWidth="140dp" android:clipToPadding="false" - tools:listitem="@layout/catalogue_mat_grid_item" /> \ No newline at end of file + tools:listitem="@layout/catalogue_grid_item" /> \ No newline at end of file diff --git a/app/src/main/res/layout/filter_bottom_sheet.xml b/app/src/main/res/layout/filter_bottom_sheet.xml index aa56f1a873..0cd2664dd7 100644 --- a/app/src/main/res/layout/filter_bottom_sheet.xml +++ b/app/src/main/res/layout/filter_bottom_sheet.xml @@ -190,7 +190,7 @@ android:focusable="true" android:gravity="start|center" android:padding="5dp" - android:text="@string/action_display_unread_badge" + android:text="@string/action_display_unread_text" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" android:textColor="?android:attr/textColorPrimary" android:textSize="15sp" diff --git a/app/src/main/res/layout/library_controller.xml b/app/src/main/res/layout/library_controller.xml index b74570b268..10389c4a66 100644 --- a/app/src/main/res/layout/library_controller.xml +++ b/app/src/main/res/layout/library_controller.xml @@ -31,7 +31,7 @@ @@ -228,7 +228,7 @@ app:layout_constraintEnd_toEndOf="parent"/> @@ -193,7 +193,7 @@ android:layout_height="wrap_content" android:text="@string/pref_zoom_start" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/verticalcenter" + app:layout_constraintEnd_toStartOf="@id/bottom_line" app:layout_constraintBaseline_toBaselineOf="@id/zoom_start"/> #212121 #212121 + @color/md_white_1000_12 #3399FF #B3000000 #FFFFFF #212121 @color/md_white_1000_20 + #707070 @color/md_grey_800 #3399FF #212121 diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index b6ee4ed8f3..82788cb292 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -31,7 +31,7 @@ @color/textColorPrimary - @drawable/list_item_selector_amoled + @drawable/list_item_selector @drawable/library_item_selector_amoled @color/dialog_amoled diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ef8c665b41..8faae86f5d 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -13,6 +13,7 @@ #323232 #323232 @color/md_white_1000 + #C2C2C2 @color/md_black_1000_12 @color/md_blue_A400 @color/md_black_1000_38 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5875db43d6..289638ab53 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -97,7 +97,7 @@ Grid List Download badges - Unread badges + Unread text All unread Any unread Hide unread @@ -197,8 +197,7 @@ Sync chapters after reading Sort by ignoring articles Fixed grid size in library - Show all covers as the same height by cropping (improves - fast scrolling performance) + Show all covers as the same height by cropping When sorting alphabetically, sort ignoring articles (a, an, the) at the start of manga titles Skip pre-migration @@ -414,10 +413,14 @@ Remove from library? New chapter - %d Unread + %d unread New Start Reading + + 1 downloaded + %d downloaded + Search filters diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c3089f614f..11721c49c5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -56,6 +56,10 @@ bold + +