Moving hide all categories preference to the group library option

Removing the preference for it as well since its in the grouped preference

Also adding new wording for group by tracking (tracking status)
This commit is contained in:
Jay 2020-05-17 04:20:09 -04:00
parent d73579d25a
commit 7813048828
9 changed files with 48 additions and 67 deletions

View File

@ -195,8 +195,6 @@ class PreferencesHelper(val context: Context) {
fun filterMangaType() = rxPrefs.getInteger(Keys.filterMangaType, 0) fun filterMangaType() = rxPrefs.getInteger(Keys.filterMangaType, 0)
fun hideCategories() = rxPrefs.getBoolean("hide_categories", false)
fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0) fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0)
fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true) fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true)

View File

@ -117,11 +117,7 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
val db: DatabaseHelper by injectLazy() val db: DatabaseHelper by injectLazy()
if (position == itemCount - 1) return recyclerView.context.getString(R.string.bottom) if (position == itemCount - 1) return recyclerView.context.getString(R.string.bottom)
return when (val item: IFlexible<*>? = getItem(position)) { return when (val item: IFlexible<*>? = getItem(position)) {
is LibraryHeaderItem -> if (!preferences.hideCategories().getOrDefault()) { is LibraryHeaderItem -> item.category.name
item.category.name
} else {
recyclerView.context.getString(R.string.top)
}
is LibraryItem -> { is LibraryItem -> {
val text = if (item.manga.isBlank()) return item.header?.category?.name.orEmpty() val text = if (item.manga.isBlank()) return item.header?.category?.name.orEmpty()
else when (getSort(position)) { else when (getSort(position)) {
@ -198,22 +194,13 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
} }
} }
private fun getSort(position: Int? = null): Int { private fun getSort(position: Int): Int {
val preferences: PreferencesHelper by injectLazy()
return if (position != null) {
val header = (getItem(position) as? LibraryItem)?.header val header = (getItem(position) as? LibraryItem)?.header
if (header != null) { return if (header != null) {
header.category.sortingMode() ?: LibrarySort.DRAG_AND_DROP header.category.sortingMode() ?: LibrarySort.DRAG_AND_DROP
} else { } else {
LibrarySort.DRAG_AND_DROP LibrarySort.DRAG_AND_DROP
} }
} else if (!preferences.showAllCategories().get() && !preferences.hideCategories()
.getOrDefault()
) {
controller.presenter.getCurrentCategory()?.sortingMode() ?: LibrarySort.DRAG_AND_DROP
} else {
preferences.librarySortingMode().getOrDefault()
}
} }
interface LibraryListener { interface LibraryListener {

View File

@ -56,6 +56,7 @@ import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_SOURCE
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_STATUS import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_STATUS
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TAG import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TAG
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TRACK_STATUS import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TRACK_STATUS
import eu.kanade.tachiyomi.ui.library.LibraryGroup.UNGROUPED
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
import eu.kanade.tachiyomi.ui.main.BottomSheetController import eu.kanade.tachiyomi.ui.main.BottomSheetController
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
@ -435,6 +436,9 @@ class LibraryController(
if (presenter.isLoggedIntoTracking) { if (presenter.isLoggedIntoTracking) {
groupItems.add(BY_TRACK_STATUS) groupItems.add(BY_TRACK_STATUS)
} }
if (presenter.allCategories.size > 1) {
groupItems.add(UNGROUPED)
}
val items = groupItems.map { id -> val items = groupItems.map { id ->
MaterialMenuSheet.MenuSheetItem( MaterialMenuSheet.MenuSheetItem(
id, id,
@ -691,9 +695,7 @@ class LibraryController(
} }
category_hopper_frame.visibleIf(!singleCategory && !preferences.hideHopper().get()) category_hopper_frame.visibleIf(!singleCategory && !preferences.hideHopper().get())
filter_bottom_sheet.updateButtons( filter_bottom_sheet.updateButtons(
showHideCategories = presenter.allCategories.size > 1, showExpand = !singleCategory && presenter.showAllCategories, groupType = presenter.groupType
showExpand = !singleCategory && presenter.showAllCategories,
groupType = presenter.groupType
) )
adapter.isLongPressDragEnabled = canDrag() adapter.isLongPressDragEnabled = canDrag()
category_recycler.setCategories(presenter.categories) category_recycler.setCategories(presenter.categories)
@ -946,8 +948,7 @@ class LibraryController(
override fun canDrag(): Boolean { override fun canDrag(): Boolean {
filter_bottom_sheet ?: return false filter_bottom_sheet ?: return false
val filterOff = val filterOff = !filter_bottom_sheet.hasActiveFilters() && presenter.groupType == BY_DEFAULT
!filter_bottom_sheet.hasActiveFilters() && !preferences.hideCategories().getOrDefault()
return filterOff && adapter.mode != SelectableAdapter.Mode.MULTI return filterOff && adapter.mode != SelectableAdapter.Mode.MULTI
} }

View File

@ -9,13 +9,15 @@ object LibraryGroup {
const val BY_SOURCE = 2 const val BY_SOURCE = 2
const val BY_STATUS = 3 const val BY_STATUS = 3
const val BY_TRACK_STATUS = 4 const val BY_TRACK_STATUS = 4
const val UNGROUPED = 5
fun groupTypeStringRes(type: Int): Int { fun groupTypeStringRes(type: Int): Int {
return when (type) { return when (type) {
BY_STATUS -> R.string.status BY_STATUS -> R.string.status
BY_TAG -> R.string.tag BY_TAG -> R.string.tag
BY_TRACK_STATUS -> R.string.tracking
BY_SOURCE -> R.string.sources BY_SOURCE -> R.string.sources
BY_TRACK_STATUS -> R.string.tracking_status
UNGROUPED -> R.string.ungrouped
else -> R.string.categories else -> R.string.categories
} }
} }
@ -26,6 +28,7 @@ object LibraryGroup {
BY_TAG -> R.drawable.ic_style_24dp BY_TAG -> R.drawable.ic_style_24dp
BY_TRACK_STATUS -> R.drawable.ic_sync_black_24dp BY_TRACK_STATUS -> R.drawable.ic_sync_black_24dp
BY_SOURCE -> R.drawable.ic_browse_24dp BY_SOURCE -> R.drawable.ic_browse_24dp
UNGROUPED -> R.drawable.ic_ungroup_24dp
else -> R.drawable.ic_label_outline_white_24dp else -> R.drawable.ic_label_outline_white_24dp
} }
} }

View File

@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_DEFAULT
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_SOURCE import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_SOURCE
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TAG import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TAG
import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TRACK_STATUS import eu.kanade.tachiyomi.ui.library.LibraryGroup.BY_TRACK_STATUS
import eu.kanade.tachiyomi.ui.library.LibraryGroup.UNGROUPED
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_EXCLUDE import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_EXCLUDE
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_IGNORE import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_IGNORE
@ -80,6 +81,9 @@ class LibraryPresenter(
val showAllCategories val showAllCategories
get() = preferences.showAllCategories().get() get() = preferences.showAllCategories().get()
val libraryIsGrouped
get() = groupType != UNGROUPED
/** Save the current list to speed up loading later */ /** Save the current list to speed up loading later */
fun onDestroy() { fun onDestroy() {
lastLibraryItems = libraryItems lastLibraryItems = libraryItems
@ -132,7 +136,7 @@ class LibraryPresenter(
fun restoreLibrary() { fun restoreLibrary() {
val items = libraryItems val items = libraryItems
val show = showAllCategories || preferences.hideCategories().getOrDefault() || val show = showAllCategories || !libraryIsGrouped ||
categories.size == 1 categories.size == 1
if (!show) { if (!show) {
sectionedLibraryItems = items.groupBy { it.manga.category }.toMutableMap() sectionedLibraryItems = items.groupBy { it.manga.category }.toMutableMap()
@ -149,7 +153,7 @@ class LibraryPresenter(
private suspend fun sectionLibrary(items: List<LibraryItem>, freshStart: Boolean = false) { private suspend fun sectionLibrary(items: List<LibraryItem>, freshStart: Boolean = false) {
libraryItems = items libraryItems = items
val showAll = showAllCategories || preferences.hideCategories().getOrDefault() || val showAll = showAllCategories || !libraryIsGrouped ||
categories.size == 1 categories.size == 1
if (!showAll) { if (!showAll) {
sectionedLibraryItems = items.groupBy { it.header.category.id ?: 0 }.toMutableMap() sectionedLibraryItems = items.groupBy { it.header.category.id ?: 0 }.toMutableMap()
@ -429,14 +433,13 @@ class LibraryPresenter(
private fun getLibraryFromDB(): List<LibraryItem> { private fun getLibraryFromDB(): List<LibraryItem> {
removeArticles = preferences.removeArticles().getOrDefault() removeArticles = preferences.removeArticles().getOrDefault()
val categories = db.getCategories().executeAsBlocking().toMutableList() val categories = db.getCategories().executeAsBlocking().toMutableList()
val showCategories = !preferences.hideCategories().getOrDefault()
var libraryManga = db.getLibraryMangas().executeAsBlocking() var libraryManga = db.getLibraryMangas().executeAsBlocking()
val showAll = showAllCategories val showAll = showAllCategories
if (groupType <= BY_DEFAULT || !showCategories) { if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
libraryManga = libraryManga.distinctBy { it.id } libraryManga = libraryManga.distinctBy { it.id }
} }
val items = if (groupType <= BY_DEFAULT || !showCategories) { val items = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
val categoryAll = Category.createAll( val categoryAll = Category.createAll(
context, context,
preferences.librarySortingMode().getOrDefault(), preferences.librarySortingMode().getOrDefault(),
@ -451,7 +454,7 @@ class LibraryPresenter(
} + (-1 to catItemAll) + (0 to LibraryHeaderItem({ getCategory(0) }, 0))).toMap() } + (-1 to catItemAll) + (0 to LibraryHeaderItem({ getCategory(0) }, 0))).toMap()
val items = libraryManga.mapNotNull { val items = libraryManga.mapNotNull {
val headerItem = (if (!showCategories) catItemAll val headerItem = (if (!libraryIsGrouped) catItemAll
else headerItems[it.category]) ?: return@mapNotNull null else headerItems[it.category]) ?: return@mapNotNull null
categorySet.add(it.category) categorySet.add(it.category)
LibraryItem(it, headerItem) LibraryItem(it, headerItem)
@ -462,7 +465,7 @@ class LibraryPresenter(
}.toMutableSet() }.toMutableSet()
if (categorySet.contains(0)) categories.add(0, createDefaultCategory()) if (categorySet.contains(0)) categories.add(0, createDefaultCategory())
if (showCategories) { if (libraryIsGrouped) {
categories.forEach { category -> categories.forEach { category ->
val catId = category.id ?: return@forEach val catId = category.id ?: return@forEach
if (catId > 0 && !categorySet.contains(catId) && (catId !in categoriesHidden || if (catId > 0 && !categorySet.contains(catId) && (catId !in categoriesHidden ||
@ -489,7 +492,7 @@ class LibraryPresenter(
categories.forEach { categories.forEach {
it.isHidden = it.id in categoriesHidden && showAll && categories.size > 1 it.isHidden = it.id in categoriesHidden && showAll && categories.size > 1
} }
this.categories = if (!showCategories) { this.categories = if (!libraryIsGrouped) {
arrayListOf(categoryAll) arrayListOf(categoryAll)
} else { } else {
categories categories
@ -497,8 +500,8 @@ class LibraryPresenter(
items items
} else { } else {
val (items, categories) = getCustomMangaItems(libraryManga) val (items, customCategories) = getCustomMangaItems(libraryManga)
this.categories = categories this.categories = customCategories
items items
} }

View File

@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.util.view.hide
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.isExpanded 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.isVisible
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 kotlinx.android.synthetic.main.filter_bottom_sheet.view.* import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
@ -221,11 +220,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
private fun createTags() { private fun createTags() {
hide_categories.isChecked = preferences.hideCategories().getOrDefault()
hide_categories.setOnCheckedChangeListener { _, isChecked ->
preferences.hideCategories().set(isChecked)
onGroupClicked(ACTION_REFRESH)
}
downloaded = inflate(R.layout.filter_buttons) as FilterTagGroup downloaded = inflate(R.layout.filter_buttons) as FilterTagGroup
downloaded.setup(this, R.string.downloaded, R.string.not_downloaded) downloaded.setup(this, R.string.downloaded, R.string.not_downloaded)
@ -276,7 +270,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
} }
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
hide_categories.visibleIf(showCategoriesCheckBox)
downloaded.setState(preferences.filterDownloaded()) downloaded.setState(preferences.filterDownloaded())
completed.setState(preferences.filterCompleted()) completed.setState(preferences.filterCompleted())
val unreadP = preferences.filterUnread().getOrDefault() val unreadP = preferences.filterUnread().getOrDefault()
@ -434,12 +427,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
} }
fun updateButtons(showHideCategories: Boolean, showExpand: Boolean, groupType: Int) { fun updateButtons(showExpand: Boolean, groupType: Int) {
hide_categories.visibleIf(showHideCategories)
expand_categories.visibleIf(showExpand && groupType == 0) expand_categories.visibleIf(showExpand && groupType == 0)
first_layout.visibleIf(
hide_categories.isVisible() || expand_categories.isVisible() || !second_layout.isVisible()
)
group_by.setIconResource(LibraryGroup.groupTypeDrawableRes(groupType)) group_by.setIconResource(LibraryGroup.groupTypeDrawableRes(groupType))
} }

View File

@ -0,0 +1,8 @@
<!-- drawable/ungroup.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M2,2H6V3H13V2H17V6H16V9H18V8H22V12H21V18H22V22H18V21H12V22H8V18H9V16H6V17H2V13H3V6H2V2M18,12V11H16V13H17V17H13V16H11V18H12V19H18V18H19V12H18M13,6V5H6V6H5V13H6V14H9V12H8V8H12V9H14V6H13M12,12H11V14H13V13H14V11H12V12Z" />
</vector>

View File

@ -70,13 +70,16 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
<com.google.android.material.checkbox.MaterialCheckBox <com.google.android.material.button.MaterialButton
android:id="@+id/hide_categories" android:id="@+id/group_by"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="20dp" android:layout_marginEnd="10dp"
android:text="@string/hide_categories" /> android:text="@string/group_library_by"
android:textColor="?android:attr/textColorPrimary"
app:icon="@drawable/ic_label_outline_white_24dp"
app:iconTint="?android:attr/textColorPrimary" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/expand_categories" android:id="@+id/expand_categories"
@ -89,18 +92,6 @@
app:iconTint="?android:attr/textColorPrimary" /> app:iconTint="?android:attr/textColorPrimary" />
</LinearLayout> </LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/group_by"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/group_library_by"
android:textColor="?android:attr/textColorPrimary"
app:icon="@drawable/ic_label_outline_white_24dp"
app:iconTint="?android:attr/textColorPrimary" />
<LinearLayout <LinearLayout
android:id="@+id/second_layout" android:id="@+id/second_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -84,7 +84,6 @@
<string name="rename_category">Rename category</string> <string name="rename_category">Rename category</string>
<string name="move_to_categories">Move to categories</string> <string name="move_to_categories">Move to categories</string>
<string name="add_to_categories">Choose which categories to add this to. If none are selected, this will be added to the "default" category</string> <string name="add_to_categories">Choose which categories to add this to. If none are selected, this will be added to the "default" category</string>
<string name="hide_categories">Hide categories</string>
<plurals name="category"> <plurals name="category">
<item quantity="one">%d category</item> <item quantity="one">%d category</item>
<item quantity="other">%d categories</item> <item quantity="other">%d categories</item>
@ -124,6 +123,8 @@
<string name="read_progress">Read progress</string> <string name="read_progress">Read progress</string>
<string name="series_type">Series type</string> <string name="series_type">Series type</string>
<string name="group_library_by">Group library by…</string> <string name="group_library_by">Group library by…</string>
<string name="tracking_status">Tracking status</string>
<string name="ungrouped">Ungrouped</string>
<!-- Library Sort --> <!-- Library Sort -->
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>