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
Show 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(
private
val
userInfoPattern
=
"^(.+?):(.*)$"
.
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
()
try
{
if
(
uri
.
userInfo
==
null
)
{
...
...
@@ -139,9 +140,11 @@ data class Profile(
private
val
fallbackMap
=
mutableMapOf
<
Profile
,
Profile
>()
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
get
()
=
// asBoolean attempts to cast everything to boolean
(
this
as
?
JsonPrimitive
)
?.
run
{
if
(
isBoolean
)
asBoolean
else
null
}
private
val
JsonElement
?.
optInt
get
()
=
try
{
private
val
JsonElement
?.
optInt
get
()
=
try
{
(
this
as
?
JsonPrimitive
)
?.
asInt
}
catch
(
_
:
NumberFormatException
)
{
null
...
...
@@ -176,8 +179,11 @@ data class Profile(
(
json
[
"proxy_apps"
]
as
?
JsonObject
)
?.
also
{
proxyApps
=
it
[
"enabled"
].
optBoolean
?:
proxyApps
bypass
=
it
[
"bypass"
].
optBoolean
?:
bypass
individual
=
(
json
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
joinToString
(
"\n"
)
?:
individual
individual
=
(
it
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
joinToString
(
"\n"
)
?:
individual
// JSONArray will return strings with "", which should be removed
individual
=
individual
.
replace
(
"\""
,
""
)
}
udpdns
=
json
[
"udpdns"
].
optBoolean
?:
udpdns
(
json
[
"udp_fallback"
]
as
?
JsonObject
)
?.
let
{
tryParse
(
it
,
true
)
}
?.
also
{
fallbackMap
[
this
]
=
it
}
...
...
@@ -194,6 +200,7 @@ data class Profile(
// ignore other types
}
}
fun
finalize
(
create
:
(
Profile
)
->
Unit
)
{
val
profiles
=
ProfileManager
.
getAllProfiles
()
?:
emptyList
()
for
((
profile
,
fallback
)
in
fallbackMap
)
{
...
...
@@ -210,6 +217,7 @@ data class Profile(
}
}
}
fun
parseJson
(
json
:
JsonElement
,
feature
:
Profile
?
=
null
,
create
:
(
Profile
)
->
Unit
)
{
JsonParser
(
feature
).
run
{
process
(
json
)
...
...
@@ -273,6 +281,7 @@ data class Profile(
if
(!
name
.
isNullOrEmpty
())
builder
.
fragment
(
name
)
return
builder
.
build
()
}
override
fun
toString
()
=
toUri
().
toString
()
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 {
profilesAdapter
.
deepRefreshId
(
profileId
)
}
override
fun
on
DestroyView
()
{
override
fun
on
Pause
()
{
undoManager
.
flush
()
super
.
onPause
()
}
override
fun
onDestroyView
()
{
nativeAd
?.
destroy
()
super
.
onDestroyView
()
}
...
...
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
View file @
091ae734
...
...
@@ -244,22 +244,28 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
fetchJob
=
GlobalScope
.
launch
{
val
subscription
=
Subscription
.
instance
try
{
for
(
url
in
subscription
.
urls
.
asIterable
())
{
try
{
val
connection
=
url
.
openConnection
()
as
HttpURLConnection
try
{
ProfileManager
.
createProfilesFromJson
(
sequenceOf
(
connection
.
inputStream
),
replace
=
true
)
}
catch
(
e
:
RuntimeException
)
{
e
.
printStackTrace
()
activity
.
snackbar
(
e
.
readableMessage
).
show
()
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
IO
Exception
)
{
e
.
printStackTrace
()
activity
.
snackbar
(
e
.
readableMessage
).
show
()
}
finally
{
}
}
progress
.
post
{
progress
.
visibility
=
View
.
INVISIBLE
}
}
}
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
layout_subscriptions
,
container
,
false
)
...
...
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