From 8b511b5708402cfd63a6c4e95e71f1cdc5e50b5e Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 10 Aug 2021 18:55:42 -0400 Subject: [PATCH] Recent covers now follows the uniform covers setting Can also change in in Recents' display options --- .../ui/recents/RecentMangaAdapter.kt | 2 ++ .../tachiyomi/ui/recents/RecentMangaHolder.kt | 21 ++++++++++--------- .../ui/recents/options/RecentsGeneralView.kt | 4 ++++ .../main/res/layout/recents_general_view.xml | 8 +++++++ app/src/main/res/values/strings.xml | 5 ++++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt index 6ffd72098f..dcefbbaad5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaAdapter.kt @@ -22,6 +22,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) : var showRemoveHistory = preferences.showRecentsRemHistory().get() var showTitleFirst = preferences.showTitleFirstInRecents().get() var showUpdatedTime = preferences.showUpdatedTime().get() + var uniformCovers = preferences.uniformGrid().get() val viewType: Int get() = delegate.getViewType() @@ -45,6 +46,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) : preferences.showRecentsRemHistory().register { showRemoveHistory = it } preferences.showTitleFirstInRecents().register { showTitleFirst = it } preferences.showUpdatedTime().register { showUpdatedTime = it } + preferences.uniformGrid().register { uniformCovers = it } } private fun Preference.register(onChanged: (T) -> Unit) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt index b2293d4094..7b10d95b6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt @@ -40,15 +40,15 @@ class RecentMangaHolder( RecentMangaAdapter.ShowRecentsDLs.All -> true } && !item.mch.manga.isLocal() - val isUpdates = adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES && + val isSmallUpdates = adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES && !adapter.showUpdatedTime binding.cardLayout.updateLayoutParams { - height = (if (isUpdates) 40 else 80).dpToPx - width = (if (isUpdates) 40 else 60).dpToPx + height = (if (isSmallUpdates) 40 else 80).dpToPx + width = (if (isSmallUpdates) 40 else 60).dpToPx } listOf(binding.title, binding.subtitle).forEach { it.updateLayoutParams { - if (isUpdates) { + if (isSmallUpdates) { if (it == binding.title) topMargin = 5.dpToPx endToStart = R.id.button_layout endToEnd = -1 @@ -60,7 +60,7 @@ class RecentMangaHolder( } } binding.buttonLayout.updateLayoutParams { - if (isUpdates) { + if (isSmallUpdates) { topToBottom = -1 topToTop = R.id.front_view } else { @@ -68,13 +68,14 @@ class RecentMangaHolder( topToBottom = R.id.subtitle } } + val freeformCovers = !isSmallUpdates && !adapter.uniformCovers with(binding.coverThumbnail) { - adjustViewBounds = !isUpdates - scaleType = if (isUpdates) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER + adjustViewBounds = freeformCovers + scaleType = if (!freeformCovers) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER } listOf(binding.coverThumbnail, binding.card).forEach { it.updateLayoutParams { - width = if (isUpdates) { + width = if (!freeformCovers) { ViewGroup.LayoutParams.MATCH_PARENT } else { ViewGroup.LayoutParams.WRAP_CONTENT @@ -108,13 +109,13 @@ class RecentMangaHolder( ) } val notValidNum = item.mch.chapter.chapter_number <= 0 - binding.body.isVisible = !isUpdates + binding.body.isVisible = !isSmallUpdates binding.body.text = when { item.mch.chapter.id == null -> binding.body.context.getString( R.string.added_, item.mch.manga.date_added.timeSpanFromNow(itemView.context) ) - isUpdates -> "" + isSmallUpdates -> "" item.mch.history.id == null -> binding.body.context.getString( R.string.updated_, item.chapter.date_upload.timeSpanFromNow(itemView.context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt index 7f850ad50d..1df984843a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt @@ -14,11 +14,15 @@ class RecentsGeneralView @JvmOverloads constructor(context: Context, attrs: Attr override fun inflateBinding() = RecentsGeneralViewBinding.bind(this) override fun initGeneralPreferences() { val titleText = context.getString(R.string.show_reset_history_button) + val uniformText = context.getString(R.string.uniform_covers) binding.showRemoveHistory.text = titleText .withSubtitle(binding.showRemoveHistory.context, R.string.press_and_hold_to_also_reset) + binding.uniformCovers.text = uniformText + .withSubtitle(binding.uniformCovers.context, R.string.affects_library_grid) binding.showRecentsDownload.bindToPreference(preferences.showRecentsDownloads()) binding.showRemoveHistory.bindToPreference(preferences.showRecentsRemHistory()) binding.showReadInAll.bindToPreference(preferences.showReadInAllRecents()) binding.showTitleFirst.bindToPreference(preferences.showTitleFirstInRecents()) + binding.uniformCovers.bindToPreference(preferences.uniformGrid()) } } diff --git a/app/src/main/res/layout/recents_general_view.xml b/app/src/main/res/layout/recents_general_view.xml index 7471557995..20a704097f 100644 --- a/app/src/main/res/layout/recents_general_view.xml +++ b/app/src/main/res/layout/recents_general_view.xml @@ -47,5 +47,13 @@ android:text="@string/show_title_first" android:textColor="?android:attr/textColorPrimary" android:layout_marginTop="8dp" /> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b8a1d8924..3d805e345c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -173,7 +173,6 @@ Download badges Hide start reading button Badges - Uniform covers Uniform grid covers Grid size XS @@ -261,12 +260,16 @@ Only unread Only downloaded Unread or downloaded + + Show reset history button Show read chapters in Grouped and All Show title first A while ago Show updated time Group chapters together + Uniform covers + Affects library grid covers Search filters