Skip to content

Commit

Permalink
添加自动修复云端仓库地址功能
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Mar 16, 2020
1 parent d539bb4 commit 02f2e34
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "net.xzos.upgradeall"
minSdkVersion 21
targetSdkVersion 29
versionCode 37
versionName "0.1.1"
versionCode 38
versionName "0.1.1-rc.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ internal class CloudConfigPlaceholderFragment : Fragment() {
}
}
?: run {
MiscellaneousUtils.resetCloudHubUrl()
if (this@CloudConfigPlaceholderFragment.isVisible)
MiscellaneousUtils.showToast(context, R.string.network_error)
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/net/xzos/upgradeall/utils/MiscellaneousUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.json.JSONException
import java.io.StringReader
import java.util.*


object MiscellaneousUtils {

init {
Expand Down Expand Up @@ -55,6 +56,17 @@ object MiscellaneousUtils {
return cloudConfigGetter
}

fun resetCloudHubUrl() {
val prefKey = "cloud_rules_hub_url"
val defaultCloudRulesHubUrl = context.resources.getString(R.string.default_cloud_rules_hub_url)
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val editor = prefs.edit()
editor.putString(prefKey, defaultCloudRulesHubUrl)
editor.apply()
renewCloudConfigGetter()
showToast(context, R.string.reset_git_url_configuration, duration = Toast.LENGTH_LONG)
}

fun accessByBrowser(url: String?, context: Context?) {
if (url != null && context != null)
try {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<integer name="default_data_expiration_time">10</integer>
<integer name="default_background_sync_data_time">18</integer>

<string name="default_cloud_rules_hub_url">https://github.com/DUpdateSystem/UpgradeAll-rules/</string>
<string name="default_cloud_rules_hub_url">https://github.com/DUpdateSystem/UpgradeAll-rules/tree/master</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<string name="long_click_version_number_to_mark_as_processed">长按云端版本号可标记为“已处理”,即跳过此次更新 \n标记后再次长按已标记的版本号即可取消标记</string>
<string name="marked_version_number_is_behind_latest">标注已处理的版本号已落后于最新版本</string>
<string name="auto_fixed_wrong_configuration">已自动修复错误配置</string>
<string name="reset_git_url_configuration">已尝试复原 Git 地址配置</string>
<string name="o_mark">⭕</string>
<string name="processing">处理中</string>
<string name="add_new_group">添加新分组</string>
Expand Down

0 comments on commit 02f2e34

Please sign in to comment.