Don't run automatic backup or library update jobs if battery is low
(cherry picked from commit 74f74eef56ce83b52cd7969f705e370c7977af87) # Conflicts: # app/build.gradle.kts # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt
This commit is contained in:
@@ -41,6 +41,7 @@ import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.core.preference.TriState
|
||||
import tachiyomi.core.preference.getAndSet
|
||||
import tachiyomi.core.preference.getEnum
|
||||
import tachiyomi.core.preference.minusAssign
|
||||
import tachiyomi.core.util.system.logcat
|
||||
@@ -259,15 +260,15 @@ object EXHMigrations {
|
||||
if (readerTheme == 4) {
|
||||
readerPreferences.readerTheme().set(3)
|
||||
}
|
||||
val updateInterval = libraryPreferences.libraryUpdateInterval().get()
|
||||
val updateInterval = libraryPreferences.autoUpdateInterval().get()
|
||||
if (updateInterval == 1 || updateInterval == 2) {
|
||||
libraryPreferences.libraryUpdateInterval().set(3)
|
||||
libraryPreferences.autoUpdateInterval().set(3)
|
||||
LibraryUpdateJob.setupTask(context, 3)
|
||||
}
|
||||
}
|
||||
if (oldVersion under 20) {
|
||||
try {
|
||||
val oldSortingMode = prefs.getInt(libraryPreferences.librarySortingMode().key(), 0 /* ALPHABETICAL */)
|
||||
val oldSortingMode = prefs.getInt(libraryPreferences.sortingMode().key(), 0 /* ALPHABETICAL */)
|
||||
val oldSortingDirection = prefs.getBoolean("library_sorting_ascending", true)
|
||||
|
||||
val newSortingMode = when (oldSortingMode) {
|
||||
@@ -290,12 +291,12 @@ object EXHMigrations {
|
||||
}
|
||||
|
||||
prefs.edit(commit = true) {
|
||||
remove(libraryPreferences.librarySortingMode().key())
|
||||
remove(libraryPreferences.sortingMode().key())
|
||||
remove("library_sorting_ascending")
|
||||
}
|
||||
|
||||
prefs.edit {
|
||||
putString(libraryPreferences.librarySortingMode().key(), newSortingMode)
|
||||
putString(libraryPreferences.sortingMode().key(), newSortingMode)
|
||||
putString("library_sorting_ascending", newSortingDirection)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -312,16 +313,16 @@ object EXHMigrations {
|
||||
}
|
||||
if (oldVersion under 22) {
|
||||
// Handle removed every 3, 4, 6, and 8 hour library updates
|
||||
val updateInterval = libraryPreferences.libraryUpdateInterval().get()
|
||||
val updateInterval = libraryPreferences.autoUpdateInterval().get()
|
||||
if (updateInterval in listOf(3, 4, 6, 8)) {
|
||||
libraryPreferences.libraryUpdateInterval().set(12)
|
||||
libraryPreferences.autoUpdateInterval().set(12)
|
||||
LibraryUpdateJob.setupTask(context, 12)
|
||||
}
|
||||
}
|
||||
if (oldVersion under 23) {
|
||||
val oldUpdateOngoingOnly = prefs.getBoolean("pref_update_only_non_completed_key", true)
|
||||
if (!oldUpdateOngoingOnly) {
|
||||
libraryPreferences.libraryUpdateMangaRestriction() -= MANGA_NON_COMPLETED
|
||||
libraryPreferences.autoUpdateMangaRestrictions() -= MANGA_NON_COMPLETED
|
||||
}
|
||||
}
|
||||
if (oldVersion under 24) {
|
||||
@@ -414,8 +415,7 @@ object EXHMigrations {
|
||||
}
|
||||
if (oldVersion under 38) {
|
||||
// Handle renamed enum values
|
||||
@Suppress("DEPRECATION")
|
||||
val newSortingMode = when (val oldSortingMode = prefs.getString(libraryPreferences.librarySortingMode().key(), "ALPHABETICAL")) {
|
||||
val newSortingMode = when (val oldSortingMode = prefs.getString(libraryPreferences.sortingMode().key(), "ALPHABETICAL")) {
|
||||
"LAST_CHECKED" -> "LAST_MANGA_UPDATE"
|
||||
"UNREAD" -> "UNREAD_COUNT"
|
||||
"DATE_FETCHED" -> "CHAPTER_FETCH_DATE"
|
||||
@@ -423,7 +423,7 @@ object EXHMigrations {
|
||||
else -> oldSortingMode
|
||||
}
|
||||
prefs.edit {
|
||||
putString(libraryPreferences.librarySortingMode().key(), newSortingMode)
|
||||
putString(libraryPreferences.sortingMode().key(), newSortingMode)
|
||||
}
|
||||
runBlocking {
|
||||
handler.await(true) {
|
||||
@@ -442,9 +442,9 @@ object EXHMigrations {
|
||||
}
|
||||
if (oldVersion under 39) {
|
||||
prefs.edit {
|
||||
val sort = prefs.getString(libraryPreferences.librarySortingMode().key(), null) ?: return@edit
|
||||
val sort = prefs.getString(libraryPreferences.sortingMode().key(), null) ?: return@edit
|
||||
val direction = prefs.getString("library_sorting_ascending", "ASCENDING")!!
|
||||
putString(libraryPreferences.librarySortingMode().key(), "$sort,$direction")
|
||||
putString(libraryPreferences.sortingMode().key(), "$sort,$direction")
|
||||
remove("library_sorting_ascending")
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,6 @@ object EXHMigrations {
|
||||
}
|
||||
}
|
||||
if (oldVersion under 41) {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val preferences = listOf(
|
||||
libraryPreferences.filterChapterByRead(),
|
||||
libraryPreferences.filterChapterByDownloaded(),
|
||||
@@ -548,6 +547,12 @@ object EXHMigrations {
|
||||
readerPreferences.longStripSplitWebtoon().set(false)
|
||||
}
|
||||
}
|
||||
if (oldVersion under 56) {
|
||||
val pref = libraryPreferences.autoUpdateDeviceRestrictions()
|
||||
if (pref.isSet() && "battery_not_low" in pref.get()) {
|
||||
pref.getAndSet { it - "battery_not_low" }
|
||||
}
|
||||
}
|
||||
|
||||
// if (oldVersion under 1) { } (1 is current release version)
|
||||
// do stuff here when releasing changed crap
|
||||
|
||||
Reference in New Issue
Block a user