Renaming pref to hide category instead

So all filters are default off
This commit is contained in:
Jay 2020-02-08 12:36:13 -08:00
parent fee697f148
commit 3d3c6b3db5
7 changed files with 17 additions and 13 deletions

View File

@ -186,7 +186,7 @@ class PreferencesHelper(val context: Context) {
fun filterTracked() = rxPrefs.getInteger(Keys.filterTrcaked, 0)
fun showCategories() = rxPrefs.getBoolean("show_categories", true)
fun hideCategories() = rxPrefs.getBoolean("hide_categories", false)
fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0)

View File

@ -71,7 +71,7 @@ class LibraryCategoryAdapter(val view: LibraryCategoryView) :
val preferences:PreferencesHelper by injectLazy()
when (preferences.librarySortingMode().getOrDefault()) {
LibrarySort.DRAG_AND_DROP -> {
if (preferences.showCategories().getOrDefault()) {
if (!preferences.hideCategories().getOrDefault()) {
val title = (iFlexible as LibraryItem).manga.currentTitle()
if (preferences.removeArticles().getOrDefault())
title.removeArticles().substring(0, 1).toUpperCase(Locale.US)

View File

@ -102,7 +102,8 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
// Disable swipe refresh when view is not at the top
val firstPos = (recycler.layoutManager as LinearLayoutManager)
.findFirstCompletelyVisibleItemPosition()
swipe_refresh.isEnabled = firstPos <= 0 && preferences.showCategories().getOrDefault()
swipe_refresh.isEnabled = firstPos <= 0 && !preferences.hideCategories()
.getOrDefault()
}
})
fast_scroller.addOnScrollStateChangeListener {
@ -189,7 +190,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
preferences.filterTracked().getOrDefault() +
preferences.filterUnread().getOrDefault() +
preferences.filterCompleted().getOrDefault() == 0 &&
preferences.showCategories().getOrDefault()
!preferences.hideCategories().getOrDefault()
return sortingMode == LibrarySort.DRAG_AND_DROP && filterOff &&
adapter.mode != SelectableAdapter.Mode.MULTI
}
@ -218,7 +219,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
// Update the category with its manga.
adapter.setItems(mangaForCategory)
swipe_refresh.isEnabled = preferences.showCategories().getOrDefault()
swipe_refresh.isEnabled = !preferences.hideCategories().getOrDefault()
if (adapter.mode == SelectableAdapter.Mode.MULTI) {
controller.selectedMangas.forEach { manga ->

View File

@ -363,7 +363,8 @@ class LibraryController(
* Called when a filter is changed.
*/
private fun onFilterChanged(item: ExtendedNavigationView.Item) {
if (item is ExtendedNavigationView.Item.MultiStateGroup && item.resTitle == R.string.categories) {
if (item is ExtendedNavigationView.Item.MultiStateGroup &&
item.resTitle == R.string.action_hide_categories) {
activity?.invalidateOptionsMenu()
presenter.requestFullUpdate()
return
@ -425,7 +426,7 @@ class LibraryController(
val reorganizeItem = menu.findItem(R.id.action_reorganize)
reorganizeItem.isVisible =
preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP &&
preferences.showCategories().getOrDefault()
!preferences.hideCategories().getOrDefault()
reorderMenuItem = reorganizeItem
enableReorderItems()

View File

@ -92,7 +92,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
private val tracked = Item.TriStateGroup(R.string.tracked, this)
private val categories = Item.TriStateGroup(R.string.categories, this)
private val categories = Item.TriStateGroup(R.string.action_hide_categories, this)
override val items:List<Item> = {
val list = mutableListOf<Item>()
@ -112,7 +112,8 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
override fun initModels() {
try {
categories.state = if (preferences.showCategories().getOrDefault()) STATE_INCLUDE
categories.state =
if (preferences.hideCategories().getOrDefault()) STATE_INCLUDE
else STATE_IGNORE
downloaded.state = preferences.filterDownloaded().getOrDefault()
unread.state = preferences.filterUnread().getOrDefault()
@ -133,7 +134,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
}
item.state = newState
when (item) {
categories -> preferences.showCategories().set(item.state == STATE_INCLUDE)
categories -> preferences.hideCategories().set(item.state == STATE_INCLUDE)
}
}
else if (item is Item.TriStateGroup) {

View File

@ -325,7 +325,7 @@ class LibraryPresenter(
else dbCategories
this.allCategories = categories
this.categories = if (!preferences.showCategories().getOrDefault())
this.categories = if (preferences.hideCategories().getOrDefault())
arrayListOf(createDefaultCategory())
else categories
Library(this.categories, libraryManga)
@ -359,7 +359,7 @@ class LibraryPresenter(
val libraryAsList = preferences.libraryAsList()
return db.getLibraryMangas().asRxObservable()
.map { list ->
if (preferences.showCategories().getOrDefault()) {
if (!preferences.hideCategories().getOrDefault()) {
list.map { LibraryItem(it, libraryAsList) }.groupBy { it.manga.category }
}
else {

View File

@ -37,6 +37,7 @@
<string name="action_sort_total">Total chapters</string>
<string name="action_sort_last_read">Last read</string>
<string name="action_sort_drag_and_drop">Drag &amp; Drop</string>
<string name="action_hide_categories">Hide categories</string>
<string name="action_search">Search</string>
<string name="action_skip_manga">Don\'t migrate</string>
<string name="action_select_all">Select all</string>