Skip to content

Commit

Permalink
Allow disable app auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Dec 28, 2024
1 parent 42bc4e4 commit c72ea1e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions i18n-kmk/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<string name="saved_searches_feeds">Saved Searches &amp; 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>
Expand Down

0 comments on commit c72ea1e

Please sign in to comment.