From 500995a9d8ee77ea1e05f8109c75439d415a2e35 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Mon, 20 Oct 2025 11:55:19 +0000
Subject: [PATCH] feat(settings): Add "Every 6 hours" option for periodic
backups
Adds a new "Every 6 hours" frequency option to the periodic backup settings.
To maintain consistency with the existing preference values, which are stored in days, this new option is represented internally as a fractional value of `0.25` days.
The implementation includes:
- Adding the new string resource and updating the preference arrays.
- Changing the preference type in `AppSettings.kt` from `Long` to `Float` to accommodate the fractional value.
- Updating the millisecond conversion logic to correctly calculate the interval from a float value in days.
This approach avoids a complex data migration and is simpler and safer than changing the base unit for all values from days to hours.
---
.../kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt | 6 +++---
app/src/main/res/values/arrays.xml | 1 +
app/src/main/res/values/constants.xml | 1 +
app/src/main/res/values/strings.xml | 1 +
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
index 8846c6f29..43c09daef 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt
@@ -546,11 +546,11 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
val isPeriodicalBackupEnabled: Boolean
get() = prefs.getBoolean(KEY_BACKUP_PERIODICAL_ENABLED, false)
- val periodicalBackupFrequency: Long
- get() = prefs.getString(KEY_BACKUP_PERIODICAL_FREQUENCY, null)?.toLongOrNull() ?: 7L
+ val periodicalBackupFrequency: Float
+ get() = prefs.getString(KEY_BACKUP_PERIODICAL_FREQUENCY, null)?.toFloatOrNull() ?: 7f
val periodicalBackupFrequencyMillis: Long
- get() = TimeUnit.DAYS.toMillis(periodicalBackupFrequency)
+ get() = (TimeUnit.DAYS.toMillis(1) * periodicalBackupFrequency).toLong()
val periodicalBackupMaxCount: Int
get() = if (prefs.getBoolean(KEY_BACKUP_PERIODICAL_TRIM, true)) {
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 87116f7e6..a938c39f7 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -75,6 +75,7 @@
- @string/advanced
+ - @string/frequency_every_6_hours
- @string/frequency_every_day
- @string/frequency_every_2_days
- @string/frequency_once_per_week
diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml
index cb536ba84..4065d5233 100644
--- a/app/src/main/res/values/constants.xml
+++ b/app/src/main/res/values/constants.xml
@@ -56,6 +56,7 @@
- SOCKS
+ - 0.25
- 1
- 2
- 7
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b53414bf5..898db1cfc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -498,6 +498,7 @@
Online variant
Periodic backups
Backup creation frequency
+ Every 6 hours
Every day
Every 2 days
Once per week