mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:09:16 +01:00
Group advanced settings
This commit is contained in:
parent
259946cf0a
commit
a2ece82197
@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.onClick
|
||||
import eu.kanade.tachiyomi.util.preference.preference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
@ -51,6 +52,34 @@ class SettingsAdvancedController : SettingsController() {
|
||||
summaryRes = R.string.pref_acra_summary
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
preference {
|
||||
titleRes = R.string.pref_disable_battery_optimization
|
||||
summaryRes = R.string.pref_disable_battery_optimization_summary
|
||||
|
||||
onClick {
|
||||
val packageName: String = context.packageName
|
||||
if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = Uri.parse("package:$packageName")
|
||||
}
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
context.toast(R.string.battery_optimization_setting_activity_not_found)
|
||||
}
|
||||
} else {
|
||||
context.toast(R.string.battery_optimization_disabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.label_data
|
||||
|
||||
preference {
|
||||
key = CLEAR_CACHE_KEY
|
||||
titleRes = R.string.pref_clear_chapter_cache
|
||||
@ -76,6 +105,11 @@ class SettingsAdvancedController : SettingsController() {
|
||||
ctrl.showDialog(router)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.label_library
|
||||
|
||||
preference {
|
||||
titleRes = R.string.pref_refresh_library_covers
|
||||
|
||||
@ -87,28 +121,6 @@ class SettingsAdvancedController : SettingsController() {
|
||||
|
||||
onClick { LibraryUpdateService.start(context, target = Target.TRACKING) }
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
preference {
|
||||
titleRes = R.string.pref_disable_battery_optimization
|
||||
summaryRes = R.string.pref_disable_battery_optimization_summary
|
||||
|
||||
onClick {
|
||||
val packageName: String = context.packageName
|
||||
if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = Uri.parse("package:$packageName")
|
||||
}
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
context.toast(R.string.battery_optimization_setting_activity_not_found)
|
||||
}
|
||||
} else {
|
||||
context.toast(R.string.battery_optimization_disabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,6 +354,7 @@
|
||||
<string name="restoring_backup_canceled">Canceled restore</string>
|
||||
|
||||
<!-- Advanced section -->
|
||||
<string name="label_data">Data</string>
|
||||
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
|
||||
<string name="used_cache">Used: %1$s</string>
|
||||
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
||||
@ -362,7 +363,7 @@
|
||||
<string name="cookies_cleared">Cookies cleared</string>
|
||||
<string name="choices_reset">Dialog choices reset</string>
|
||||
<string name="pref_clear_database">Clear database</string>
|
||||
<string name="pref_clear_database_summary">Delete manga and chapters that are not in your library</string>
|
||||
<string name="pref_clear_database_summary">Delete history for manga that are not in saved your library</string>
|
||||
<string name="clear_database_confirmation">Are you sure? Read chapters and progress of non-library manga will be lost</string>
|
||||
<string name="clear_database_completed">Entries deleted</string>
|
||||
<string name="pref_refresh_library_covers">Refresh library manga covers</string>
|
||||
|
Loading…
Reference in New Issue
Block a user