From 8c1ec4350032d560223cbf418748d21650cd6227 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 24 Apr 2020 10:39:55 -0400 Subject: [PATCH] Remove option to turn off app update checks, check every 3 days --- .../java/eu/kanade/tachiyomi/Migrations.kt | 12 +++++-- .../data/preference/PreferenceKeys.kt | 2 -- .../data/preference/PreferencesHelper.kt | 2 -- .../tachiyomi/data/updater/UpdaterJob.kt | 4 +-- .../tachiyomi/ui/more/AboutController.kt | 35 +++++-------------- app/src/main/res/values/strings.xml | 4 +-- 6 files changed, 21 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index b62d0e8501..e7da97a875 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 84c1784cf6..63e7ebc469 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 3c94ffcaff..652d73885b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt index c98387b291..bbd093a9ec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt @@ -63,8 +63,8 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) : .build() val request = PeriodicWorkRequestBuilder( - 1, TimeUnit.DAYS, - 1, TimeUnit.HOURS) + 3, TimeUnit.DAYS, + 3, TimeUnit.HOURS) .addTag(TAG) .setConstraints(constraints) .build() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 97e4c5f722..90987e7937 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -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() } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c38e4416eb..a27603cd62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -358,8 +358,8 @@ Changelog Preview build notices Open source licenses - Check for updates - Automatically check for new app versions + Check for updates + Send crash reports Helps fix any bugs. No sensitive data will be sent