forked from recloudstream/cloudstream
[Feature] Skip update (#953)
This commit is contained in:
parent
765b3efa26
commit
a4735c41ba
2 changed files with 19 additions and 8 deletions
|
@ -44,6 +44,7 @@ class InAppUpdater {
|
||||||
@JsonProperty("assets") val assets: List<GithubAsset>,
|
@JsonProperty("assets") val assets: List<GithubAsset>,
|
||||||
@JsonProperty("target_commitish") val target_commitish: String, // branch
|
@JsonProperty("target_commitish") val target_commitish: String, // branch
|
||||||
@JsonProperty("prerelease") val prerelease: Boolean,
|
@JsonProperty("prerelease") val prerelease: Boolean,
|
||||||
|
@JsonProperty("node_id") val node_id: String //Node Id
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GithubObject(
|
data class GithubObject(
|
||||||
|
@ -61,6 +62,7 @@ class InAppUpdater {
|
||||||
@JsonProperty("updateURL") val updateURL: String?,
|
@JsonProperty("updateURL") val updateURL: String?,
|
||||||
@JsonProperty("updateVersion") val updateVersion: String?,
|
@JsonProperty("updateVersion") val updateVersion: String?,
|
||||||
@JsonProperty("changelog") val changelog: String?,
|
@JsonProperty("changelog") val changelog: String?,
|
||||||
|
@JsonProperty("updateNodeId") val updateNodeId: String?
|
||||||
)
|
)
|
||||||
|
|
||||||
private val mapper = JsonMapper.builder().addModule(KotlinModule())
|
private val mapper = JsonMapper.builder().addModule(KotlinModule())
|
||||||
|
@ -76,7 +78,7 @@ class InAppUpdater {
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println(e)
|
println(e)
|
||||||
Update(false, null, null, null)
|
Update(false, null, null, null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +138,14 @@ class InAppUpdater {
|
||||||
shouldUpdate,
|
shouldUpdate,
|
||||||
foundAsset.browser_download_url,
|
foundAsset.browser_download_url,
|
||||||
foundVersion.groupValues[2],
|
foundVersion.groupValues[2],
|
||||||
found.body
|
found.body,
|
||||||
|
found.node_id
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Update(false, null, null, null)
|
Update(false, null, null, null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Update(false, null, null, null)
|
return Update(false, null, null, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Activity.getPreReleaseUpdate(): Update = runBlocking {
|
private fun Activity.getPreReleaseUpdate(): Update = runBlocking {
|
||||||
|
@ -170,10 +173,11 @@ class InAppUpdater {
|
||||||
shouldUpdate,
|
shouldUpdate,
|
||||||
foundAsset.browser_download_url,
|
foundAsset.browser_download_url,
|
||||||
tagResponse.github_object.sha,
|
tagResponse.github_object.sha,
|
||||||
found.body
|
found.body,
|
||||||
|
found.node_id
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Update(false, null, null, null)
|
Update(false, null, null, null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +269,11 @@ class InAppUpdater {
|
||||||
) {
|
) {
|
||||||
val update = getAppUpdate()
|
val update = getAppUpdate()
|
||||||
if (update.shouldUpdate && update.updateURL != null) {
|
if (update.shouldUpdate && update.updateURL != null) {
|
||||||
|
//Check if update should be skipped
|
||||||
|
val updateNodeId = settingsManager.getString(getString(R.string.skip_update_key), "")
|
||||||
|
if (update.updateNodeId.equals(updateNodeId)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
try {
|
try {
|
||||||
val currentVersion = packageName?.let {
|
val currentVersion = packageName?.let {
|
||||||
|
@ -306,8 +315,8 @@ class InAppUpdater {
|
||||||
setNegativeButton(R.string.cancel) { _, _ -> }
|
setNegativeButton(R.string.cancel) { _, _ -> }
|
||||||
|
|
||||||
if (checkAutoUpdate) {
|
if (checkAutoUpdate) {
|
||||||
setNeutralButton(R.string.dont_show_again) { _, _ ->
|
setNeutralButton(R.string.skip_update) { _, _ ->
|
||||||
settingsManager.edit().putBoolean("auto_update", false)
|
settingsManager.edit().putString(getString(R.string.skip_update_key), update.updateNodeId ?: "")
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<string name="search_types_list_key" translatable="false">search_type_list</string>
|
<string name="search_types_list_key" translatable="false">search_type_list</string>
|
||||||
<string name="grid_format_key" translatable="false">grid_format</string>
|
<string name="grid_format_key" translatable="false">grid_format</string>
|
||||||
<string name="auto_update_key" translatable="false">auto_update</string>
|
<string name="auto_update_key" translatable="false">auto_update</string>
|
||||||
|
<string name="skip_update_key" translatable="false">skip_update_key</string>
|
||||||
<string name="prerelease_update_key" translatable="false">prerelease_update</string>
|
<string name="prerelease_update_key" translatable="false">prerelease_update</string>
|
||||||
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
||||||
<string name="fast_forward_button_time_key" translatable="false">fast_forward_button_time</string>
|
<string name="fast_forward_button_time_key" translatable="false">fast_forward_button_time</string>
|
||||||
|
@ -347,6 +348,7 @@
|
||||||
<string name="video_skip_op">Skip OP</string>
|
<string name="video_skip_op">Skip OP</string>
|
||||||
|
|
||||||
<string name="dont_show_again">Don\'t show again</string>
|
<string name="dont_show_again">Don\'t show again</string>
|
||||||
|
<string name="skip_update">Skip this Update</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
<string name="watch_quality_pref">Preferred watch quality</string>
|
||||||
<string name="limit_title">Limit title characters on player</string>
|
<string name="limit_title">Limit title characters on player</string>
|
||||||
|
|
Loading…
Reference in a new issue