From a9a94d76542a58b05b635f5079e5facf3a8a4b5c Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 8 Feb 2020 12:26:46 -0800 Subject: [PATCH] Updating for change of category pref --- .../tachiyomi/ui/library/LibraryPresenter.kt | 4 ++-- .../ui/library/filter/FilterBottomSheet.kt | 15 ++++++++------- app/src/main/res/layout/filter_bottom_sheet.xml | 7 +++++-- 3 files changed, 15 insertions(+), 11 deletions(-) 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 68aa97e292..38fde9f85b 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 @@ -411,7 +411,7 @@ class LibraryPresenter( private fun getLibraryFromDB(): Library { val categories = db.getCategories().executeAsBlocking().toMutableList() val libraryAsList = preferences.libraryAsList() - val showCategories = preferences.showCategories().getOrDefault() + val showCategories = !preferences.hideCategories().getOrDefault() var libraryManga = db.getLibraryMangas().executeAsBlocking() if (!showCategories) libraryManga = libraryManga.distinctBy { it.id } @@ -424,7 +424,7 @@ class LibraryPresenter( categories.add(0, createDefaultCategory()) this.allCategories = categories - this.categories = if (!preferences.showCategories().getOrDefault()) + this.categories = if (preferences.hideCategories().getOrDefault()) arrayListOf(createDefaultCategory()) else categories return Library(this.categories, libraryMap) 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 4361b3a289..bac5f8544f 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 @@ -231,7 +231,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri val sortingMode = preferences.librarySortingMode().getOrDefault() return if (!trueSort && sortingMode == LibrarySort.DRAG_AND_DROP && lastCategory != null && - preferences.showCategories().getOrDefault()) { + !preferences.hideCategories().getOrDefault()) { when (lastCategory?.mangaSort) { 'a', 'b' -> LibrarySort.ALPHA 'c', 'd' -> LibrarySort.LAST_UPDATED @@ -247,7 +247,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri private fun getFilters(): List { val filters = mutableListOf() - val categoriesOn = preferences.showCategories().getOrDefault() + val categoriesOn = !preferences.hideCategories().getOrDefault() if (!categoriesOn) { filters.add(R.string.hiding_categories) } @@ -324,7 +324,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri } } launchUI { - categories.setState(!preferences.showCategories().getOrDefault()) + categories.setState(preferences.hideCategories().getOrDefault()) downloaded.setState(preferences.filterDownloaded()) completed.setState(preferences.filterCompleted()) unread.setState(preferences.filterUnread()) @@ -479,7 +479,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri private fun setCatSortText() { launchUI { - if (preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP && preferences.showCategories().getOrDefault() && lastCategory != null) { + if (preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP && + !preferences.hideCategories().getOrDefault() && lastCategory != null) { val sortId = withContext(Dispatchers.IO) { sorting() } val drawable = withContext(Dispatchers.IO) { tintVector( @@ -536,7 +537,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference:Boolean) { if (updatePreference) { if (view == categories) { - preferences.showCategories().set(index != 0) + preferences.hideCategories().set(index == 0) onGroupClicked(ACTION_REFRESH) } else { when (view) { @@ -559,10 +560,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri } private fun clearFilters() { - val action = if (preferences.showCategories().getOrDefault()) ACTION_REFRESH + val action = if (preferences.hideCategories().getOrDefault()) ACTION_REFRESH else ACTION_FILTER - preferences.showCategories().set(true) + preferences.hideCategories().set(false) preferences.filterDownloaded().set(0) preferences.filterUnread().set(0) preferences.filterCompleted().set(0) diff --git a/app/src/main/res/layout/filter_bottom_sheet.xml b/app/src/main/res/layout/filter_bottom_sheet.xml index 1aaea2b132..935c0c0a67 100644 --- a/app/src/main/res/layout/filter_bottom_sheet.xml +++ b/app/src/main/res/layout/filter_bottom_sheet.xml @@ -19,7 +19,10 @@