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 hideCategories() = rxPrefs.getBoolean("hide_categories", false)
fun librarySortingMode() = rxPrefs.getInteger(Keys.librarySortingMode, 0)
fun librarySortingAscending() = rxPrefs.getBoolean("library_sorting_ascending", true)

View File

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

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

View File

@ -9,13 +9,15 @@ object LibraryGroup {
const val BY_SOURCE = 2
const val BY_STATUS = 3
const val BY_TRACK_STATUS = 4
const val UNGROUPED = 5
fun groupTypeStringRes(type: Int): Int {
return when (type) {
BY_STATUS -> R.string.status
BY_TAG -> R.string.tag
BY_TRACK_STATUS -> R.string.tracking
BY_SOURCE -> R.string.sources
BY_TRACK_STATUS -> R.string.tracking_status
UNGROUPED -> R.string.ungrouped
else -> R.string.categories
}
}
@ -26,6 +28,7 @@ object LibraryGroup {
BY_TAG -> R.drawable.ic_style_24dp
BY_TRACK_STATUS -> R.drawable.ic_sync_black_24dp
BY_SOURCE -> R.drawable.ic_browse_24dp
UNGROUPED -> R.drawable.ic_ungroup_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_TAG
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.Companion.STATE_EXCLUDE
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_IGNORE
@ -80,6 +81,9 @@ class LibraryPresenter(
val showAllCategories
get() = preferences.showAllCategories().get()
val libraryIsGrouped
get() = groupType != UNGROUPED
/** Save the current list to speed up loading later */
fun onDestroy() {
lastLibraryItems = libraryItems
@ -132,7 +136,7 @@ class LibraryPresenter(
fun restoreLibrary() {
val items = libraryItems
val show = showAllCategories || preferences.hideCategories().getOrDefault() ||
val show = showAllCategories || !libraryIsGrouped ||
categories.size == 1
if (!show) {
sectionedLibraryItems = items.groupBy { it.manga.category }.toMutableMap()
@ -149,7 +153,7 @@ class LibraryPresenter(
private suspend fun sectionLibrary(items: List<LibraryItem>, freshStart: Boolean = false) {
libraryItems = items
val showAll = showAllCategories || preferences.hideCategories().getOrDefault() ||
val showAll = showAllCategories || !libraryIsGrouped ||
categories.size == 1
if (!showAll) {
sectionedLibraryItems = items.groupBy { it.header.category.id ?: 0 }.toMutableMap()
@ -429,14 +433,13 @@ class LibraryPresenter(
private fun getLibraryFromDB(): List<LibraryItem> {
removeArticles = preferences.removeArticles().getOrDefault()
val categories = db.getCategories().executeAsBlocking().toMutableList()
val showCategories = !preferences.hideCategories().getOrDefault()
var libraryManga = db.getLibraryMangas().executeAsBlocking()
val showAll = showAllCategories
if (groupType <= BY_DEFAULT || !showCategories) {
if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
libraryManga = libraryManga.distinctBy { it.id }
}
val items = if (groupType <= BY_DEFAULT || !showCategories) {
val items = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
val categoryAll = Category.createAll(
context,
preferences.librarySortingMode().getOrDefault(),
@ -451,7 +454,7 @@ class LibraryPresenter(
} + (-1 to catItemAll) + (0 to LibraryHeaderItem({ getCategory(0) }, 0))).toMap()
val items = libraryManga.mapNotNull {
val headerItem = (if (!showCategories) catItemAll
val headerItem = (if (!libraryIsGrouped) catItemAll
else headerItems[it.category]) ?: return@mapNotNull null
categorySet.add(it.category)
LibraryItem(it, headerItem)
@ -462,7 +465,7 @@ class LibraryPresenter(
}.toMutableSet()
if (categorySet.contains(0)) categories.add(0, createDefaultCategory())
if (showCategories) {
if (libraryIsGrouped) {
categories.forEach { category ->
val catId = category.id ?: return@forEach
if (catId > 0 && !categorySet.contains(catId) && (catId !in categoriesHidden ||
@ -489,7 +492,7 @@ class LibraryPresenter(
categories.forEach {
it.isHidden = it.id in categoriesHidden && showAll && categories.size > 1
}
this.categories = if (!showCategories) {
this.categories = if (!libraryIsGrouped) {
arrayListOf(categoryAll)
} else {
categories
@ -497,8 +500,8 @@ class LibraryPresenter(
items
} else {
val (items, categories) = getCustomMangaItems(libraryManga)
this.categories = categories
val (items, customCategories) = getCustomMangaItems(libraryManga)
this.categories = customCategories
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.isExpanded
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.visibleIf
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
@ -221,11 +220,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
}
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.setup(this, R.string.downloaded, R.string.not_downloaded)
@ -276,7 +270,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
}
}
withContext(Dispatchers.Main) {
hide_categories.visibleIf(showCategoriesCheckBox)
downloaded.setState(preferences.filterDownloaded())
completed.setState(preferences.filterCompleted())
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) {
hide_categories.visibleIf(showHideCategories)
fun updateButtons(showExpand: Boolean, groupType: Int) {
expand_categories.visibleIf(showExpand && groupType == 0)
first_layout.visibleIf(
hide_categories.isVisible() || expand_categories.isVisible() || !second_layout.isVisible()
)
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:orientation="horizontal">
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/hide_categories"
<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_marginEnd="20dp"
android:text="@string/hide_categories" />
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" />
<com.google.android.material.button.MaterialButton
android:id="@+id/expand_categories"
@ -89,18 +92,6 @@
app:iconTint="?android:attr/textColorPrimary" />
</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
android:id="@+id/second_layout"
android:layout_width="wrap_content"

View File

@ -84,7 +84,6 @@
<string name="rename_category">Rename category</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="hide_categories">Hide categories</string>
<plurals name="category">
<item quantity="one">%d category</item>
<item quantity="other">%d categories</item>
@ -124,6 +123,8 @@
<string name="read_progress">Read progress</string>
<string name="series_type">Series type</string>
<string name="group_library_by">Group library by…</string>
<string name="tracking_status">Tracking status</string>
<string name="ungrouped">Ungrouped</string>
<!-- Library Sort -->
<string name="sort_by">Sort by</string>