mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-11 21:56:17 +00:00
Compare commits
2 Commits
feat/impro
...
v1.26.0-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25d82e869c | ||
|
|
9d9a0e81db |
@@ -1,3 +1,10 @@
|
||||
# app [1.26.0-dev.17](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.16...v1.26.0-dev.17) (2026-01-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow updating patches on metered networks ([9d9a0e8](https://github.com/ReVanced/revanced-manager/commit/9d9a0e81dbc9e73e6e3181f6bea9cabb69e49ea8))
|
||||
|
||||
# app [1.26.0-dev.16](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.15...v1.26.0-dev.16) (2025-12-30)
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
version = 1.26.0-dev.16
|
||||
version = 1.26.0-dev.17
|
||||
|
||||
@@ -15,5 +15,5 @@ class NetworkInfo(app: Application) {
|
||||
/**
|
||||
* Returns true if it is safe to download large files.
|
||||
*/
|
||||
fun isSafe() = isConnected() && isUnmetered()
|
||||
fun isSafe(ignoreMetered: Boolean) = isConnected() && (ignoreMetered || isUnmetered())
|
||||
}
|
||||
@@ -34,4 +34,6 @@ class PreferencesManager(
|
||||
val acknowledgedDownloaderPlugins = stringSetPreference("acknowledged_downloader_plugins", emptySet())
|
||||
|
||||
val showDeveloperSettings = booleanPreference("show_developer_settings", context.isDebuggable)
|
||||
|
||||
val allowMeteredNetworks = booleanPreference("allow_metered_networks", false)
|
||||
}
|
||||
|
||||
@@ -286,28 +286,29 @@ class PatchBundleRepository(
|
||||
State(sources.toPersistentMap(), info.toPersistentMap())
|
||||
}
|
||||
|
||||
suspend fun createLocal(createStream: suspend () -> InputStream) = dispatchAction("Add bundle") {
|
||||
with(createEntity("", SourceInfo.Local).load() as LocalPatchBundle) {
|
||||
try {
|
||||
createStream().use { patches -> replace(patches) }
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e(tag, "Got exception while importing bundle", e)
|
||||
withContext(Dispatchers.Main) {
|
||||
app.toast(app.getString(R.string.patches_replace_fail, e.simpleMessage()))
|
||||
suspend fun createLocal(createStream: suspend () -> InputStream) =
|
||||
dispatchAction("Add bundle") {
|
||||
with(createEntity("", SourceInfo.Local).load() as LocalPatchBundle) {
|
||||
try {
|
||||
createStream().use { patches -> replace(patches) }
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e(tag, "Got exception while importing bundle", e)
|
||||
withContext(Dispatchers.Main) {
|
||||
app.toast(app.getString(R.string.patches_replace_fail, e.simpleMessage()))
|
||||
}
|
||||
|
||||
deleteLocalFile()
|
||||
}
|
||||
|
||||
deleteLocalFile()
|
||||
}
|
||||
}
|
||||
|
||||
doReload()
|
||||
}
|
||||
doReload()
|
||||
}
|
||||
|
||||
suspend fun createRemote(url: String, autoUpdate: Boolean) =
|
||||
dispatchAction("Add bundle ($url)") { state ->
|
||||
val src = createEntity("", SourceInfo.from(url), autoUpdate).load() as RemotePatchBundle
|
||||
update(src)
|
||||
update(src, force = true)
|
||||
state.copy(sources = state.sources.put(src.uid, src))
|
||||
}
|
||||
|
||||
@@ -329,32 +330,38 @@ class PatchBundleRepository(
|
||||
state.copy(sources = state.sources.put(uid, newSrc))
|
||||
}
|
||||
|
||||
suspend fun update(vararg sources: RemotePatchBundle, showToast: Boolean = false) {
|
||||
suspend fun update(
|
||||
vararg sources: RemotePatchBundle,
|
||||
showToast: Boolean = false,
|
||||
force: Boolean = false
|
||||
) {
|
||||
val uids = sources.map { it.uid }.toSet()
|
||||
store.dispatch(Update(showToast = showToast) { it.uid in uids })
|
||||
store.dispatch(Update(showToast = showToast, force = force) { it.uid in uids })
|
||||
}
|
||||
|
||||
suspend fun redownloadRemoteBundles() = store.dispatch(Update(force = true))
|
||||
suspend fun redownloadRemoteBundles() = store.dispatch(Update(force = true, redownload = true))
|
||||
|
||||
/**
|
||||
* Updates all bundles that should be automatically updated.
|
||||
*/
|
||||
suspend fun updateCheck() = store.dispatch(Update { it.autoUpdate })
|
||||
suspend fun updateCheck() =
|
||||
store.dispatch(Update(force = prefs.allowMeteredNetworks.get()) { it.autoUpdate })
|
||||
|
||||
private inner class Update(
|
||||
private val force: Boolean = false,
|
||||
private val redownload: Boolean = false,
|
||||
private val showToast: Boolean = false,
|
||||
private val predicate: (bundle: RemotePatchBundle) -> Boolean = { true },
|
||||
) : Action<State> {
|
||||
private suspend fun toast(@StringRes id: Int, vararg args: Any?) =
|
||||
withContext(Dispatchers.Main) { app.toast(app.getString(id, *args)) }
|
||||
|
||||
override fun toString() = if (force) "Redownload remote bundles" else "Update check"
|
||||
override fun toString() = if (redownload) "Redownload remote bundles" else "Update check"
|
||||
|
||||
override suspend fun ActionContext.execute(
|
||||
current: State
|
||||
) = coroutineScope {
|
||||
if (!networkInfo.isSafe()) {
|
||||
if (!networkInfo.isSafe(force)) {
|
||||
Log.d(tag, "Skipping update check because the network is down or metered.")
|
||||
return@coroutineScope current
|
||||
}
|
||||
@@ -367,7 +374,7 @@ class PatchBundleRepository(
|
||||
Log.d(tag, "Updating patch bundle: ${it.name}")
|
||||
|
||||
val newVersion = with(it) {
|
||||
if (force) downloadLatest() else update()
|
||||
if (redownload) downloadLatest() else update()
|
||||
} ?: return@async null
|
||||
|
||||
it to newVersion
|
||||
|
||||
@@ -105,6 +105,14 @@ fun GeneralSettingsScreen(
|
||||
description = R.string.pure_black_theme_description
|
||||
)
|
||||
}
|
||||
|
||||
GroupHeader(stringResource(R.string.networking))
|
||||
BooleanItem(
|
||||
preference = prefs.allowMeteredNetworks,
|
||||
coroutineScope = coroutineScope,
|
||||
headline = R.string.allow_metered_networks,
|
||||
description = R.string.allow_metered_networks_description
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class BundleListViewModel : ViewModel(), KoinComponent {
|
||||
patchBundleRepository.update(
|
||||
*getSelectedSources().filterIsInstance<RemotePatchBundle>().toTypedArray(),
|
||||
showToast = true,
|
||||
force = true
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -65,7 +66,7 @@ class BundleListViewModel : ViewModel(), KoinComponent {
|
||||
fun update(src: PatchBundleSource) = viewModelScope.launch {
|
||||
if (src !is RemotePatchBundle) return@launch
|
||||
|
||||
patchBundleRepository.update(src, showToast = true)
|
||||
patchBundleRepository.update(src, showToast = true, force = true)
|
||||
}
|
||||
|
||||
enum class Event {
|
||||
|
||||
@@ -82,7 +82,7 @@ class UpdateViewModel(
|
||||
uiSafe(app, R.string.failed_to_download_update, "Failed to download update") {
|
||||
val release = releaseInfo!!
|
||||
withContext(Dispatchers.IO) {
|
||||
if (!networkInfo.isSafe() && !ignoreInternetCheck) {
|
||||
if (!networkInfo.isSafe(false) && !ignoreInternetCheck) {
|
||||
showInternetCheckDialog = true
|
||||
} else {
|
||||
state = State.DOWNLOADING
|
||||
|
||||
@@ -217,6 +217,10 @@ You will not be able to update the previously installed apps from this source."<
|
||||
<string name="light">Light</string>
|
||||
<string name="dark">Dark</string>
|
||||
<string name="appearance">Appearance</string>
|
||||
<string name="networking">Networking</string>
|
||||
<string name="allow_metered_networks">Allow metered networks</string>
|
||||
<string name="allow_metered_networks_description">Permits automatic updates on metered networks.
|
||||
The application might still warn about metered networks for manual operations.</string>
|
||||
<string name="downloaded_apps">Downloaded apps</string>
|
||||
<string name="process_runtime">Run Patcher in another process (experimental)</string>
|
||||
<string name="process_runtime_description">This is faster and allows Patcher to use more memory</string>
|
||||
|
||||
Reference in New Issue
Block a user