Filters no longer show on first launch + option to always show hopper

option is on by default
+ renaming 3rd section to "Categories"
+ refactoring
This commit is contained in:
Jays2Kings 2021-03-24 00:29:21 -04:00
parent eb585e79d8
commit 455ebb6fa4
8 changed files with 36 additions and 29 deletions

View File

@ -113,6 +113,8 @@ object PreferenceKeys {
const val automaticExtUpdates = "automatic_ext_updates" const val automaticExtUpdates = "automatic_ext_updates"
const val autoHideHopper = "autohide_hopper"
const val onlySearchPinned = "only_search_pinned" const val onlySearchPinned = "only_search_pinned"
const val downloadNew = "download_new" const val downloadNew = "download_new"

View File

@ -275,8 +275,6 @@ class PreferencesHelper(val context: Context) {
fun hideStartReadingButton() = rxPrefs.getBoolean("hide_reading_button", false) 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 alwaysShowChapterTransition() = flowPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
fun deleteRemovedChapters() = flowPrefs.getInt(Keys.deleteRemovedChapters, 0) fun deleteRemovedChapters() = flowPrefs.getInt(Keys.deleteRemovedChapters, 0)
@ -289,6 +287,8 @@ class PreferencesHelper(val context: Context) {
fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false) fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false)
fun autohideHopper() = flowPrefs.getBoolean(Keys.autoHideHopper, true)
fun groupLibraryBy() = flowPrefs.getInt("group_library_by", 0) fun groupLibraryBy() = flowPrefs.getInt("group_library_by", 0)
fun showCategoryInTitle() = flowPrefs.getBoolean("category_in_title", false) fun showCategoryInTitle() = flowPrefs.getBoolean("category_in_title", false)

View File

@ -175,7 +175,8 @@ class LibraryController(
private var scrollDistance = 0f private var scrollDistance = 0f
private val scrollDistanceTilHidden = 1000.dpToPx private val scrollDistanceTilHidden = 1000.dpToPx
private var textAnim: ViewPropertyAnimator? = null private var textAnim: ViewPropertyAnimator? = null
var startingFiltersY = 0f private var hasExpanded = false
var hopperGravity: Int = preferences.hopperGravity().get() var hopperGravity: Int = preferences.hopperGravity().get()
set(value) { set(value) {
field = value field = value
@ -211,9 +212,11 @@ class LibraryController(
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)
val recyclerCover = recycler_cover ?: return val recyclerCover = recycler_cover ?: return
if (!recyclerCover.isClickable && isAnimatingHopper != true) { if (!recyclerCover.isClickable && isAnimatingHopper != true) {
if (preferences.autohideHopper().get()) {
category_hopper_frame.translationY += dy category_hopper_frame.translationY += dy
category_hopper_frame.translationY = category_hopper_frame.translationY =
category_hopper_frame.translationY.coerceIn(0f, 50f.dpToPx) category_hopper_frame.translationY.coerceIn(0f, 50f.dpToPx)
}
up_category.alpha = if (isAtTop()) 0.25f else 1f up_category.alpha = if (isAtTop()) 0.25f else 1f
down_category.alpha = if (isAtBottom()) 0.25f else 1f down_category.alpha = if (isAtBottom()) 0.25f else 1f
} }
@ -337,7 +340,7 @@ class LibraryController(
} }
private fun showFilterTip() { private fun showFilterTip() {
if (preferences.shownFilterTutorial().get()) return if (preferences.shownFilterTutorial().get() || !hasExpanded) return
val activity = activity ?: return val activity = activity ?: return
val icon = activity.bottom_nav.getItemView(R.id.nav_library) ?: return val icon = activity.bottom_nav.getItemView(R.id.nav_library) ?: return
filterTooltip = filterTooltip =
@ -582,6 +585,10 @@ class LibraryController(
} }
} }
fun resetHopperY() {
category_hopper_frame.translationY = 0f
}
fun hideHopper(hide: Boolean) { fun hideHopper(hide: Boolean) {
category_hopper_frame.visibleIf(!hide) category_hopper_frame.visibleIf(!hide)
jumper_category_text.visibleIf(!hide) jumper_category_text.visibleIf(!hide)
@ -1339,7 +1346,10 @@ class LibraryController(
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.action_search -> expandActionViewFromInteraction = true 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) else -> return super.onOptionsItemSelected(item)
} }
return true return true

View File

@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.library.display
import android.content.Context import android.content.Context
import android.util.AttributeSet 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) { LibraryPreferenceView(context, attrs) {
override fun initGeneralPreferences() { override fun initGeneralPreferences() {
@ -19,6 +19,8 @@ class LibraryOtherView @JvmOverloads constructor(context: Context, attrs: Attrib
hide_hopper.bindToPreference(preferences.hideHopper()) { hide_hopper.bindToPreference(preferences.hideHopper()) {
controller.hideHopper(it) controller.hideHopper(it)
} }
hide_filters.bindToPreference(preferences.hideFiltersAtStart()) auto_hide_hopper.bindToPreference(preferences.autohideHopper()) {
controller.resetHopperY()
}
} }
} }

View File

@ -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 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 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 { init {
displayView.controller = controller displayView.controller = controller
badgesView.controller = controller badgesView.controller = controller
otherView.controller = controller categoryView.controller = controller
menu.visible() menu.visible()
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
menu.tooltipText = context.getString(R.string.more_library_settings) menu.tooltipText = context.getString(R.string.more_library_settings)
@ -39,12 +39,12 @@ open class TabbedLibraryDisplaySheet(controller: LibraryController):
override fun getTabViews(): List<View> = listOf( override fun getTabViews(): List<View> = listOf(
displayView, displayView,
badgesView, badgesView,
otherView categoryView
) )
override fun getTabTitles(): List<Int> = listOf( override fun getTabTitles(): List<Int> = listOf(
R.string.display, R.string.display,
R.string.badges, R.string.badges,
R.string.other R.string.categories
) )
} }

View File

@ -5,7 +5,6 @@ import android.content.res.Configuration
import android.os.Parcelable import android.os.Parcelable
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager 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.data.track.TrackManager
import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.library.LibraryGroup 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.main.MainActivity
import eu.kanade.tachiyomi.ui.setting.SettingsLibraryController
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.collapse 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.isHidden
import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.visibleIf 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.filter_bottom_sheet.view.*
import kotlinx.android.synthetic.main.library_grid_recycler.* import kotlinx.android.synthetic.main.library_grid_recycler.*
import kotlinx.android.synthetic.main.library_list_controller.* import kotlinx.android.synthetic.main.library_list_controller.*
@ -144,9 +138,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
second_layout.gone() second_layout.gone()
} }
if (preferences.hideFiltersAtStart().getOrDefault()) {
sheetBehavior?.hide() sheetBehavior?.hide()
}
expand_categories.setOnClickListener { expand_categories.setOnClickListener {
onGroupClicked(ACTION_EXPAND_COLLAPSE_ALL) onGroupClicked(ACTION_EXPAND_COLLAPSE_ALL)
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<eu.kanade.tachiyomi.ui.library.display.LibraryOtherView <eu.kanade.tachiyomi.ui.library.display.LibraryCategoryView
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@ -29,10 +29,10 @@
android:text="@string/hide_category_hopper" /> android:text="@string/hide_category_hopper" />
<com.google.android.material.checkbox.MaterialCheckBox <com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/hide_filters" android:id="@+id/auto_hide_hopper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:text="@string/start_with_filters_hidden" /> android:text="@string/hide_hopper_on_scroll" />
</eu.kanade.tachiyomi.ui.library.display.LibraryOtherView> </eu.kanade.tachiyomi.ui.library.display.LibraryCategoryView>

View File

@ -162,6 +162,7 @@
<string name="tap_library_to_show_filters">Tap the Library icon to show filters</string> <string name="tap_library_to_show_filters">Tap the Library icon to show filters</string>
<string name="display_as">Display as</string> <string name="display_as">Display as</string>
<string name="hide_category_hopper">Hide category hopper</string> <string name="hide_category_hopper">Hide category hopper</string>
<string name="hide_hopper_on_scroll">Hide category hopper on scroll</string>
<string name="more_library_settings">More library settings</string> <string name="more_library_settings">More library settings</string>
<!-- Library update service notifications --> <!-- Library update service notifications -->
@ -515,7 +516,7 @@
<string name="check_for_updates">Check for updates</string> <string name="check_for_updates">Check for updates</string>
<string name="auto_check_for_app_versions">Automatically check for new app versions</string> <string name="auto_check_for_app_versions">Automatically check for new app versions</string>
<string name="secure_screen">Secure screen</string> <string name="secure_screen">Secure screen</string>
<string name="hide_bottom_nav">Auto-Hide bottom navigation</string> <string name="hide_bottom_nav">Auto-hide bottom navigation</string>
<string name="hides_on_scroll">Hides when scrolling</string> <string name="hides_on_scroll">Hides when scrolling</string>
<string name="hide_tachi_from_recents">Hide Tachiyomi from the recents screen</string> <string name="hide_tachi_from_recents">Hide Tachiyomi from the recents screen</string>
<string name="security">Security</string> <string name="security">Security</string>