Remove option to turn off app update checks, check every 3 days

This commit is contained in:
arkon 2020-04-24 10:39:55 -04:00
parent 1ac1c6dc9e
commit 8c1ec43500
6 changed files with 21 additions and 38 deletions

View file

@ -18,13 +18,19 @@ object Migrations {
fun upgrade(preferences: PreferencesHelper): Boolean {
val context = preferences.context
val oldVersion = preferences.lastVersionCode().get()
// Cancel app updater job for debug builds that don't include it
if (BuildConfig.DEBUG && !BuildConfig.INCLUDE_UPDATER) {
UpdaterJob.cancelTask(context)
}
if (oldVersion < BuildConfig.VERSION_CODE) {
preferences.lastVersionCode().set(BuildConfig.VERSION_CODE)
// Fresh install
if (oldVersion == 0) {
// Set up default app updater task
if (BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
if (BuildConfig.INCLUDE_UPDATER) {
UpdaterJob.setupTask(context)
}
if (preferences.automaticExtUpdates().get()) {
@ -35,7 +41,7 @@ object Migrations {
if (oldVersion < 14) {
// Restore jobs after upgrading to Evernote's job scheduler.
if (BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
if (BuildConfig.INCLUDE_UPDATER) {
UpdaterJob.setupTask(context)
}
LibraryUpdateJob.setupTask(context)
@ -68,7 +74,7 @@ object Migrations {
}
if (oldVersion < 43) {
// Restore jobs after migrating from Evernote's job scheduler to WorkManager.
if (BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
if (BuildConfig.INCLUDE_UPDATER) {
UpdaterJob.setupTask(context)
}
LibraryUpdateJob.setupTask(context)

View file

@ -109,8 +109,6 @@ object PreferenceKeys {
const val librarySortingMode = "library_sorting_mode"
const val automaticUpdates = "automatic_updates"
const val automaticExtUpdates = "automatic_ext_updates"
const val startScreen = "start_screen"

View file

@ -197,8 +197,6 @@ class PreferencesHelper(val context: Context) {
fun librarySortingAscending() = flowPrefs.getBoolean("library_sorting_ascending", true)
fun automaticUpdates() = prefs.getBoolean(Keys.automaticUpdates, true)
fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true)
fun extensionUpdatesCount() = flowPrefs.getInt("ext_updates_count", 0)

View file

@ -63,8 +63,8 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) :
.build()
val request = PeriodicWorkRequestBuilder<UpdaterJob>(
1, TimeUnit.DAYS,
1, TimeUnit.HOURS)
3, TimeUnit.DAYS,
3, TimeUnit.HOURS)
.addTag(TAG)
.setConstraints(constraints)
.build()

View file

@ -9,25 +9,19 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.updater.UpdateChecker
import eu.kanade.tachiyomi.data.updater.UpdateResult
import eu.kanade.tachiyomi.data.updater.UpdaterJob
import eu.kanade.tachiyomi.data.updater.UpdaterService
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.main.ChangelogDialogController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.util.lang.launchNow
import eu.kanade.tachiyomi.util.lang.toDateTimestampString
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.onChange
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
import eu.kanade.tachiyomi.util.system.toast
import java.text.DateFormat
@ -54,34 +48,21 @@ class AboutController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.pref_category_about
switchPreference {
key = Keys.automaticUpdates
titleRes = R.string.pref_enable_automatic_updates
summaryRes = R.string.pref_enable_automatic_updates_summary
defaultValue = true
if (isUpdaterEnabled) {
onChange { newValue ->
val checked = newValue as Boolean
if (checked) {
UpdaterJob.setupTask(context)
} else {
UpdaterJob.cancelTask(context)
}
true
}
} else {
isVisible = false
}
}
preference {
titleRes = R.string.version
summary = if (BuildConfig.DEBUG)
"Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA})"
else
"Stable ${BuildConfig.VERSION_NAME}"
}
preference {
titleRes = R.string.build_time
summary = getFormattedBuildTime()
}
if (isUpdaterEnabled) {
preference {
titleRes = R.string.check_for_updates
if (isUpdaterEnabled) {
onClick { checkVersion() }
}
}

View file

@ -358,8 +358,8 @@
<string name="changelog">Changelog</string>
<string name="notices">Preview build notices</string>
<string name="licenses">Open source licenses</string>
<string name="pref_enable_automatic_updates">Check for updates</string>
<string name="pref_enable_automatic_updates_summary">Automatically check for new app versions</string>
<string name="check_for_updates">Check for updates</string>
<!-- ACRA -->
<string name="pref_enable_acra">Send crash reports</string>
<string name="pref_acra_summary">Helps fix any bugs. No sensitive data will be sent</string>