Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
091ae734
Commit
091ae734
authored
Dec 31, 2019
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some bugs
parent
09211cd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
21 deletions
+40
-21
core/src/main/java/com/github/shadowsocks/database/Profile.kt
.../src/main/java/com/github/shadowsocks/database/Profile.kt
+19
-10
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+5
-1
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
...m/github/shadowsocks/subscription/SubscriptionFragment.kt
+16
-10
No files found.
core/src/main/java/com/github/shadowsocks/database/Profile.kt
View file @
091ae734
...
@@ -82,7 +82,8 @@ data class Profile(
...
@@ -82,7 +82,8 @@ data class Profile(
private
val
userInfoPattern
=
"^(.+?):(.*)$"
.
toRegex
()
private
val
userInfoPattern
=
"^(.+?):(.*)$"
.
toRegex
()
private
val
legacyPattern
=
"^(.+?):(.*)@(.+?):(\\d+?)$"
.
toRegex
()
private
val
legacyPattern
=
"^(.+?):(.*)@(.+?):(\\d+?)$"
.
toRegex
()
fun
findAllUrls
(
data
:
CharSequence
?,
feature
:
Profile
?
=
null
)
=
pattern
.
findAll
(
data
?:
""
).
map
{
fun
findAllUrls
(
data
:
CharSequence
?,
feature
:
Profile
?
=
null
)
=
pattern
.
findAll
(
data
?:
""
).
map
{
val
uri
=
it
.
value
.
toUri
()
val
uri
=
it
.
value
.
toUri
()
try
{
try
{
if
(
uri
.
userInfo
==
null
)
{
if
(
uri
.
userInfo
==
null
)
{
...
@@ -139,13 +140,15 @@ data class Profile(
...
@@ -139,13 +140,15 @@ data class Profile(
private
val
fallbackMap
=
mutableMapOf
<
Profile
,
Profile
>()
private
val
fallbackMap
=
mutableMapOf
<
Profile
,
Profile
>()
private
val
JsonElement
?.
optString
get
()
=
(
this
as
?
JsonPrimitive
)
?.
asString
private
val
JsonElement
?.
optString
get
()
=
(
this
as
?
JsonPrimitive
)
?.
asString
private
val
JsonElement
?.
optBoolean
get
()
=
// asBoolean attempts to cast everything to boolean
private
val
JsonElement
?.
optBoolean
(
this
as
?
JsonPrimitive
)
?.
run
{
if
(
isBoolean
)
asBoolean
else
null
}
get
()
=
// asBoolean attempts to cast everything to boolean
private
val
JsonElement
?.
optInt
get
()
=
try
{
(
this
as
?
JsonPrimitive
)
?.
run
{
if
(
isBoolean
)
asBoolean
else
null
}
(
this
as
?
JsonPrimitive
)
?.
asInt
private
val
JsonElement
?.
optInt
}
catch
(
_
:
NumberFormatException
)
{
get
()
=
try
{
null
(
this
as
?
JsonPrimitive
)
?.
asInt
}
}
catch
(
_
:
NumberFormatException
)
{
null
}
private
fun
tryParse
(
json
:
JsonObject
,
fallback
:
Boolean
=
false
):
Profile
?
{
private
fun
tryParse
(
json
:
JsonObject
,
fallback
:
Boolean
=
false
):
Profile
?
{
val
host
=
json
[
"server"
].
optString
val
host
=
json
[
"server"
].
optString
...
@@ -176,8 +179,11 @@ data class Profile(
...
@@ -176,8 +179,11 @@ data class Profile(
(
json
[
"proxy_apps"
]
as
?
JsonObject
)
?.
also
{
(
json
[
"proxy_apps"
]
as
?
JsonObject
)
?.
also
{
proxyApps
=
it
[
"enabled"
].
optBoolean
?:
proxyApps
proxyApps
=
it
[
"enabled"
].
optBoolean
?:
proxyApps
bypass
=
it
[
"bypass"
].
optBoolean
?:
bypass
bypass
=
it
[
"bypass"
].
optBoolean
?:
bypass
individual
=
(
json
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
joinToString
(
"\n"
)
?:
individual
=
(
it
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
joinToString
(
"\n"
)
individual
?:
individual
// JSONArray will return strings with "", which should be removed
individual
=
individual
.
replace
(
"\""
,
""
)
}
}
udpdns
=
json
[
"udpdns"
].
optBoolean
?:
udpdns
udpdns
=
json
[
"udpdns"
].
optBoolean
?:
udpdns
(
json
[
"udp_fallback"
]
as
?
JsonObject
)
?.
let
{
tryParse
(
it
,
true
)
}
?.
also
{
fallbackMap
[
this
]
=
it
}
(
json
[
"udp_fallback"
]
as
?
JsonObject
)
?.
let
{
tryParse
(
it
,
true
)
}
?.
also
{
fallbackMap
[
this
]
=
it
}
...
@@ -194,6 +200,7 @@ data class Profile(
...
@@ -194,6 +200,7 @@ data class Profile(
// ignore other types
// ignore other types
}
}
}
}
fun
finalize
(
create
:
(
Profile
)
->
Unit
)
{
fun
finalize
(
create
:
(
Profile
)
->
Unit
)
{
val
profiles
=
ProfileManager
.
getAllProfiles
()
?:
emptyList
()
val
profiles
=
ProfileManager
.
getAllProfiles
()
?:
emptyList
()
for
((
profile
,
fallback
)
in
fallbackMap
)
{
for
((
profile
,
fallback
)
in
fallbackMap
)
{
...
@@ -210,6 +217,7 @@ data class Profile(
...
@@ -210,6 +217,7 @@ data class Profile(
}
}
}
}
}
}
fun
parseJson
(
json
:
JsonElement
,
feature
:
Profile
?
=
null
,
create
:
(
Profile
)
->
Unit
)
{
fun
parseJson
(
json
:
JsonElement
,
feature
:
Profile
?
=
null
,
create
:
(
Profile
)
->
Unit
)
{
JsonParser
(
feature
).
run
{
JsonParser
(
feature
).
run
{
process
(
json
)
process
(
json
)
...
@@ -273,6 +281,7 @@ data class Profile(
...
@@ -273,6 +281,7 @@ data class Profile(
if
(!
name
.
isNullOrEmpty
())
builder
.
fragment
(
name
)
if
(!
name
.
isNullOrEmpty
())
builder
.
fragment
(
name
)
return
builder
.
build
()
return
builder
.
build
()
}
}
override
fun
toString
()
=
toUri
().
toString
()
override
fun
toString
()
=
toUri
().
toString
()
fun
toJson
(
profiles
:
LongSparseArray
<
Profile
>?
=
null
):
JSONObject
=
JSONObject
().
apply
{
fun
toJson
(
profiles
:
LongSparseArray
<
Profile
>?
=
null
):
JSONObject
=
JSONObject
().
apply
{
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
091ae734
...
@@ -591,8 +591,12 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -591,8 +591,12 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesAdapter
.
deepRefreshId
(
profileId
)
profilesAdapter
.
deepRefreshId
(
profileId
)
}
}
override
fun
on
DestroyView
()
{
override
fun
on
Pause
()
{
undoManager
.
flush
()
undoManager
.
flush
()
super
.
onPause
()
}
override
fun
onDestroyView
()
{
nativeAd
?.
destroy
()
nativeAd
?.
destroy
()
super
.
onDestroyView
()
super
.
onDestroyView
()
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
View file @
091ae734
...
@@ -244,19 +244,25 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
...
@@ -244,19 +244,25 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
fetchJob
=
GlobalScope
.
launch
{
fetchJob
=
GlobalScope
.
launch
{
val
subscription
=
Subscription
.
instance
val
subscription
=
Subscription
.
instance
try
{
for
(
url
in
subscription
.
urls
.
asIterable
())
{
for
(
url
in
subscription
.
urls
.
asIterable
())
{
try
{
val
connection
=
url
.
openConnection
()
as
HttpURLConnection
val
connection
=
url
.
openConnection
()
as
HttpURLConnection
ProfileManager
.
createProfilesFromJson
(
sequenceOf
(
connection
.
inputStream
),
replace
=
true
)
}
try
{
}
catch
(
e
:
Exception
)
{
ProfileManager
.
createProfilesFromJson
(
sequenceOf
(
connection
.
inputStream
),
replace
=
true
)
e
.
printStackTrace
()
}
catch
(
e
:
RuntimeException
)
{
activity
.
snackbar
(
e
.
readableMessage
).
show
()
e
.
printStackTrace
()
}
finally
{
activity
.
snackbar
(
e
.
readableMessage
).
show
()
progress
.
post
{
}
progress
.
visibility
=
View
.
INVISIBLE
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
activity
.
snackbar
(
e
.
readableMessage
).
show
()
}
}
}
}
progress
.
post
{
progress
.
visibility
=
View
.
INVISIBLE
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment