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
b397ab2b
Commit
b397ab2b
authored
Feb 02, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support pasting multiple lines
parent
33c087f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
mobile/src/main/res/layout/dialog_acl_rule.xml
mobile/src/main/res/layout/dialog_acl_rule.xml
+1
-2
mobile/src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
...cala/com/github/shadowsocks/acl/CustomRulesFragment.scala
+8
-9
No files found.
mobile/src/main/res/layout/dialog_acl_rule.xml
View file @
b397ab2b
...
...
@@ -10,6 +10,5 @@
<EditText
android:id=
"@+id/content"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textNoSuggestions"
android:lines=
"1"
/>
android:inputType=
"textNoSuggestions|textMultiLine"
/>
</LinearLayout>
mobile/src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
View file @
b397ab2b
...
...
@@ -20,6 +20,7 @@ import com.github.shadowsocks.widget.UndoSnackbarManager
import
com.github.shadowsocks.
{
MainActivity
,
R
,
ToolbarFragment
}
import
scala.collection.mutable
import
scala.io.Source
/**
* @author Mygod
...
...
@@ -144,8 +145,12 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
apply
()
index
}
else
-
1
def
addToProxy
(
input
:
String
)
:
Int
=
try
addSubnet
(
Subnet
.
fromString
(
input
))
catch
{
case
_:
IllegalArgumentException
=>
addHostname
(
input
)
def
addToProxy
(
input
:
String
)
:
Int
=
{
val
acl
=
new
Acl
().
fromSource
(
Source
.
fromString
(
input
),
defaultBypass
=
true
)
var
result
=
-
1
for
(
hostname
<-
acl
.
proxyHostnames
)
result
=
addHostname
(
hostname
)
if
(
acl
.
bypass
)
for
(
subnet
<-
acl
.
subnets
)
result
=
addSubnet
(
subnet
)
result
}
def
addFromTemplate
(
template
:
Int
,
text
:
CharSequence
)
:
Int
=
template
match
{
case
GENERIC
=>
addToProxy
(
text
.
toString
)
...
...
@@ -298,13 +303,7 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
.
create
().
show
()
true
case
R
.
id
.
action_import
=>
try
{
val
items
=
clipboard
.
getPrimaryClip
.
getItemAt
(
0
).
getText
.
toString
.
split
(
"\n"
)
if
(
items
.
nonEmpty
)
{
items
.
foreach
(
adapter
.
addToProxy
)
return
true
}
}
catch
{
try
if
(
adapter
.
addToProxy
(
clipboard
.
getPrimaryClip
.
getItemAt
(
0
).
getText
.
toString
)
!=
-
1
)
return
true
catch
{
case
_:
Exception
=>
}
Snackbar
.
make
(
getActivity
.
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_err
,
Snackbar
.
LENGTH_LONG
).
show
()
...
...
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