diff --git a/build.gradle b/build.gradle
index 83908ce378..58a6d973cc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,8 +10,8 @@ buildscript {
compileSdkVersion = 29
buildToolsVersion = '29.0.2'
desugarLibsVersion = '1.0.4'
- versionCode = 414
- versionName = '5.0.3.1R'
+ versionCode = 415
+ versionName = '5.0.3.2R'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}
diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml
index 545f329734..0242c63a73 100644
--- a/core/src/main/AndroidManifest.xml
+++ b/core/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:usesCleartextTraffic="false">
+
diff --git a/core/src/main/java/com/github/shadowsocks/Core.kt b/core/src/main/java/com/github/shadowsocks/Core.kt
index 0b5676b539..5d162a3417 100644
--- a/core/src/main/java/com/github/shadowsocks/Core.kt
+++ b/core/src/main/java/com/github/shadowsocks/Core.kt
@@ -31,6 +31,8 @@ import android.os.Build.VERSION_CODES.O
import android.os.Build.VERSION_CODES.Q
import android.os.UserManager
import android.util.Log
+import android.view.Gravity
+import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.annotation.VisibleForTesting
import androidx.core.content.ContextCompat
@@ -89,8 +91,12 @@ object Core {
DataStore.profileId = result.id
return result
}
-
- fun updateBuiltinServers(){
+ fun showMessage(msg: String) {
+ var toast = Toast.makeText(app, msg, Toast.LENGTH_SHORT)
+ toast.setGravity(Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, 150)
+ toast.show()
+ }
+ fun updateBuiltinServers(activity:Activity? = null){
Log.e("updateBuiltinServers ","...")
GlobalScope.launch {
var builtinSubUrls = app.resources.getStringArray(com.github.shadowsocks.core.R.array.builtinSubUrls)
@@ -98,6 +104,11 @@ object Core {
var builtinSub= SSRSubManager.createBuiltinSub(builtinSubUrls.get(i),"aes")
if (builtinSub != null) break
}
+
+ if(activity != null) {//如果不是APP启动时更新,则停止服务,提醒重新连接
+ stopService()
+ activity.runOnUiThread(){showMessage("更新成功,如果必要请重新连接。")}
+ }
}
}
diff --git a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
index 7b71a560f0..5488dc6b77 100644
--- a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
+++ b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
@@ -71,6 +71,13 @@ object ProfileManager {
}
}
+ fun deletBuiltinSSRSubProfiles(profiles: List) {
+ if (profiles.isEmpty()) return
+ profiles.forEach {
+ delProfile(it.id)
+ }
+ }
+
fun createProfilesFromSub(profiles: List, group: String) {
val old = getAllProfilesByGroup(group).toMutableList()
profiles.filter {
@@ -86,6 +93,15 @@ object ProfileManager {
deletSSRSubProfiles(old)
}
+ fun createBuiltinProfilesFromSub(profiles: List) {
+ val old = getAllProfilesByGroup(VpnEncrypt.vpnGroupName).toMutableList()
+ deletBuiltinSSRSubProfiles(old)
+ profiles.forEach {
+ createProfile(it)
+ }
+
+ }
+
fun createProfilesFromJson(jsons: Sequence, replace: Boolean = false) {
val profiles = if (replace) getAllProfiles()?.associateBy { it.formattedAddress } else null
val feature = if (replace) {
diff --git a/core/src/main/java/com/github/shadowsocks/database/SSRSubManager.kt b/core/src/main/java/com/github/shadowsocks/database/SSRSubManager.kt
index 35e995ab97..33f5b85804 100644
--- a/core/src/main/java/com/github/shadowsocks/database/SSRSubManager.kt
+++ b/core/src/main/java/com/github/shadowsocks/database/SSRSubManager.kt
@@ -95,7 +95,10 @@ object SSRSubManager {
profiles = profiles.shuffled().take(limit)
}
- ProfileManager.createProfilesFromSub(profiles, ssrSub.url_group)
+ if(ssrSub.isBuiltin())
+ ProfileManager.createBuiltinProfilesFromSub(profiles)
+ else
+ ProfileManager.createProfilesFromSub(profiles, ssrSub.url_group)
}
suspend fun create(url: String): SSRSub {
diff --git a/core/src/main/res/values-zh-rCN/strings.xml b/core/src/main/res/values-zh-rCN/strings.xml
index bcc3b322d5..282bee933b 100644
--- a/core/src/main/res/values-zh-rCN/strings.xml
+++ b/core/src/main/res/values-zh-rCN/strings.xml
@@ -83,7 +83,7 @@
"未找到有效的 SSR 配置信息。"
- "请选择配置文件"
+ "请选择服务器"
"代理服务器地址及密码不能为空"
"连接"
diff --git a/core/src/main/res/values-zh-rTW/strings.xml b/core/src/main/res/values-zh-rTW/strings.xml
index 87838b4fa3..ef9efff83d 100644
--- a/core/src/main/res/values-zh-rTW/strings.xml
+++ b/core/src/main/res/values-zh-rTW/strings.xml
@@ -83,7 +83,7 @@
"未找到有效的 SSR 配置信息。"
- "請選擇配置文件"
+ "請選擇伺服器"
"代理服務器地址及密碼不能爲空"
"連接"
diff --git a/gitupdate.bat b/gitupdate.bat
index 0070cebbda..365da9f4b5 100644
--- a/gitupdate.bat
+++ b/gitupdate.bat
@@ -3,6 +3,6 @@ git pull origin master
git add -A
git commit -m "update"
git push origin master
-git tag -a v5.0.3.1 -m "release v5.0.3.1"
+git tag -a v5.0.3.2 -m "release v5.0.3.2"
git push origin --tags
pause
\ No newline at end of file
diff --git a/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt b/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
index abad50e68f..18b706cf1f 100644
--- a/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+++ b/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
@@ -405,7 +405,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override fun onMenuItemClick(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.update_servers -> {
- Core.updateBuiltinServers()
+ Core.updateBuiltinServers(activity)
true
}
R.id.action_scan_qr_code -> {
diff --git a/mobile/src/main/java/com/github/shadowsocks/widget/RecyclerViewNoBugLinearLayoutManager.kt b/mobile/src/main/java/com/github/shadowsocks/widget/RecyclerViewNoBugLinearLayoutManager.kt
index bc8669d8f0..62337c6f00 100644
--- a/mobile/src/main/java/com/github/shadowsocks/widget/RecyclerViewNoBugLinearLayoutManager.kt
+++ b/mobile/src/main/java/com/github/shadowsocks/widget/RecyclerViewNoBugLinearLayoutManager.kt
@@ -15,7 +15,7 @@ class RecyclerViewNoBugLinearLayoutManager : LinearLayoutManager {
try { //try catch一下
super.onLayoutChildren(recycler, state)
} catch (e: IndexOutOfBoundsException) {
- Log.e("speedup.vpn","",e)
+ Log.e("speedup.vpn",this.javaClass.name+":"+e.javaClass.name)
} catch (e: Exception) {
Log.e("speedup.vpn","",e)
}