Allow disable app auto-update
This commit is contained in:
parent
42bc4e4c51
commit
c72ea1e1ac
4 changed files with 13 additions and 2 deletions
|
|
@ -167,6 +167,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
AppUpdatePolicy.DEVICE_ONLY_ON_WIFI to stringResource(MR.strings.connected_to_wifi),
|
||||
AppUpdatePolicy.DEVICE_NETWORK_NOT_METERED to stringResource(MR.strings.network_not_metered),
|
||||
AppUpdatePolicy.DEVICE_CHARGING to stringResource(MR.strings.charging),
|
||||
AppUpdatePolicy.DISABLE_AUTO_DOWNLOAD to stringResource(KMR.strings.auto_update_app_disable_auto_download),
|
||||
),
|
||||
onValueChanged = {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@ import android.os.Build
|
|||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
||||
import tachiyomi.domain.release.service.AppUpdatePolicy
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class AppUpdateChecker(
|
||||
|
|
@ -16,11 +20,15 @@ class AppUpdateChecker(
|
|||
|
||||
private val getApplicationRelease: GetApplicationRelease by injectLazy()
|
||||
|
||||
// KMK -->
|
||||
private val preferences by lazy { Injekt.get<UnsortedPreferences>() }
|
||||
// KMK <--
|
||||
|
||||
suspend fun checkForUpdate(
|
||||
context: Context,
|
||||
forceCheck: Boolean = false,
|
||||
// KMK -->
|
||||
pendingAutoUpdate: Boolean = true,
|
||||
autoUpdate: Boolean = AppUpdatePolicy.DISABLE_AUTO_DOWNLOAD !in preferences.appShouldAutoUpdate().get(),
|
||||
// KMK <--
|
||||
): GetApplicationRelease.Result {
|
||||
return withIOContext {
|
||||
|
|
@ -54,7 +62,7 @@ class AppUpdateChecker(
|
|||
}
|
||||
|
||||
// KMK -->
|
||||
if (pendingAutoUpdate && result is GetApplicationRelease.Result.NewUpdate) {
|
||||
if (autoUpdate && result is GetApplicationRelease.Result.NewUpdate) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
AppUpdateDownloadJob.start(
|
||||
context = context,
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ class AppUpdatePolicy {
|
|||
const val DEVICE_ONLY_ON_WIFI = "wifi"
|
||||
const val DEVICE_NETWORK_NOT_METERED = "network_not_metered"
|
||||
const val DEVICE_CHARGING = "ac"
|
||||
const val DISABLE_AUTO_DOWNLOAD = "disable"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@
|
|||
<string name="saved_searches_feeds">Saved Searches & Feeds</string>
|
||||
<string name="preload_library_cover_color">Preload library's cover color</string>
|
||||
<string name="auto_update_app">Auto-update app</string>
|
||||
<string name="auto_update_app_disable_auto_download">Don't auto download update</string>
|
||||
|
||||
<!-- Onboarding section -->
|
||||
<string name="onboarding_permission_external_storage">Access media files permission</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue