Option to disable all sources
This commit is contained in:
@@ -106,7 +106,13 @@ class SourcesSettingsFragment :
|
|||||||
searchView.queryHint = searchMenuItem.title
|
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 {
|
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
|
||||||
(activity as? AppBarOwner)?.appBar?.setExpanded(false, true)
|
(activity as? AppBarOwner)?.appBar?.setExpanded(false, true)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.koitharu.kotatsu.base.ui.BaseViewModel
|
|||||||
import org.koitharu.kotatsu.core.model.getLocaleTitle
|
import org.koitharu.kotatsu.core.model.getLocaleTitle
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
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.parsers.util.toTitleCase
|
||||||
import org.koitharu.kotatsu.settings.sources.model.SourceConfigItem
|
import org.koitharu.kotatsu.settings.sources.model.SourceConfigItem
|
||||||
import org.koitharu.kotatsu.utils.ext.map
|
import org.koitharu.kotatsu.utils.ext.map
|
||||||
@@ -58,6 +59,13 @@ class SourcesSettingsViewModel(
|
|||||||
buildList()
|
buildList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun disableAll() {
|
||||||
|
settings.hiddenSources = settings.getMangaSources(includeHidden = true).mapToSet {
|
||||||
|
it.name
|
||||||
|
}
|
||||||
|
buildList()
|
||||||
|
}
|
||||||
|
|
||||||
fun expandOrCollapse(headerId: String?) {
|
fun expandOrCollapse(headerId: String?) {
|
||||||
if (headerId in expandedGroups) {
|
if (headerId in expandedGroups) {
|
||||||
expandedGroups.remove(headerId)
|
expandedGroups.remove(headerId)
|
||||||
|
|||||||
@@ -10,4 +10,9 @@
|
|||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
app:showAsAction="ifRoom|collapseActionView" />
|
app:showAsAction="ifRoom|collapseActionView" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_disable_all"
|
||||||
|
android:title="@string/disable_all"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@@ -300,4 +300,5 @@
|
|||||||
<string name="disable_battery_optimization_summary">Helps with background updates checks</string>
|
<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="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="send">Send</string>
|
||||||
|
<string name="disable_all">Disable all</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user