From 455ebb6fa4d40b4912c42d8835caee8d35397a31 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 24 Mar 2021 00:29:21 -0400 Subject: [PATCH] Filters no longer show on first launch + option to always show hopper option is on by default + renaming 3rd section to "Categories" + refactoring --- .../data/preference/PreferenceKeys.kt | 2 ++ .../data/preference/PreferencesHelper.kt | 4 ++-- .../tachiyomi/ui/library/LibraryController.kt | 22 ++++++++++++++----- ...aryOtherView.kt => LibraryCategoryView.kt} | 8 ++++--- .../display/TabbedLibraryDisplaySheet.kt | 8 +++---- .../ui/library/filter/FilterBottomSheet.kt | 10 +-------- ...layout.xml => library_category_layout.xml} | 8 +++---- app/src/main/res/values/strings.xml | 3 ++- 8 files changed, 36 insertions(+), 29 deletions(-) rename app/src/main/java/eu/kanade/tachiyomi/ui/library/display/{LibraryOtherView.kt => LibraryCategoryView.kt} (69%) rename app/src/main/res/layout/{library_other_layout.xml => library_category_layout.xml} (86%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 4306d1fa82..830e420501 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -113,6 +113,8 @@ object PreferenceKeys { const val automaticExtUpdates = "automatic_ext_updates" + const val autoHideHopper = "autohide_hopper" + const val onlySearchPinned = "only_search_pinned" const val downloadNew = "download_new" 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 a4c2b698d3..1064798ee7 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 @@ -275,8 +275,6 @@ class PreferencesHelper(val context: Context) { fun hideStartReadingButton() = rxPrefs.getBoolean("hide_reading_button", false) - fun hideFiltersAtStart() = rxPrefs.getBoolean("hide_filters_at_start", false) - fun alwaysShowChapterTransition() = flowPrefs.getBoolean(Keys.alwaysShowChapterTransition, true) fun deleteRemovedChapters() = flowPrefs.getInt(Keys.deleteRemovedChapters, 0) @@ -289,6 +287,8 @@ class PreferencesHelper(val context: Context) { fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false) + fun autohideHopper() = flowPrefs.getBoolean(Keys.autoHideHopper, true) + fun groupLibraryBy() = flowPrefs.getInt("group_library_by", 0) fun showCategoryInTitle() = flowPrefs.getBoolean("category_in_title", false) 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 ba6258fe0d..5995ec8171 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 @@ -175,7 +175,8 @@ class LibraryController( private var scrollDistance = 0f private val scrollDistanceTilHidden = 1000.dpToPx private var textAnim: ViewPropertyAnimator? = null - var startingFiltersY = 0f + private var hasExpanded = false + var hopperGravity: Int = preferences.hopperGravity().get() set(value) { field = value @@ -211,9 +212,11 @@ class LibraryController( super.onScrolled(recyclerView, dx, dy) val recyclerCover = recycler_cover ?: return if (!recyclerCover.isClickable && isAnimatingHopper != true) { - category_hopper_frame.translationY += dy - category_hopper_frame.translationY = - category_hopper_frame.translationY.coerceIn(0f, 50f.dpToPx) + if (preferences.autohideHopper().get()) { + category_hopper_frame.translationY += dy + category_hopper_frame.translationY = + category_hopper_frame.translationY.coerceIn(0f, 50f.dpToPx) + } up_category.alpha = if (isAtTop()) 0.25f else 1f down_category.alpha = if (isAtBottom()) 0.25f else 1f } @@ -337,7 +340,7 @@ class LibraryController( } private fun showFilterTip() { - if (preferences.shownFilterTutorial().get()) return + if (preferences.shownFilterTutorial().get() || !hasExpanded) return val activity = activity ?: return val icon = activity.bottom_nav.getItemView(R.id.nav_library) ?: return filterTooltip = @@ -582,6 +585,10 @@ class LibraryController( } } + fun resetHopperY() { + category_hopper_frame.translationY = 0f + } + fun hideHopper(hide: Boolean) { category_hopper_frame.visibleIf(!hide) jumper_category_text.visibleIf(!hide) @@ -1339,7 +1346,10 @@ class LibraryController( override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.action_search -> expandActionViewFromInteraction = true - R.id.action_filter -> filter_bottom_sheet.sheetBehavior?.expand() + R.id.action_filter -> { + hasExpanded = true + filter_bottom_sheet.sheetBehavior?.expand() + } else -> return super.onOptionsItemSelected(item) } return true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryOtherView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt similarity index 69% rename from app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryOtherView.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt index 42cad1da60..b172b7e12e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryOtherView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt @@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.library.display import android.content.Context import android.util.AttributeSet -import kotlinx.android.synthetic.main.library_other_layout.view.* +import kotlinx.android.synthetic.main.library_category_layout.view.* -class LibraryOtherView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : +class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LibraryPreferenceView(context, attrs) { override fun initGeneralPreferences() { @@ -19,6 +19,8 @@ class LibraryOtherView @JvmOverloads constructor(context: Context, attrs: Attrib hide_hopper.bindToPreference(preferences.hideHopper()) { controller.hideHopper(it) } - hide_filters.bindToPreference(preferences.hideFiltersAtStart()) + auto_hide_hopper.bindToPreference(preferences.autohideHopper()) { + controller.resetHopperY() + } } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt index 06dbd69c7a..06399dbd58 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt @@ -16,12 +16,12 @@ open class TabbedLibraryDisplaySheet(controller: LibraryController): private val displayView: LibraryDisplayView = inflate(controller.activity!!, R.layout.library_display_layout, null) as LibraryDisplayView private val badgesView: LibraryBadgesView = inflate(controller.activity!!, R.layout.library_badges_layout, null) as LibraryBadgesView - private val otherView: LibraryOtherView = inflate(controller.activity!!, R.layout.library_other_layout, null) as LibraryOtherView + private val categoryView: LibraryCategoryView = inflate(controller.activity!!, R.layout.library_category_layout, null) as LibraryCategoryView init { displayView.controller = controller badgesView.controller = controller - otherView.controller = controller + categoryView.controller = controller menu.visible() if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { menu.tooltipText = context.getString(R.string.more_library_settings) @@ -39,12 +39,12 @@ open class TabbedLibraryDisplaySheet(controller: LibraryController): override fun getTabViews(): List = listOf( displayView, badgesView, - otherView + categoryView ) override fun getTabTitles(): List = listOf( R.string.display, R.string.badges, - R.string.other + R.string.categories ) } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt index 4838c6c31e..e08959e251 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt @@ -5,7 +5,6 @@ import android.content.res.Configuration import android.os.Parcelable import android.util.AttributeSet import android.view.View -import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import androidx.recyclerview.widget.LinearLayoutManager @@ -22,10 +21,7 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryGroup -import eu.kanade.tachiyomi.ui.library.display.LibraryBadgesView -import eu.kanade.tachiyomi.ui.library.display.LibraryDisplayView import eu.kanade.tachiyomi.ui.main.MainActivity -import eu.kanade.tachiyomi.ui.setting.SettingsLibraryController import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.view.collapse @@ -36,8 +32,6 @@ import eu.kanade.tachiyomi.util.view.isExpanded import eu.kanade.tachiyomi.util.view.isHidden import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.visibleIf -import eu.kanade.tachiyomi.util.view.withFadeTransaction -import eu.kanade.tachiyomi.widget.ViewPagerAdapter import kotlinx.android.synthetic.main.filter_bottom_sheet.view.* import kotlinx.android.synthetic.main.library_grid_recycler.* import kotlinx.android.synthetic.main.library_list_controller.* @@ -144,9 +138,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri second_layout.gone() } - if (preferences.hideFiltersAtStart().getOrDefault()) { - sheetBehavior?.hide() - } + sheetBehavior?.hide() expand_categories.setOnClickListener { onGroupClicked(ACTION_EXPAND_COLLAPSE_ALL) } diff --git a/app/src/main/res/layout/library_other_layout.xml b/app/src/main/res/layout/library_category_layout.xml similarity index 86% rename from app/src/main/res/layout/library_other_layout.xml rename to app/src/main/res/layout/library_category_layout.xml index e134292b33..967555f158 100644 --- a/app/src/main/res/layout/library_other_layout.xml +++ b/app/src/main/res/layout/library_category_layout.xml @@ -1,5 +1,5 @@ - @@ -29,10 +29,10 @@ android:text="@string/hide_category_hopper" /> - \ No newline at end of file + android:text="@string/hide_hopper_on_scroll" /> + \ 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 e5564bcb30..08970908f1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -162,6 +162,7 @@ Tap the Library icon to show filters Display as Hide category hopper + Hide category hopper on scroll More library settings @@ -515,7 +516,7 @@ Check for updates Automatically check for new app versions Secure screen - Auto-Hide bottom navigation + Auto-hide bottom navigation Hides when scrolling Hide Tachiyomi from the recents screen Security