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
37cdf8f9
Commit
37cdf8f9
authored
Nov 11, 2015
by
Max Lv
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #422 from Mygod/master
Some fixes
parents
24b8a5ab
6f6cb461
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
70 deletions
+57
-70
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+4
-2
src/main/res/xml/pref_all.xml
src/main/res/xml/pref_all.xml
+0
-11
src/main/scala/com/github/shadowsocks/ParserActivity.scala
src/main/scala/com/github/shadowsocks/ParserActivity.scala
+10
-19
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
...scala/com/github/shadowsocks/ProfileManagerActivity.scala
+7
-7
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+13
-26
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+6
-4
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+15
-0
src/main/scala/com/github/shadowsocks/preferences/NatSwitchPreference.scala
.../github/shadowsocks/preferences/NatSwitchPreference.scala
+2
-1
No files found.
src/main/AndroidManifest.xml
View file @
37cdf8f9
...
@@ -66,7 +66,8 @@
...
@@ -66,7 +66,8 @@
android:name=
".ProfileManagerActivity"
android:name=
".ProfileManagerActivity"
android:label=
"@string/profiles"
android:label=
"@string/profiles"
android:parentActivityName=
".Shadowsocks"
android:parentActivityName=
".Shadowsocks"
android:exported=
"false"
>
android:exported=
"false"
android:launchMode=
"singleTask"
>
<intent-filter>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.ProfileManagerActivity"
/>
<action
android:name=
"com.github.shadowsocks.ProfileManagerActivity"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
...
@@ -76,7 +77,8 @@
...
@@ -76,7 +77,8 @@
<activity
<activity
android:name=
".AppManager"
android:name=
".AppManager"
android:label=
"@string/proxied_apps"
android:label=
"@string/proxied_apps"
android:parentActivityName=
".Shadowsocks"
/>
android:parentActivityName=
".Shadowsocks"
android:launchMode=
"singleTask"
/>
<service
<service
android:name=
".ShadowsocksRunnerService"
android:name=
".ShadowsocksRunnerService"
...
...
src/main/res/xml/pref_all.xml
View file @
37cdf8f9
...
@@ -14,23 +14,19 @@
...
@@ -14,23 +14,19 @@
android:title=
"@string/proxy_cat"
>
android:title=
"@string/proxy_cat"
>
<com.github.shadowsocks.preferences.SummaryEditTextPreference
<com.github.shadowsocks.preferences.SummaryEditTextPreference
android:defaultValue=
"Default"
android:key=
"profileName"
android:key=
"profileName"
android:title=
"@string/profile_name"
/>
android:title=
"@string/profile_name"
/>
<com.github.shadowsocks.preferences.SummaryEditTextPreference
<com.github.shadowsocks.preferences.SummaryEditTextPreference
android:defaultValue=
"198.199.101.152"
android:key=
"proxy"
android:key=
"proxy"
android:summary=
"@string/proxy_summary"
android:summary=
"@string/proxy_summary"
android:title=
"@string/proxy"
/>
android:title=
"@string/proxy"
/>
<com.github.shadowsocks.preferences.NumberPickerPreference
<com.github.shadowsocks.preferences.NumberPickerPreference
android:defaultValue=
"443"
app:min=
"1"
app:min=
"1"
app:max=
"65535"
app:max=
"65535"
android:key=
"remotePort"
android:key=
"remotePort"
app:summary=
"@string/remote_port_summary"
app:summary=
"@string/remote_port_summary"
android:title=
"@string/remote_port"
/>
android:title=
"@string/remote_port"
/>
<com.github.shadowsocks.preferences.NumberPickerPreference
<com.github.shadowsocks.preferences.NumberPickerPreference
android:defaultValue=
"1080"
app:min=
"1025"
app:min=
"1025"
app:max=
"65535"
app:max=
"65535"
android:key=
"port"
android:key=
"port"
...
@@ -38,12 +34,10 @@
...
@@ -38,12 +34,10 @@
android:title=
"@string/port"
/>
android:title=
"@string/port"
/>
<com.github.shadowsocks.preferences.PasswordEditTextPreference
<com.github.shadowsocks.preferences.PasswordEditTextPreference
android:inputType=
"textPassword"
android:inputType=
"textPassword"
android:defaultValue=
"u1rRWTssNv0p"
android:key=
"sitekey"
android:key=
"sitekey"
android:summary=
"@string/sitekey_summary"
android:summary=
"@string/sitekey_summary"
android:title=
"@string/sitekey"
/>
android:title=
"@string/sitekey"
/>
<com.github.shadowsocks.preferences.DropDownPreference
<com.github.shadowsocks.preferences.DropDownPreference
android:defaultValue=
"rc4"
android:key=
"encMethod"
android:key=
"encMethod"
app:entries=
"@array/enc_method_entry"
app:entries=
"@array/enc_method_entry"
app:entryValues=
"@array/enc_method_value"
app:entryValues=
"@array/enc_method_value"
...
@@ -51,7 +45,6 @@
...
@@ -51,7 +45,6 @@
android:title=
"@string/enc_method"
/>
android:title=
"@string/enc_method"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isAuth"
android:key=
"isAuth"
android:defaultValue=
"false"
android:summary=
"@string/onetime_auth_summary"
android:summary=
"@string/onetime_auth_summary"
android:title=
"@string/onetime_auth"
/>
android:title=
"@string/onetime_auth"
/>
...
@@ -61,7 +54,6 @@
...
@@ -61,7 +54,6 @@
android:title=
"@string/feature_cat"
>
android:title=
"@string/feature_cat"
>
<com.github.shadowsocks.preferences.DropDownPreference
<com.github.shadowsocks.preferences.DropDownPreference
android:defaultValue=
"all"
android:key=
"route"
android:key=
"route"
app:entries=
"@array/route_entry"
app:entries=
"@array/route_entry"
app:entryValues=
"@array/route_value"
app:entryValues=
"@array/route_value"
...
@@ -69,17 +61,14 @@
...
@@ -69,17 +61,14 @@
android:title=
"@string/route_list"
/>
android:title=
"@string/route_list"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isIpv6"
android:key=
"isIpv6"
android:defaultValue=
"false"
android:summary=
"@string/ipv6_summary"
android:summary=
"@string/ipv6_summary"
android:title=
"@string/ipv6"
/>
android:title=
"@string/ipv6"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isProxyApps"
android:key=
"isProxyApps"
android:defaultValue=
"false"
android:summary=
"@string/proxied_apps_summary"
android:summary=
"@string/proxied_apps_summary"
android:title=
"@string/proxied_apps"
/>
android:title=
"@string/proxied_apps"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isUdpDns"
android:key=
"isUdpDns"
android:defaultValue=
"false"
android:summary=
"@string/udp_dns_summary"
android:summary=
"@string/udp_dns_summary"
android:title=
"@string/udp_dns"
/>
android:title=
"@string/udp_dns"
/>
...
...
src/main/scala/com/github/shadowsocks/ParserActivity.scala
View file @
37cdf8f9
...
@@ -44,33 +44,33 @@ import android.content.DialogInterface
...
@@ -44,33 +44,33 @@ import android.content.DialogInterface
import
android.graphics.Color
import
android.graphics.Color
import
android.graphics.drawable.ColorDrawable
import
android.graphics.drawable.ColorDrawable
import
android.os.Bundle
import
android.os.Bundle
import
android.preference.PreferenceManager
import
android.view.WindowManager
import
android.view.WindowManager
import
com.github.shadowsocks.database.
{
Profile
,
ProfileManager
}
import
com.github.shadowsocks.utils.Parser
import
com.github.shadowsocks.utils.Parser
class
ParserActivity
extends
Activity
{
class
ParserActivity
extends
Activity
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
showAsPopup
(
this
)
val
data
=
getIntent
.
getData
.
toString
val
data
=
getIntent
.
getData
.
toString
new
AlertDialog
.
Builder
(
this
)
val
profile
=
Parser
.
parse
(
data
)
if
(
profile
.
isEmpty
)
{
// ignore
finish
()
return
}
showAsPopup
(
this
)
val
dialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setCancelable
(
false
)
.
setCancelable
(
false
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
Parser
.
parse
(
data
)
match
{
ShadowsocksApplication
.
profileManager
.
createOrUpdateProfile
(
profile
.
get
)
case
Some
(
profile
)
=>
addProfile
(
profile
)
case
_
=>
// ignore
}
dialog
.
dismiss
()
dialog
.
dismiss
()
})
:
DialogInterface.OnClickListener
)
})
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
.
setNegativeButton
(
android
.
R
.
string
.
no
,
((
dialog
:
DialogInterface
,
id
:
Int
)
=>
{
dialog
.
dismiss
()
dialog
.
dismiss
()
finish
()
})
:
DialogInterface.OnClickListener
)
})
:
DialogInterface.OnClickListener
)
.
setMessage
(
data
)
.
setMessage
(
data
)
.
create
()
.
create
()
.
show
()
dialog
.
setOnDismissListener
((
dialog
:
DialogInterface
)
=>
finish
())
// builder method was added in API 17
dialog
.
show
()
}
}
def
showAsPopup
(
activity
:
Activity
)
{
def
showAsPopup
(
activity
:
Activity
)
{
...
@@ -82,13 +82,4 @@ class ParserActivity extends Activity {
...
@@ -82,13 +82,4 @@ class ParserActivity extends Activity {
activity
.
getWindow
.
setAttributes
(
params
.
asInstanceOf
[
android.view.WindowManager.LayoutParams
])
activity
.
getWindow
.
setAttributes
(
params
.
asInstanceOf
[
android.view.WindowManager.LayoutParams
])
activity
.
getWindow
.
setBackgroundDrawable
(
new
ColorDrawable
(
Color
.
TRANSPARENT
))
activity
.
getWindow
.
setBackgroundDrawable
(
new
ColorDrawable
(
Color
.
TRANSPARENT
))
}
}
def
addProfile
(
profile
:
Profile
)
{
val
profileManager
=
new
ProfileManager
(
PreferenceManager
.
getDefaultSharedPreferences
(
getBaseContext
),
ShadowsocksApplication
.
dbHelper
)
profileManager
.
createOrUpdateProfile
(
profile
)
profileManager
.
reload
(
profile
.
id
)
}
}
}
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
View file @
37cdf8f9
...
@@ -61,7 +61,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -61,7 +61,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
}
}
def
onClick
(
v
:
View
)
=
{
def
onClick
(
v
:
View
)
=
{
ShadowsocksApplication
.
profileId
(
item
.
id
)
ShadowsocksApplication
.
switchProfile
(
item
.
id
)
finish
finish
}
}
}
}
...
@@ -82,11 +82,9 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -82,11 +82,9 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
removedSnackbar
.
dismiss
removedSnackbar
.
dismiss
commitRemoves
commitRemoves
val
pos
=
getItemCount
val
pos
=
getItemCount
if
(
ShadowsocksApplication
.
profileManager
.
createOrUpdateProfile
(
item
))
{
profiles
+=
item
profiles
+=
item
notifyItemInserted
(
pos
)
notifyItemInserted
(
pos
)
}
}
}
def
remove
(
pos
:
Int
)
{
def
remove
(
pos
:
Int
)
{
recycleBin
.
append
((
pos
,
profiles
(
pos
)))
recycleBin
.
append
((
pos
,
profiles
(
pos
)))
...
@@ -126,6 +124,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -126,6 +124,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
toolbar
.
inflateMenu
(
R
.
menu
.
add_profile_methods
)
toolbar
.
inflateMenu
(
R
.
menu
.
add_profile_methods
)
toolbar
.
setOnMenuItemClickListener
(
this
)
toolbar
.
setOnMenuItemClickListener
(
this
)
ShadowsocksApplication
.
profileManager
.
setProfileAddedListener
(
profilesAdapter
.
add
)
val
profilesList
=
findViewById
(
R
.
id
.
profilesList
).
asInstanceOf
[
RecyclerView
]
val
profilesList
=
findViewById
(
R
.
id
.
profilesList
).
asInstanceOf
[
RecyclerView
]
profilesList
.
setLayoutManager
(
new
LinearLayoutManager
(
this
))
profilesList
.
setLayoutManager
(
new
LinearLayoutManager
(
this
))
profilesList
.
setItemAnimator
(
new
DefaultItemAnimator
)
profilesList
.
setItemAnimator
(
new
DefaultItemAnimator
)
...
@@ -147,13 +146,14 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -147,13 +146,14 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
override
def
onDestroy
{
override
def
onDestroy
{
super
.
onDestroy
super
.
onDestroy
ShadowsocksApplication
.
profileManager
.
setProfileAddedListener
(
null
)
profilesAdapter
.
commitRemoves
profilesAdapter
.
commitRemoves
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
scanResult
!=
null
)
Parser
.
parse
(
scanResult
.
getContents
)
match
{
if
(
scanResult
!=
null
)
Parser
.
parse
(
scanResult
.
getContents
)
match
{
case
Some
(
profile
)
=>
profilesAdapter
.
add
(
profile
)
case
Some
(
profile
)
=>
ShadowsocksApplication
.
profileManager
.
createOrUpdateProfile
(
profile
)
case
_
=>
// ignore
case
_
=>
// ignore
}
}
}
}
...
@@ -168,7 +168,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -168,7 +168,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
true
true
case
R
.
id
.
manual_settings
=>
case
R
.
id
.
manual_settings
=>
ShadowsocksApplication
.
profileManager
.
reload
(-
1
)
ShadowsocksApplication
.
profileManager
.
reload
(-
1
)
ShadowsocksApplication
.
profileId
(
ShadowsocksApplication
.
profileManager
.
save
.
id
)
ShadowsocksApplication
.
switchProfile
(
ShadowsocksApplication
.
profileManager
.
save
.
id
)
finish
finish
true
true
case
_
=>
false
case
_
=>
false
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
37cdf8f9
...
@@ -55,12 +55,12 @@ import android.support.v4.content.ContextCompat
...
@@ -55,12 +55,12 @@ import android.support.v4.content.ContextCompat
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.widget.Toolbar
import
android.support.v7.widget.Toolbar
import
android.util.Log
import
android.util.Log
import
android.view.
{
View
,
ViewGroup
,
ViewParent
}
import
android.view.
{
View
Group
,
View
,
ViewParent
}
import
android.widget._
import
android.widget._
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
import
com.github.shadowsocks.database._
import
com.github.shadowsocks.database._
import
com.github.shadowsocks.preferences.
{
NumberPickerPreference
,
DropDown
Preference
,
PasswordEditTextPreference
,
SummaryEditTextPreference
}
import
com.github.shadowsocks.preferences.
{
DropDownPreference
,
NumberPicker
Preference
,
PasswordEditTextPreference
,
SummaryEditTextPreference
}
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.utils._
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
AdView
}
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
AdView
}
...
@@ -197,6 +197,7 @@ class Shadowsocks
...
@@ -197,6 +197,7 @@ class Shadowsocks
private
lazy
val
preferences
=
private
lazy
val
preferences
=
getFragmentManager
.
findFragmentById
(
android
.
R
.
id
.
content
).
asInstanceOf
[
ShadowsocksSettings
]
getFragmentManager
.
findFragmentById
(
android
.
R
.
id
.
content
).
asInstanceOf
[
ShadowsocksSettings
]
private
var
adView
:
AdView
=
_
private
lazy
val
greyTint
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
material_blue_grey_700
)
private
lazy
val
greyTint
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
material_blue_grey_700
)
private
lazy
val
greenTint
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
material_green_700
)
private
lazy
val
greenTint
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
material_green_700
)
...
@@ -349,22 +350,7 @@ class Shadowsocks
...
@@ -349,22 +350,7 @@ class Shadowsocks
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
// Initialize the profile
currentProfile
=
{
ShadowsocksApplication
.
currentProfile
getOrElse
currentProfile
}
ShadowsocksApplication
.
profileManager
.
load
(
currentProfile
.
id
)
setContentView
(
R
.
layout
.
layout_main
)
setContentView
(
R
.
layout
.
layout_main
)
if
(
ShadowsocksApplication
.
proxy
==
"198.199.101.152"
)
{
val
adView
=
new
AdView
(
this
)
adView
.
setAdUnitId
(
"ca-app-pub-9097031975646651/7760346322"
)
adView
.
setAdSize
(
AdSize
.
SMART_BANNER
)
preferences
.
getView
.
asInstanceOf
[
ViewGroup
].
addView
(
adView
,
0
)
adView
.
loadAd
(
new
AdRequest
.
Builder
().
build
())
}
// Initialize action bar
// Initialize action bar
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
getString
(
R
.
string
.
screen_name
))
toolbar
.
setTitle
(
getString
(
R
.
string
.
screen_name
))
...
@@ -429,7 +415,8 @@ class Shadowsocks
...
@@ -429,7 +415,8 @@ class Shadowsocks
case
Some
(
profile
)
=>
profile
// updated
case
Some
(
profile
)
=>
profile
// updated
case
None
=>
// removed
case
None
=>
// removed
val
profiles
=
ShadowsocksApplication
.
profileManager
.
getAllProfiles
.
getOrElse
(
List
[
Profile
]())
val
profiles
=
ShadowsocksApplication
.
profileManager
.
getAllProfiles
.
getOrElse
(
List
[
Profile
]())
ShadowsocksApplication
.
profileId
(
if
(
profiles
.
isEmpty
)
-
1
else
profiles
.
head
.
id
)
if
(
profiles
.
isEmpty
)
ShadowsocksApplication
.
profileManager
.
createDefault
()
else
ShadowsocksApplication
.
switchProfile
(
profiles
.
head
.
id
)
}
}
updatePreferenceScreen
()
updatePreferenceScreen
()
...
@@ -437,14 +424,6 @@ class Shadowsocks
...
@@ -437,14 +424,6 @@ class Shadowsocks
serviceStop
()
serviceStop
()
}
}
def
addProfile
(
profile
:
Profile
)
{
currentProfile
=
profile
ShadowsocksApplication
.
profileManager
.
createOrUpdateProfile
(
currentProfile
)
ShadowsocksApplication
.
profileManager
.
reload
(
currentProfile
.
id
)
updatePreferenceScreen
()
}
protected
override
def
onPause
()
{
protected
override
def
onPause
()
{
super
.
onPause
()
super
.
onPause
()
ShadowsocksApplication
.
profileManager
.
save
ShadowsocksApplication
.
profileManager
.
save
...
@@ -509,6 +488,14 @@ class Shadowsocks
...
@@ -509,6 +488,14 @@ class Shadowsocks
}
}
private
def
updatePreferenceScreen
()
{
private
def
updatePreferenceScreen
()
{
if
(
ShadowsocksApplication
.
proxy
==
"198.199.101.152"
&&
adView
==
null
)
{
adView
=
new
AdView
(
this
)
adView
.
setAdUnitId
(
"ca-app-pub-9097031975646651/7760346322"
)
adView
.
setAdSize
(
AdSize
.
SMART_BANNER
)
preferences
.
getView
.
asInstanceOf
[
ViewGroup
].
addView
(
adView
,
0
)
adView
.
loadAd
(
new
AdRequest
.
Builder
().
build
())
}
val
profile
=
currentProfile
val
profile
=
currentProfile
for
(
name
<-
Shadowsocks
.
PROXY_PREFS
)
{
for
(
name
<-
Shadowsocks
.
PROXY_PREFS
)
{
val
pref
=
preferences
.
findPreference
(
name
)
val
pref
=
preferences
.
findPreference
(
name
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
37cdf8f9
...
@@ -77,12 +77,14 @@ object ShadowsocksApplication {
...
@@ -77,12 +77,14 @@ object ShadowsocksApplication {
.
build
())
.
build
())
def
profileId
=
settings
.
getInt
(
Key
.
profileId
,
-
1
)
def
profileId
=
settings
.
getInt
(
Key
.
profileId
,
-
1
)
def
profileId
(
i
:
Int
)
=
{
def
profileId
(
i
:
Int
)
=
settings
.
edit
.
putInt
(
Key
.
profileId
,
i
).
apply
settings
.
edit
.
putInt
(
Key
.
profileId
,
i
).
apply
profileManager
.
load
(
i
)
}
def
proxy
=
settings
.
getString
(
Key
.
proxy
,
""
)
def
proxy
=
settings
.
getString
(
Key
.
proxy
,
""
)
def
currentProfile
=
profileManager
.
getProfile
(
profileId
)
def
currentProfile
=
profileManager
.
getProfile
(
profileId
)
def
switchProfile
(
id
:
Int
)
=
{
profileId
(
id
)
profileManager
.
load
(
id
)
}
}
}
class
ShadowsocksApplication
extends
Application
{
class
ShadowsocksApplication
extends
Application
{
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
37cdf8f9
...
@@ -46,9 +46,13 @@ import com.github.shadowsocks.utils.Key
...
@@ -46,9 +46,13 @@ import com.github.shadowsocks.utils.Key
class
ProfileManager
(
settings
:
SharedPreferences
,
dbHelper
:
DBHelper
)
{
class
ProfileManager
(
settings
:
SharedPreferences
,
dbHelper
:
DBHelper
)
{
var
profileAddedListener
:
Profile
=>
Any
=
_
def
setProfileAddedListener
(
listener
:
Profile
=>
Any
)
=
this
.
profileAddedListener
=
listener
def
createOrUpdateProfile
(
profile
:
Profile
)
:
Boolean
=
{
def
createOrUpdateProfile
(
profile
:
Profile
)
:
Boolean
=
{
try
{
try
{
dbHelper
.
profileDao
.
createOrUpdate
(
profile
)
dbHelper
.
profileDao
.
createOrUpdate
(
profile
)
if
(
profileAddedListener
!=
null
)
profileAddedListener
(
profile
)
true
true
}
catch
{
}
catch
{
case
ex
:
Exception
=>
case
ex
:
Exception
=>
...
@@ -163,4 +167,15 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
...
@@ -163,4 +167,15 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
updateProfile
(
profile
)
updateProfile
(
profile
)
profile
profile
}
}
def
createDefault
()
:
Profile
=
{
val
profile
=
new
Profile
{
name
=
"Default"
host
=
"198.199.101.152"
remotePort
=
443
password
=
"u1rRWTssNv0p"
}
createOrUpdateProfile
(
profile
)
profile
}
}
}
src/main/scala/com/github/shadowsocks/preferences/NatSwitchPreference.scala
View file @
37cdf8f9
...
@@ -22,5 +22,6 @@ final class NatSwitchPreference(context: Context, attrs: AttributeSet) extends S
...
@@ -22,5 +22,6 @@ final class NatSwitchPreference(context: Context, attrs: AttributeSet) extends S
setSummary
(
R
.
string
.
nat_summary_no_root
)
setSummary
(
R
.
string
.
nat_summary_no_root
)
}
}
override
def
onGetDefaultValue
(
a
:
TypedArray
,
index
:
Int
)
=
ShadowsocksApplication
.
isVpnEnabled
.
asInstanceOf
[
AnyRef
]
override
def
onGetDefaultValue
(
a
:
TypedArray
,
index
:
Int
)
=
(!
ShadowsocksApplication
.
isVpnEnabled
).
asInstanceOf
[
AnyRef
]
}
}
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