Option to disable all sources

This commit is contained in:
Koitharu
2022-06-24 14:10:51 +03:00
parent cc6bbc9869
commit 2cf08f74db
4 changed files with 21 additions and 1 deletions

View File

@@ -106,7 +106,13 @@ class SourcesSettingsFragment :
searchView.queryHint = searchMenuItem.title
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = false
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
R.id.action_disable_all -> {
viewModel.disableAll()
true
}
else -> false
}
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
(activity as? AppBarOwner)?.appBar?.setExpanded(false, true)

View File

@@ -7,6 +7,7 @@ import org.koitharu.kotatsu.base.ui.BaseViewModel
import org.koitharu.kotatsu.core.model.getLocaleTitle
import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.parsers.util.mapToSet
import org.koitharu.kotatsu.parsers.util.toTitleCase
import org.koitharu.kotatsu.settings.sources.model.SourceConfigItem
import org.koitharu.kotatsu.utils.ext.map
@@ -58,6 +59,13 @@ class SourcesSettingsViewModel(
buildList()
}
fun disableAll() {
settings.hiddenSources = settings.getMangaSources(includeHidden = true).mapToSet {
it.name
}
buildList()
}
fun expandOrCollapse(headerId: String?) {
if (headerId in expandedGroups) {
expandedGroups.remove(headerId)

View File

@@ -10,4 +10,9 @@
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
<item
android:id="@+id/action_disable_all"
android:title="@string/disable_all"
app:showAsAction="never" />
</menu>

View File

@@ -300,4 +300,5 @@
<string name="disable_battery_optimization_summary">Helps with background updates checks</string>
<string name="crash_text">Something went wrong. Please submit a bug report to the developers to help us fix it.</string>
<string name="send">Send</string>
<string name="disable_all">Disable all</string>
</resources>