diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 9f89e99c86..1ddd54b2db 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -145,8 +145,6 @@ object PreferenceKeys { const val updateOnRefresh = "update_on_refresh" - const val keepCatSort = "keep_cat_sort" - const val alwaysShowChapterTransition = "always_show_chapter_transition" @Deprecated("Use the preferences of the source") diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 9eb1919b21..32635c484f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -251,8 +251,6 @@ class PreferencesHelper(val context: Context) { fun unreadBadgeType() = rxPrefs.getInteger("unread_badge_type", 2) - fun keepCatSort() = rxPrefs.getInteger(Keys.keepCatSort, 0) - fun hideFiltersAtStart() = rxPrefs.getBoolean("hide_filters_at_start", false) fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt index 73f47279ef..e53602a75e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/CenteredToolbar.kt @@ -15,12 +15,6 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut toolbar_title.text = null } else { toolbar_title.text = context.getString(resId) - post { - if (navigationIcon !is DrawerArrowDrawable) { - toolbar_title.text = context.getString(resId) - requestLayout() - } - } super.setTitle(null) } } @@ -31,12 +25,6 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut toolbar_title.text = "" } else { toolbar_title.text = title - post { - if (navigationIcon !is DrawerArrowDrawable) { - toolbar_title.text = title - requestLayout() - } - } super.setTitle(null) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt index 5d8518c965..ec27dca1a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt @@ -97,7 +97,7 @@ class LibraryCategoryAdapter(val libraryListener: LibraryListener) : val db: DatabaseHelper by injectLazy() return when (val item: IFlexible<*>? = getItem(position)) { is LibraryHeaderItem -> - if (preferences.hideCategories().getOrDefault()) null + if (preferences.hideCategories().getOrDefault() || item.category.id == 0) null else getFirstLetter(item.category.name) + "\u200B".repeat(max(0, item.category.order)) is LibraryItem -> { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 53c34bbf72..a5005f0faf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -23,8 +23,6 @@ import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.checkbox.checkBoxPrompt -import com.afollestad.materialdialogs.checkbox.isCheckPromptChecked import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType @@ -73,7 +71,6 @@ import kotlinx.android.synthetic.main.main_activity.* import kotlinx.coroutines.delay import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.util.Locale import kotlin.math.abs import kotlin.math.roundToInt @@ -158,7 +155,7 @@ class LibraryController( scrollDistance = 0f } } else scrollDistance = 0f - if (order != null && order != activeCategory) { + if (order != null && order != activeCategory && lastItem == null) { preferences.lastUsedCategory().set(order) activeCategory = order setTitle() @@ -663,10 +660,16 @@ class LibraryController( override fun onItemMove(fromPosition: Int, toPosition: Int) { // Because padding a recycler causes it to scroll up we have to scroll it back down... wild - if ((adapter.getItem(fromPosition) is LibraryItem && adapter.getItem(fromPosition) is LibraryItem) || adapter.getItem( + if ((adapter.getItem(fromPosition) is LibraryItem && adapter.getItem(fromPosition) is + LibraryItem) || adapter.getItem( fromPosition ) == null - ) recycler.scrollBy(0, recycler.paddingTop) + ) { + recycler.scrollBy(0, recycler.paddingTop) + view?.post { + setTitle() + } + } activity?.appbar?.y = 0f if (lastItemPosition == toPosition) lastItemPosition = null else if (lastItemPosition == null) lastItemPosition = fromPosition @@ -676,7 +679,7 @@ class LibraryController( if (adapter.isSelected(fromPosition)) toggleSelection(fromPosition) val item = adapter.getItem(fromPosition) as? LibraryItem ?: return false val newHeader = adapter.getSectionHeader(toPosition) as? LibraryHeaderItem - if (toPosition <= 1) return false + if (toPosition < 1) return false return (adapter.getItem(toPosition) !is LibraryHeaderItem) && (newHeader?.category?.id == item.manga.category || !presenter.mangaIsInCategory( item.manga, newHeader?.category?.id )) @@ -687,6 +690,7 @@ class LibraryController( lastItemPosition = null return } + lastItem = null destroyActionModeIfNeeded() // if nothing moved if (lastItemPosition == null) return @@ -705,36 +709,9 @@ class LibraryController( } return } - if (newHeader?.category?.mangaSort == null) { - moveMangaToCategory(item.manga, newHeader?.category, mangaIds, true) - } else { - val keepCatSort = preferences.keepCatSort().getOrDefault() - if (keepCatSort == 0) { - MaterialDialog(activity!!).message(R.string.switch_to_dnd) - .positiveButton(R.string.action_switch) { - moveMangaToCategory( - item.manga, newHeader.category, mangaIds, true - ) - if (it.isCheckPromptChecked()) preferences.keepCatSort().set(2) - }.checkBoxPrompt(R.string.remember_choice) {}.negativeButton( - text = resources?.getString( - R.string.keep_current_sort, - resources!!.getString(newHeader.category.sortRes()).toLowerCase( - Locale.getDefault() - ) - ) - ) { - moveMangaToCategory( - item.manga, newHeader.category, mangaIds, false - ) - if (it.isCheckPromptChecked()) preferences.keepCatSort().set(1) - }.cancelOnTouchOutside(false).show() - } else { - moveMangaToCategory( - item.manga, newHeader.category, mangaIds, keepCatSort == 2 - ) - } - } + if (newHeader?.category != null) moveMangaToCategory( + item.manga, newHeader.category, mangaIds + ) } lastItemPosition = null } @@ -742,12 +719,11 @@ class LibraryController( private fun moveMangaToCategory( manga: LibraryManga, category: Category?, - mangaIds: List, - useDND: Boolean + mangaIds: List ) { if (category?.id == null) return val oldCatId = manga.category - presenter.moveMangaToCategory(manga, category.id, mangaIds, useDND) + presenter.moveMangaToCategory(manga, category.id, mangaIds) snack?.dismiss() snack = view?.snack( resources!!.getString(R.string.moved_to_category, category.name) @@ -755,7 +731,7 @@ class LibraryController( anchorView = bottom_sheet setAction(R.string.action_undo) { manga.category = category.id!! - presenter.moveMangaToCategory(manga, oldCatId, mangaIds, useDND) + presenter.moveMangaToCategory(manga, oldCatId, mangaIds) } } } 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 ed17f7b4e6..13b810950d 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 @@ -853,28 +853,20 @@ class LibraryPresenter( fun moveMangaToCategory( manga: LibraryManga, catId: Int?, - mangaIds: List, - useDND: Boolean + mangaIds: List ) { GlobalScope.launch(Dispatchers.IO) { val categoryId = catId ?: return@launch val category = categories.find { catId == it.id } ?: return@launch - /*val mangaMap = currentMangaMap?.toMutableMap() ?: return@launch - val oldCatId = item.manga.category - val oldCatMap = mangaMap[manga.category]?.toMutableList() ?: return@launch - val newCatMap = mangaMap[catId]?.toMutableList() ?: return@launch - oldCatMap.remove(item) - newCatMap.add(item) - mangaMap[oldCatId] = oldCatMap - mangaMap[catId] = newCatMap - currentMangaMap = mangaMap*/ - val oldCatId = manga.category manga.category = categoryId val mc = ArrayList() - val categories = db.getCategoriesForManga(manga).executeAsBlocking() + val categories = + if (catId == 0) emptyList() + else + db.getCategoriesForManga(manga).executeAsBlocking() .filter { it.id != oldCatId } + listOf(category) for (cat in categories) { @@ -883,8 +875,7 @@ class LibraryPresenter( db.setMangaCategories(mc, listOf(manga)) - if (useDND) { - category.mangaSort = null + if (category.mangaSort == null) { val ids = mangaIds.toMutableList() if (!ids.contains(manga.id!!)) ids.add(manga.id!!) category.mangaOrder = ids diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 7adb0bf956..63fb2ed2bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -29,14 +29,6 @@ class SettingsLibraryController : SettingsController() { titleRes = R.string.pref_category_library preferenceCategory { titleRes = R.string.pref_category_library_display - /* - switchPreference { - key = Keys.libraryAsSingleList - titleRes = R.string.pref_library_single_list - summaryRes = R.string.pref_library_single_list_summary - defaultValue = false - }*/ - switchPreference { key = Keys.removeArticles titleRes = R.string.pref_remove_articles @@ -75,19 +67,6 @@ class SettingsLibraryController : SettingsController() { true } } - intListPreference(activity) { - titleRes = R.string.pref_keep_category_sorting - key = Keys.keepCatSort - - customSummary = context.getString(R.string.pref_keep_category_sorting_summary) - entries = listOf( - context.getString(R.string.always_ask), - context.getString(R.string.option_keep_category_sort), - context.getString(R.string.option_switch_to_dnd) - ) - entryRange = 0..2 - defaultValue = 0 - } } preferenceCategory { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f254b00c04..404c5e8008 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -260,14 +260,6 @@ when updating library (overwrites local covers) Migration - Change category sorting when moving - Should dragging and - dropping an entry into a new category change the category\'s sorting to drag & - drop? - Always ask - Keep category\'s current sorting - Switch to Drag & Drop - All @@ -460,13 +452,11 @@ Category is empty Local Remove from library? - Switch to Drag & Drop mode? What should update? Top category (%1$s) First category Categories to update when manually refreshing All categories in global update - Keep sorting by %1$s Delete category? Manga in this category will moved into the default category.