Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Feb 14, 2020
1 parent b3ec2c4 commit 56c41f1
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:usesCleartextTraffic="false">
<!-- get aip_key from https://developer.android.com/google/backup/signup.html -->
<meta-data android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIM5F-5ydWKC8n0V5PCzVXtGOerdXdgxzbf7k_5g" />

Expand Down
15 changes: 13 additions & 2 deletions core/src/main/java/com/github/shadowsocks/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,15 +91,24 @@ 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)
for (i in 0 until builtinSubUrls.size) {
var builtinSub= SSRSubManager.createBuiltinSub(builtinSubUrls.get(i),"aes")
if (builtinSub != null) break
}

if(activity != null) {//如果不是APP启动时更新,则停止服务,提醒重新连接
stopService()
activity.runOnUiThread(){showMessage("更新成功,如果必要请重新连接。")}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ object ProfileManager {
}
}

fun deletBuiltinSSRSubProfiles(profiles: List<Profile>) {
if (profiles.isEmpty()) return
profiles.forEach {
delProfile(it.id)
}
}

fun createProfilesFromSub(profiles: List<Profile>, group: String) {
val old = getAllProfilesByGroup(group).toMutableList()
profiles.filter {
Expand All @@ -86,6 +93,15 @@ object ProfileManager {
deletSSRSubProfiles(old)
}

fun createBuiltinProfilesFromSub(profiles: List<Profile>) {
val old = getAllProfilesByGroup(VpnEncrypt.vpnGroupName).toMutableList()
deletBuiltinSSRSubProfiles(old)
profiles.forEach {
createProfile(it)
}

}

fun createProfilesFromJson(jsons: Sequence<InputStream>, replace: Boolean = false) {
val profiles = if (replace) getAllProfiles()?.associateBy { it.formattedAddress } else null
val feature = if (replace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<string name="profile_invalid_input">"未找到有效的 SSR 配置信息。"</string>

<!-- alert category -->
<string name="profile_empty">"请选择配置文件"</string>
<string name="profile_empty">"请选择服务器"</string>
<string name="proxy_empty">"代理服务器地址及密码不能为空"</string>
<string name="connect">"连接"</string>

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<string name="profile_invalid_input">"未找到有效的 SSR 配置信息。"</string>

<!-- alert category -->
<string name="profile_empty">"請選擇配置文件"</string>
<string name="profile_empty">"請選擇伺服器"</string>
<string name="proxy_empty">"代理服務器地址及密碼不能爲空"</string>
<string name="connect">"連接"</string>

Expand Down
2 changes: 1 addition & 1 deletion gitupdate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 56c41f1

Please sign in to comment.