mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-28 03:57:50 +02:00
Add ability to ask for category on long press
This commit is contained in:
@ -169,6 +169,8 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val eh_expandFilters = "eh_expand_filters"
|
const val eh_expandFilters = "eh_expand_filters"
|
||||||
|
|
||||||
|
const val eh_askCategoryOnLongPress = "eh_ask_category_on_long_press"
|
||||||
|
|
||||||
const val eh_readerThreads = "eh_reader_threads"
|
const val eh_readerThreads = "eh_reader_threads"
|
||||||
|
|
||||||
const val eh_readerInstantRetry = "eh_reader_instant_retry"
|
const val eh_readerInstantRetry = "eh_reader_instant_retry"
|
||||||
|
@ -251,4 +251,6 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun eh_preserveReadingPosition() = rxPrefs.getBoolean(Keys.eh_preserveReadingPosition, false)
|
fun eh_preserveReadingPosition() = rxPrefs.getBoolean(Keys.eh_preserveReadingPosition, false)
|
||||||
|
|
||||||
fun eh_incogWebview() = rxPrefs.getBoolean(Keys.eh_incogWebview, false)
|
fun eh_incogWebview() = rxPrefs.getBoolean(Keys.eh_incogWebview, false)
|
||||||
|
|
||||||
|
fun eh_askCategoryOnLongPress() = rxPrefs.getBoolean(Keys.eh_askCategoryOnLongPress, false)
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
|||||||
|
|
||||||
// Set onclickListener to toggle favorite when FAB clicked.
|
// Set onclickListener to toggle favorite when FAB clicked.
|
||||||
fab_favorite.clicks().subscribeUntilDestroy { onFabClick() }
|
fab_favorite.clicks().subscribeUntilDestroy { onFabClick() }
|
||||||
|
fab_favorite.longClicks().subscribeUntilDestroy { onFabLongClick() }
|
||||||
|
|
||||||
// Set SwipeRefresh to refresh manga data.
|
// Set SwipeRefresh to refresh manga data.
|
||||||
swipe_refresh.refreshes().subscribeUntilDestroy { fetchMangaFromSource() }
|
swipe_refresh.refreshes().subscribeUntilDestroy { fetchMangaFromSource() }
|
||||||
@ -408,7 +409,26 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
|||||||
defaultCategory != null -> presenter.moveMangaToCategory(manga, defaultCategory)
|
defaultCategory != null -> presenter.moveMangaToCategory(manga, defaultCategory)
|
||||||
categories.size <= 1 -> // default or the one from the user
|
categories.size <= 1 -> // default or the one from the user
|
||||||
presenter.moveMangaToCategory(manga, categories.firstOrNull())
|
presenter.moveMangaToCategory(manga, categories.firstOrNull())
|
||||||
else -> {
|
else -> askCategories(manga, categories)
|
||||||
|
}
|
||||||
|
activity?.toast(activity?.getString(R.string.manga_added_library))
|
||||||
|
} else {
|
||||||
|
activity?.toast(activity?.getString(R.string.manga_removed_library))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onFabLongClick() {
|
||||||
|
if(preferences.eh_askCategoryOnLongPress().getOrDefault()) {
|
||||||
|
val manga = presenter.manga
|
||||||
|
if(!manga.favorite) toggleFavorite()
|
||||||
|
val categories = presenter.getCategories()
|
||||||
|
if(categories.size > 1) {
|
||||||
|
askCategories(manga, categories)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun askCategories(manga: Manga, categories: List<Category>) {
|
||||||
val ids = presenter.getMangaCategoryIds(manga)
|
val ids = presenter.getMangaCategoryIds(manga)
|
||||||
val preselected = ids.mapNotNull { id ->
|
val preselected = ids.mapNotNull { id ->
|
||||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||||
@ -417,12 +437,6 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
|||||||
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
||||||
.showDialog(router)
|
.showDialog(router)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
activity?.toast(activity?.getString(R.string.manga_added_library))
|
|
||||||
} else {
|
|
||||||
activity?.toast(activity?.getString(R.string.manga_removed_library))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateCategoriesForMangas(mangas: List<Manga>, categories: List<Category>) {
|
override fun updateCategoriesForMangas(mangas: List<Manga>, categories: List<Category>) {
|
||||||
val manga = mangas.firstOrNull() ?: return
|
val manga = mangas.firstOrNull() ?: return
|
||||||
|
@ -180,6 +180,12 @@ class SettingsGeneralController : SettingsController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --> EH
|
// --> EH
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.eh_askCategoryOnLongPress
|
||||||
|
title = "Long-press favorite button to specify category"
|
||||||
|
defaultValue = false
|
||||||
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.eh_expandFilters
|
key = Keys.eh_expandFilters
|
||||||
title = "Expand all search filters by default"
|
title = "Expand all search filters by default"
|
||||||
@ -189,7 +195,7 @@ class SettingsGeneralController : SettingsController() {
|
|||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.eh_incogWebview
|
key = Keys.eh_incogWebview
|
||||||
title = "Incognito 'Open in browser'"
|
title = "Incognito 'Open in browser'"
|
||||||
summary = "Prevent pages viewed from the 'Open in browser' menu option from being placed into Chrome's browsing history. Some browser features will be unavailable."
|
summary = "Prevent pages viewed from the 'Open in browser' menu option from being placed into Chrome's browsing history. May be buggy, some browser features will be unavailable."
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ buildscript {
|
|||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
||||||
// Realm (EH)
|
// Realm (EH)
|
||||||
classpath "io.realm:realm-gradle-plugin:5.3.1"
|
classpath "io.realm:realm-gradle-plugin:5.4.1"
|
||||||
|
|
||||||
// Firebase (EH)
|
// Firebase (EH)
|
||||||
classpath 'com.google.firebase:firebase-plugins:1.1.5'
|
classpath 'com.google.firebase:firebase-plugins:1.1.5'
|
||||||
|
Reference in New Issue
Block a user