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
14414c64
Commit
14414c64
authored
Nov 18, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy feature settings from the current profile to the new profile.
And fix #432.
parent
95952f0f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
13 deletions
+20
-13
src/main/scala/com/github/shadowsocks/ParserActivity.scala
src/main/scala/com/github/shadowsocks/ParserActivity.scala
+1
-1
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
...scala/com/github/shadowsocks/ProfileManagerActivity.scala
+1
-1
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+17
-9
src/main/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
...n/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
+1
-2
No files found.
src/main/scala/com/github/shadowsocks/ParserActivity.scala
View file @
14414c64
...
...
@@ -61,7 +61,7 @@ class ParserActivity extends Activity {
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setCancelable
(
false
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
ShadowsocksApplication
.
profileManager
.
create
OrUpdate
Profile
(
profile
.
get
)
ShadowsocksApplication
.
profileManager
.
createProfile
(
profile
.
get
)
dialog
.
dismiss
()
})
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
...
...
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
View file @
14414c64
...
...
@@ -153,7 +153,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
scanResult
!=
null
)
Parser
.
parse
(
scanResult
.
getContents
)
match
{
case
Some
(
profile
)
=>
ShadowsocksApplication
.
profileManager
.
create
OrUpdate
Profile
(
profile
)
case
Some
(
profile
)
=>
ShadowsocksApplication
.
profileManager
.
createProfile
(
profile
)
case
_
=>
// ignore
}
}
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
14414c64
...
...
@@ -49,15 +49,27 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
var
profileAddedListener
:
Profile
=>
Any
=
_
def
setProfileAddedListener
(
listener
:
Profile
=>
Any
)
=
this
.
profileAddedListener
=
listener
def
create
OrUpdateProfile
(
profile
:
Profile
)
:
Boolean
=
{
def
create
Profile
(
p
:
Profile
=
null
)
:
Profile
=
{
try
{
val
profile
=
if
(
p
==
null
)
new
Profile
else
p
profile
.
id
=
0
ShadowsocksApplication
.
currentProfile
match
{
case
Some
(
oldProfile
)
=>
// Copy Feature Settings from old profile
profile
.
route
=
oldProfile
.
route
profile
.
ipv6
=
oldProfile
.
ipv6
profile
.
proxyApps
=
oldProfile
.
proxyApps
profile
.
individual
=
oldProfile
.
individual
profile
.
udpdns
=
oldProfile
.
udpdns
case
_
=>
}
dbHelper
.
profileDao
.
createOrUpdate
(
profile
)
if
(
profileAddedListener
!=
null
)
profileAddedListener
(
profile
)
tru
e
profil
e
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
Shadowsocks
.
TAG
,
"addProfile"
,
ex
)
false
p
}
}
...
...
@@ -114,11 +126,7 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
def
load
(
id
:
Int
)
:
Profile
=
{
val
profile
=
getProfile
(
id
)
getOrElse
{
val
p
=
new
Profile
()
createOrUpdateProfile
(
p
)
p
}
val
profile
=
getProfile
(
id
)
getOrElse
createProfile
()
val
edit
=
settings
.
edit
()
edit
.
putBoolean
(
Key
.
isProxyApps
,
profile
.
proxyApps
)
...
...
@@ -175,7 +183,7 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
remotePort
=
443
password
=
"u1rRWTssNv0p"
}
create
OrUpdate
Profile
(
profile
)
createProfile
(
profile
)
profile
}
}
src/main/scala/com/github/shadowsocks/utils/TrafficMonitor.scala
View file @
14414c64
...
...
@@ -20,7 +20,7 @@ object TrafficMonitor {
var
txTotal
:
Long
=
0
var
rxTotal
:
Long
=
0
def
getTraffic
()
:
Traffic
=
{
def
getTraffic
:
Traffic
=
{
new
Traffic
(
Math
.
max
(
TrafficStats
.
getTotalTxBytes
-
TrafficStats
.
getUidTxBytes
(
uid
),
0
),
Math
.
max
(
TrafficStats
.
getTotalRxBytes
-
TrafficStats
.
getUidRxBytes
(
uid
),
0
),
System
.
currentTimeMillis
())
}
...
...
@@ -84,4 +84,3 @@ object TrafficMonitor {
}
}
class
TrafficMonitor
()
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