diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 9d4d085e5f..4a27738688 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -280,6 +280,8 @@ class PreferencesHelper(val context: Context) { fun collapsedDynamicCategories() = flowPrefs.getStringSet("collapsed_dynamic_categories", mutableSetOf()) + fun collapsedDynamicAtBottom() = flowPrefs.getBoolean("collapsed_dynamic_at_bottom", false) + fun hiddenSources() = flowPrefs.getStringSet("hidden_catalogues", mutableSetOf()) fun pinnedCatalogues() = rxPrefs.getStringSet("pinned_catalogues", emptySet()) 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 a06a70b9f5..df0a9e2925 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 @@ -590,7 +590,7 @@ class LibraryPresenter( }.flatten().toMutableList() val hiddenDynamics = preferences.collapsedDynamicCategories().get() - val headers = tagItems.map { item -> + var headers = tagItems.map { item -> Category.createCustom( item.key, preferences.librarySortingMode().getOrDefault(), @@ -611,6 +611,9 @@ class LibraryPresenter( it.name } } + if (preferences.collapsedDynamicAtBottom().get()) { + headers = headers.filterNot { it.isHidden } + headers.filter { it.isHidden } + } headers.forEach { category -> val catId = category.id ?: return@forEach val headerItem = tagItems[if (category.sourceId != null) "${category.name}$sourceSplitter${category.sourceId}" else category.name] diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt index 693842f869..8c51f6fd5b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt @@ -2,8 +2,10 @@ package eu.kanade.tachiyomi.ui.library.display import android.content.Context import android.util.AttributeSet +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.LibraryCategoryLayoutBinding import eu.kanade.tachiyomi.util.bindToPreference +import eu.kanade.tachiyomi.util.lang.withSubtitle import eu.kanade.tachiyomi.util.system.toInt import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView import kotlin.math.min @@ -22,6 +24,11 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att categoryShow.bindToPreference(preferences.showCategoryInTitle()) { controller?.showMiniBar() } + dynamicToBottom.text = context.getString(R.string.move_dynamic_to_bottom) + .withSubtitle(context, R.string.when_grouping_by_sources_tags) + dynamicToBottom.bindToPreference(preferences.collapsedDynamicAtBottom()) { + controller?.presenter?.getLibrary() + } val hideHopper = min( 2, preferences.hideHopper().get().toInt() * 2 + preferences.autohideHopper().get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsOptionsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsOptionsSheet.kt index 986848126d..117463f669 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsOptionsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsOptionsSheet.kt @@ -32,8 +32,8 @@ class RecentsOptionsSheet(activity: Activity) : BottomSheetBehavior.from(binding.root.parent as ViewGroup).skipCollapsed = true val titleText = context.getString(R.string.show_reset_history_button) - val subtitleText = context.getString(R.string.press_and_hold_to_also_reset) - binding.showRemoveHistory.text = titleText.withSubtitle(binding.showRemoveHistory.context, subtitleText) + binding.showRemoveHistory.text = titleText + .withSubtitle(binding.showRemoveHistory.context, R.string.press_and_hold_to_also_reset) } private fun initGeneralPreferences() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt index a024734d71..595f57b7be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt @@ -12,6 +12,7 @@ import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.text.style.SuperscriptSpan import androidx.annotation.ColorInt +import androidx.annotation.StringRes import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.getResourceColor import kotlin.math.floor @@ -99,6 +100,9 @@ fun String.indexesOf(substr: String, ignoreCase: Boolean = true): List { } } +fun String.withSubtitle(context: Context, @StringRes subtitleRes: Int) = + withSubtitle(context, context.getString(subtitleRes)) + fun String.withSubtitle(context: Context, subtitle: String): Spanned { val spannable = SpannableStringBuilder(this + "\n" + subtitle) spannable.setSpan( diff --git a/app/src/main/res/layout/library_category_layout.xml b/app/src/main/res/layout/library_category_layout.xml index a569438edb..a0b022ea8c 100644 --- a/app/src/main/res/layout/library_category_layout.xml +++ b/app/src/main/res/layout/library_category_layout.xml @@ -27,6 +27,14 @@ android:layout_marginEnd="12dp" android:text="@string/show_all_categories" /> + + No matches found for your current filters Show all categories + Move collapsed dynamic categories to bottom + When grouping library by sources, status, etc. Always show current category Category hopper long-press action Expand/collapse all categories