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
19205a89
Commit
19205a89
authored
Apr 14, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix IllegalArgumentException again
parent
8bb82543
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
core/src/main/java/com/github/shadowsocks/database/Profile.kt
.../src/main/java/com/github/shadowsocks/database/Profile.kt
+4
-4
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
...in/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
+10
-9
plugin/src/main/java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
...java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
+3
-3
No files found.
core/src/main/java/com/github/shadowsocks/database/Profile.kt
View file @
19205a89
...
...
@@ -244,12 +244,12 @@ data class Profile(
}
fun
toUri
():
Uri
{
val
auth
=
Base64
.
encodeToString
(
"$method:$password"
.
toByteArray
(),
Base64
.
NO_PADDING
or
Base64
.
NO_WRAP
or
Base64
.
URL_SAFE
)
val
wrappedHost
=
if
(
host
.
contains
(
':'
))
"[$host]"
else
host
val
builder
=
Uri
.
Builder
()
.
scheme
(
"ss"
)
.
encodedAuthority
(
"%s@%s:%d"
.
format
(
Locale
.
ENGLISH
,
Base64
.
encodeToString
(
"$method:$password"
.
toByteArray
(),
Base64
.
NO_PADDING
or
Base64
.
NO_WRAP
or
Base64
.
URL_SAFE
),
if
(
host
.
contains
(
':'
))
"[$host]"
else
host
,
remotePort
))
.
encodedAuthority
(
"$auth@$wrappedHost:$remotePort"
)
val
configuration
=
PluginConfiguration
(
plugin
?:
""
)
if
(
configuration
.
selected
.
isNotEmpty
())
builder
.
appendQueryParameter
(
Key
.
plugin
,
configuration
.
selectedOptions
.
toString
(
false
))
...
...
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
View file @
19205a89
...
...
@@ -63,7 +63,6 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
companion
object
{
private
const
val
REQUEST_CODE_ADD
=
1
private
const
val
REQUEST_CODE_EDIT
=
2
private
const
val
TEMPLATE_REGEX_DOMAIN
=
"(^|\\.)%s$"
private
const
val
SELECTED_SUBNETS
=
"com.github.shadowsocks.acl.CustomRulesFragment.SELECTED_SUBNETS"
private
const
val
SELECTED_HOSTNAMES
=
"com.github.shadowsocks.acl.CustomRulesFragment.SELECTED_HOSTNAMES"
...
...
@@ -170,14 +169,16 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
inputLayout
.
error
=
message
}
override
val
ret
get
()
=
AclEditResult
(
editText
.
text
.
toString
().
let
{
text
->
when
(
Template
.
values
()[
templateSelector
.
selectedItemPosition
])
{
Template
.
Generic
->
AclItem
(
text
)
Template
.
Domain
->
AclItem
(
TEMPLATE_REGEX_DOMAIN
.
format
(
Locale
.
ENGLISH
,
IDN
.
toASCII
(
text
,
IDN
.
ALLOW_UNASSIGNED
or
IDN
.
USE_STD3_ASCII_RULES
).
replace
(
"."
,
"\\."
)))
Template
.
Url
->
AclItem
(
text
,
true
)
}
},
arg
)
override
fun
ret
(
which
:
Int
)
=
if
(
which
!=
DialogInterface
.
BUTTON_POSITIVE
)
null
else
{
AclEditResult
(
editText
.
text
.
toString
().
let
{
text
->
when
(
Template
.
values
()[
templateSelector
.
selectedItemPosition
])
{
Template
.
Generic
->
AclItem
(
text
)
Template
.
Domain
->
AclItem
(
IDN
.
toASCII
(
text
,
IDN
.
ALLOW_UNASSIGNED
or
IDN
.
USE_STD3_ASCII_RULES
)
.
replace
(
"."
,
"\\."
).
let
{
"(^|\\.)$it\$"
})
Template
.
Url
->
AclItem
(
text
,
true
)
}
},
arg
)
}
override
fun
onClick
(
dialog
:
DialogInterface
?,
which
:
Int
)
{
if
(
which
!=
DialogInterface
.
BUTTON_NEGATIVE
)
super
.
onClick
(
dialog
,
which
)
...
...
plugin/src/main/java/com/github/shadowsocks/plugin/AlertDialogFragment.kt
View file @
19205a89
...
...
@@ -43,21 +43,21 @@ abstract class AlertDialogFragment<Arg : Parcelable, Ret : Parcelable> :
protected
abstract
fun
AlertDialog
.
Builder
.
prepare
(
listener
:
DialogInterface
.
OnClickListener
)
protected
val
arg
by
lazy
{
arguments
!!
.
getParcelable
<
Arg
>(
KEY_ARG
)
!!
}
protected
open
val
ret
:
Ret
?
get
()
=
null
protected
open
fun
ret
(
which
:
Int
):
Ret
?
=
null
fun
withArg
(
arg
:
Arg
)
=
apply
{
arguments
=
Bundle
().
apply
{
putParcelable
(
KEY_ARG
,
arg
)
}
}
override
fun
onCreateDialog
(
savedInstanceState
:
Bundle
?):
AlertDialog
=
AlertDialog
.
Builder
(
requireContext
()).
also
{
it
.
prepare
(
this
)
}.
create
()
override
fun
onClick
(
dialog
:
DialogInterface
?,
which
:
Int
)
{
targetFragment
?.
onActivityResult
(
targetRequestCode
,
which
,
ret
?.
let
{
targetFragment
?.
onActivityResult
(
targetRequestCode
,
which
,
ret
(
which
)
?.
let
{
Intent
().
replaceExtras
(
Bundle
().
apply
{
putParcelable
(
KEY_RET
,
it
)
})
})
}
override
fun
onDismiss
(
dialog
:
DialogInterface
)
{
super
.
onDismiss
(
dialog
)
targetFragment
?.
onActivityResult
(
targetRequestCode
,
Activity
.
RESULT_CANCELED
,
null
)
onClick
(
dialog
,
Activity
.
RESULT_CANCELED
)
}
fun
show
(
target
:
Fragment
,
requestCode
:
Int
=
0
,
tag
:
String
=
javaClass
.
simpleName
)
{
...
...
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