Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Apr 21, 2020
1 parent b66b4f6 commit e7e793a
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 14 deletions.
9 changes: 3 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@ buildscript {
junitVersion = '4.13'
androidTestVersion = '1.2.0'
androidEspressoVersion = '3.2.0'
versionCode = 5000668
versionName = '5.0.6.3-nightly'
versionCode = 5000678
versionName = '5.0.6.4-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}

repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-beta04'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.9.0'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
Expand Down
11 changes: 10 additions & 1 deletion core/src/main/java/com/github/shadowsocks/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ object Core {
}
val currentProfile: Pair<Profile, Profile?>? get() {
if (DataStore.directBootAware) DirectBoot.getDeviceProfile()?.apply { return this }
return ProfileManager.expand(ProfileManager.getProfile(DataStore.profileId) ?: return null)
var theOne=ProfileManager.getProfile(DataStore.profileId)
if (theOne==null){
theOne=ProfileManager.getRandomVPNServer()
if (theOne!=null)DataStore.profileId=theOne.id
}
return ProfileManager.expand(theOne ?: return null)
}

fun switchProfile(id: Long): Profile {
Expand Down Expand Up @@ -198,6 +203,8 @@ object Core {
}

fun alertMessage(msg: String,activity:Context) {
try {
if(activity==null || (activity as Activity).isFinishing)return
val builder: AlertDialog.Builder? = activity.let {
AlertDialog.Builder(activity)
}
Expand All @@ -206,5 +213,7 @@ object Core {
})
val dialog: AlertDialog? = builder?.create()
dialog?.show()
}
catch (t:Throwable){}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,22 @@ object ProfileManager {
printLog(ex)
emptyList()
}

fun getFirstVPNServer(): Profile? {
try {
return getAllProfilesByGroup(VpnEncrypt.vpnGroupName)?.first()
} catch (ex: Exception) {
Log.e("speedup.vpn",this.javaClass.name+":"+ex.javaClass.name)
return null
}
}

fun getRandomVPNServer(): Profile? {
try {
return getAllProfilesByGroup(VpnEncrypt.vpnGroupName)?.random()
} catch (ex: Exception) {
Log.e("speedup.vpn",this.javaClass.name+":"+ex.javaClass.name)
return null
}
}
}
3 changes: 3 additions & 0 deletions core/src/main/java/com/github/shadowsocks/database/SSRSub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class SSRSub(
@Query("SELECT * FROM `SSRSub` WHERE `id` = :id")
operator fun get(id: Long): SSRSub?

@Query("SELECT * FROM `SSRSub` WHERE `url_group` = :url_group")
fun getByGroup(url_group: String): SSRSub?

@Query("DELETE FROM `SSRSub` WHERE `id` = :id")
fun delete(id: Long): Int

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 @@ -199,7 +199,7 @@
<string name="title_ping_all_server">测试全部配置Tcping</string>
<string name="title_real_ping_all_server">测试全部配置真连接</string>
<string name="title_retest_invalid_servers">再测无效服务器</string>
<string name="title_remove_invalid_servers">删除无效服务器</string>
<string name="title_remove_invalid_servers">删除无效/按组排序</string>
<string name="title_sort_servers_by_speed">按测速结果排序</string>
<string name="toast_test_ended">啊!测试结束啦!</string>
<string name="toast_test_interrupted">"服务器:%s或前一个服务器导致测试中断,请检查之。并请确保安装了simple-obfs插件"</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 @@ -211,7 +211,7 @@
<string name="title_ping_all_server">測試全部配置Tcping</string>
<string name="title_real_ping_all_server">測試全部配置真連接</string>
<string name="title_retest_invalid_servers">再測無效伺服器</string>
<string name="title_remove_invalid_servers">刪除無效伺服器</string>
<string name="title_remove_invalid_servers">刪除無效/按組排序</string>
<string name="title_sort_servers_by_speed">按測速結果排序</string>
<string name="toast_test_ended">啊!測試結束啦!</string>
<string name="toast_test_interrupted">"伺服器:%s或前一個伺服器導致測試中斷,請檢查之。並請確保安裝了simple-obfs插件。"</string>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<string name="title_ping_all_server">Tcping all servers</string>
<string name="title_real_ping_all_server">Real test all servers</string>
<string name="title_retest_invalid_servers">Re-test invalid servers</string>
<string name="title_remove_invalid_servers">Remove invalid servers</string>
<string name="title_remove_invalid_servers">Remove invalid/Sort By Group</string>
<string name="title_sort_servers_by_speed">Sort servers by speed</string>
<string name="toast_test_ended">The test ended successfully</string>
<string name="toast_test_interrupted">Server: %s or the previous one caused the test to be interrupted, please check them. And please make sure that the simple-obfs plugin is installed.</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.6.3 -m "release v5.0.6.3"
git tag -a v5.0.6.4 -m "release v5.0.6.4"
git push origin --tags
pause
2 changes: 1 addition & 1 deletion mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import java.util.regex.Pattern

apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.github.shadowsocks

import SpeedUpVPN.VpnEncrypt
import android.app.Activity
import android.content.Intent
import android.os.Build
Expand All @@ -30,6 +31,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import com.github.shadowsocks.bg.BaseService
import com.github.shadowsocks.database.PrivateDatabase
import com.github.shadowsocks.database.SSRSubManager
import com.github.shadowsocks.preference.DataStore
import com.github.shadowsocks.utils.DirectBoot
import com.github.shadowsocks.utils.Key
Expand Down Expand Up @@ -61,6 +64,13 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
findPreference<SwitchPreference>(Key.is_get_free_servers)!!.setOnPreferenceChangeListener { _, value ->
DataStore.publicStore.putBoolean(Key.is_get_free_servers, value as Boolean)
if(value)Core.importFreeSubs()
if(!value){
val freesub= PrivateDatabase.ssrSubDao.getByGroup(VpnEncrypt.freesubGroupName)
if (freesub!=null) {
SSRSubManager.deletProfiles(freesub)
SSRSubManager.delSSRSub(freesub.id)
}
}
true
}
findPreference<SwitchPreference>(Key.persistAcrossReboot)!!.setOnPreferenceChangeListener { _, value ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
var viewHolder = profilesList.findViewHolderForAdapterPosition(i)
if(viewHolder==null)continue
viewHolder = viewHolder as ProfileViewHolder
if (i<9 /*viewHolder.item.isBuiltin()*/) {
if (true /*viewHolder.item.isBuiltin()*/) {
viewHolder.populateUnifiedNativeAdView(nativeAd!!, nativeAdView!!)
// might be in the middle of a layout after scrolling, need to wait
withContext(Dispatchers.Main) { profilesAdapter.notifyItemChanged(i) }
Expand Down Expand Up @@ -678,6 +678,9 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
//profilesAdapter.remove(k)
}
}
val list=profilesAdapter.profiles.sortedWith(compareBy({ it.url_group }, { it.elapsed }))
profilesAdapter.profiles.clear()
profilesAdapter.profiles.addAll(list)
profilesAdapter.notifyDataSetChanged()
}
catch (e:Exception){
Expand Down
2 changes: 1 addition & 1 deletion tv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import java.util.regex.Pattern

apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

Expand Down

0 comments on commit e7e793a

Please sign in to comment.