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
7d3f6096
Commit
7d3f6096
authored
Jan 20, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add plugin to card
Fix #1054.
parent
c7c72c65
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
22 deletions
+39
-22
mobile/src/main/res/layout/layout_profile.xml
mobile/src/main/res/layout/layout_profile.xml
+15
-13
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+1
-0
mobile/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
.../main/scala/com/github/shadowsocks/ProfilesFragment.scala
+20
-7
mobile/src/main/scala/com/github/shadowsocks/plugin/PluginManager.scala
...n/scala/com/github/shadowsocks/plugin/PluginManager.scala
+3
-2
No files found.
mobile/src/main/res/layout/layout_profile.xml
View file @
7d3f6096
...
...
@@ -24,7 +24,7 @@
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:id=
"@+id/container"
>
<TextView
android:id=
"@
+id/title
"
<TextView
android:id=
"@
android:id/text1
"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
...
...
@@ -54,15 +54,16 @@
android:contentDescription=
"@string/edit"
android:focusable=
"true"
/>
</LinearLayout>
<
Linear
Layout
android:layout_width=
"match_parent"
<
Relative
Layout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"4dp"
android:id=
"@+id/details"
>
<TextView
android:id=
"@+id/address"
android:layout_width=
"0dp"
android:layout_marginTop=
"4dp"
>
<TextView
android:id=
"@android:id/text2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_alignParentStart=
"true"
android:layout_toStartOf=
"@+id/traffic"
android:layout_marginEnd=
"8dp"
android:maxLines=
"2"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceSmall"
...
...
@@ -71,10 +72,11 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_alignParentEnd=
"true"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textColor=
"?android:attr/textColorSecondary"
/>
</
Linear
Layout>
</
Relative
Layout>
</LinearLayout>
</com.github.shadowsocks.widget.BoundedCardView>
</FrameLayout>
mobile/src/main/res/values/strings.xml
View file @
7d3f6096
...
...
@@ -142,4 +142,5 @@
<string
name=
"plugin_configure"
>
Configure…
</string>
<string
name=
"plugin_disabled"
>
Disabled
</string>
<string
name=
"plugin_unknown"
>
Unknown plugin %s
</string>
<string
name=
"profile_plugin"
>
Plugin: %s
</string>
</resources>
mobile/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
7d3f6096
...
...
@@ -37,11 +37,12 @@ import android.view._
import
android.widget.
{
LinearLayout
,
PopupMenu
,
TextView
,
Toast
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.plugin.PluginConfiguration
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
NativeExpressAdView
}
import
scala.collection.mutable.
ArrayBuffer
import
scala.collection.mutable.
{
ArrayBuffer
,
ListBuffer
}
import
scala.util.Random
object
ProfilesFragment
{
...
...
@@ -77,8 +78,8 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
var
item
:
Profile
=
_
private
val
t
itle
=
itemView
.
findViewById
(
R
.
id
.
title
).
asInstanceOf
[
TextView
]
private
val
address
=
itemView
.
findViewById
(
R
.
id
.
address
).
asInstanceOf
[
TextView
]
private
val
t
ext1
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
).
asInstanceOf
[
TextView
]
private
val
text2
=
itemView
.
findViewById
(
android
.
R
.
id
.
text2
).
asInstanceOf
[
TextView
]
private
val
traffic
=
itemView
.
findViewById
(
R
.
id
.
traffic
).
asInstanceOf
[
TextView
]
private
val
edit
=
itemView
.
findViewById
(
R
.
id
.
edit
)
edit
.
setOnClickListener
(
_
=>
startConfig
(
item
.
id
))
...
...
@@ -111,10 +112,22 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
tx
+=
txTotal
rx
+=
rxTotal
}
title
.
setText
(
item
.
getName
)
address
.
setText
(
if
(
item
.
nameIsEmpty
)
""
else
item
.
formattedAddress
)
traffic
.
setText
(
if
(
tx
<=
0
&&
rx
<=
0
)
null
else
getString
(
R
.
string
.
stat_profiles
,
text1
.
setText
(
item
.
getName
)
val
t2
=
new
ListBuffer
[
String
]
if
(!
item
.
nameIsEmpty
)
t2
+=
item
.
formattedAddress
new
PluginConfiguration
(
item
.
plugin
).
selected
match
{
case
""
=>
case
id
=>
t2
+=
app
.
getString
(
R
.
string
.
profile_plugin
,
id
)
}
if
(
t2
.
isEmpty
)
text2
.
setVisibility
(
View
.
GONE
)
else
{
text2
.
setVisibility
(
View
.
VISIBLE
)
text2
.
setText
(
t2
.
mkString
(
"\n"
))
}
if
(
tx
<=
0
&&
rx
<=
0
)
traffic
.
setVisibility
(
View
.
GONE
)
else
{
traffic
.
setVisibility
(
View
.
VISIBLE
)
traffic
.
setText
(
getString
(
R
.
string
.
stat_profiles
,
TrafficMonitor
.
formatTraffic
(
tx
),
TrafficMonitor
.
formatTraffic
(
rx
)))
}
if
(
item
.
id
==
app
.
profileId
)
{
itemView
.
setSelected
(
true
)
...
...
mobile/src/main/scala/com/github/shadowsocks/plugin/PluginManager.scala
View file @
7d3f6096
...
...
@@ -11,6 +11,7 @@ import com.github.shadowsocks.utils.{Commandline, IOUtils}
import
eu.chainfire.libsuperuser.Shell
import
scala.collection.JavaConversions._
import
scala.collection.mutable.ListBuffer
/**
* @author Mygod
...
...
@@ -80,14 +81,14 @@ object PluginManager {
IOUtils
.
deleteRecursively
(
pluginDir
)
if
(!
pluginDir
.
mkdirs
())
throw
new
FileNotFoundException
(
"Unable to create plugin directory"
)
val
pluginDirPath
=
pluginDir
.
getAbsolutePath
+
'/'
va
r
list
:
List
[
String
]
=
Nil
va
l
list
=
new
ListBuffer
[
String
]
do
{
val
path
=
cursor
.
getString
(
0
)
val
file
=
new
File
(
pluginDir
,
path
)
assert
(
file
.
getAbsolutePath
.
startsWith
(
pluginDirPath
))
autoClose
(
cr
.
openInputStream
(
builder
.
path
(
path
).
build
()))(
in
=>
autoClose
(
new
FileOutputStream
(
file
))(
out
=>
IOUtils
.
copy
(
in
,
out
)))
list
+
:
=
Commandline
.
toString
(
Array
(
"chmod"
,
cursor
.
getString
(
1
),
file
.
getAbsolutePath
))
list
+=
Commandline
.
toString
(
Array
(
"chmod"
,
cursor
.
getString
(
1
),
file
.
getAbsolutePath
))
if
(
path
==
id
)
initialized
=
true
}
while
(
cursor
.
moveToNext
())
if
(!
initialized
)
entryNotFound
()
...
...
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