Просмотр исходного кода

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

arkon 5 лет назад
Родитель
Сommit
8c1ec43500

+ 9 - 3
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)

+ 0 - 2
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"

+ 0 - 2
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)

+ 2 - 2
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<UpdaterJob>(
-                    1, TimeUnit.DAYS,
-                    1, TimeUnit.HOURS)
+                    3, TimeUnit.DAYS,
+                    3, TimeUnit.HOURS)
                     .addTag(TAG)
                     .setConstraints(constraints)
                     .build()

+ 8 - 27
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() }
             }
         }

+ 2 - 2
app/src/main/res/values/strings.xml

@@ -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>