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
42c5a01d
Commit
42c5a01d
authored
Nov 10, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix default configuration
parent
8045c961
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
35 deletions
+32
-35
src/main/res/xml/pref_all.xml
src/main/res/xml/pref_all.xml
+0
-11
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
...scala/com/github/shadowsocks/ProfileManagerActivity.scala
+2
-2
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+13
-18
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
+11
-0
No files found.
src/main/res/xml/pref_all.xml
View file @
42c5a01d
...
...
@@ -18,23 +18,19 @@
android:title=
"@string/proxy_cat"
>
<com.github.shadowsocks.preferences.SummaryEditTextPreference
android:defaultValue=
"Default"
android:key=
"profileName"
android:title=
"@string/profile_name"
/>
<com.github.shadowsocks.preferences.SummaryEditTextPreference
android:defaultValue=
"198.199.101.152"
android:key=
"proxy"
android:summary=
"@string/proxy_summary"
android:title=
"@string/proxy"
/>
<com.github.shadowsocks.preferences.NumberPickerPreference
android:defaultValue=
"443"
app:min=
"1"
app:max=
"65535"
android:key=
"remotePort"
app:summary=
"@string/remote_port_summary"
android:title=
"@string/remote_port"
/>
<com.github.shadowsocks.preferences.NumberPickerPreference
android:defaultValue=
"1080"
app:min=
"1025"
app:max=
"65535"
android:key=
"port"
...
...
@@ -42,12 +38,10 @@
android:title=
"@string/port"
/>
<com.github.shadowsocks.preferences.PasswordEditTextPreference
android:inputType=
"textPassword"
android:defaultValue=
"u1rRWTssNv0p"
android:key=
"sitekey"
android:summary=
"@string/sitekey_summary"
android:title=
"@string/sitekey"
/>
<com.github.shadowsocks.preferences.DropDownPreference
android:defaultValue=
"rc4"
android:key=
"encMethod"
app:entries=
"@array/enc_method_entry"
app:entryValues=
"@array/enc_method_value"
...
...
@@ -55,7 +49,6 @@
android:title=
"@string/enc_method"
/>
<SwitchPreference
android:key=
"isAuth"
android:defaultValue=
"false"
android:summary=
"@string/onetime_auth_summary"
android:title=
"@string/onetime_auth"
/>
...
...
@@ -65,7 +58,6 @@
android:title=
"@string/feature_cat"
>
<com.github.shadowsocks.preferences.DropDownPreference
android:defaultValue=
"all"
android:key=
"route"
app:entries=
"@array/route_entry"
app:entryValues=
"@array/route_value"
...
...
@@ -73,17 +65,14 @@
android:title=
"@string/route_list"
/>
<SwitchPreference
android:key=
"isIpv6"
android:defaultValue=
"false"
android:summary=
"@string/ipv6_summary"
android:title=
"@string/ipv6"
/>
<SwitchPreference
android:key=
"isProxyApps"
android:defaultValue=
"false"
android:summary=
"@string/proxied_apps_summary"
android:title=
"@string/proxied_apps"
/>
<SwitchPreference
android:key=
"isUdpDns"
android:defaultValue=
"false"
android:summary=
"@string/udp_dns_summary"
android:title=
"@string/udp_dns"
/>
...
...
src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
View file @
42c5a01d
...
...
@@ -61,7 +61,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
}
def
onClick
(
v
:
View
)
=
{
ShadowsocksApplication
.
profileId
(
item
.
id
)
ShadowsocksApplication
.
switchProfile
(
item
.
id
)
finish
}
}
...
...
@@ -168,7 +168,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
true
case
R
.
id
.
manual_settings
=>
ShadowsocksApplication
.
profileManager
.
reload
(-
1
)
ShadowsocksApplication
.
profileId
(
ShadowsocksApplication
.
profileManager
.
save
.
id
)
ShadowsocksApplication
.
switchProfile
(
ShadowsocksApplication
.
profileManager
.
save
.
id
)
finish
true
case
_
=>
false
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
42c5a01d
...
...
@@ -55,12 +55,12 @@ import android.support.v4.content.ContextCompat
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.widget.Toolbar
import
android.util.Log
import
android.view.
{
View
,
ViewGroup
,
ViewParent
}
import
android.view.
{
View
Group
,
View
,
ViewParent
}
import
android.widget._
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
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.google.android.gms.ads.
{
AdRequest
,
AdSize
,
AdView
}
...
...
@@ -197,6 +197,7 @@ class Shadowsocks
private
lazy
val
preferences
=
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
greenTint
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
material_green_700
)
...
...
@@ -349,22 +350,7 @@ class Shadowsocks
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
// Initialize the profile
currentProfile
=
{
ShadowsocksApplication
.
currentProfile
getOrElse
currentProfile
}
ShadowsocksApplication
.
profileManager
.
load
(
currentProfile
.
id
)
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
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
getString
(
R
.
string
.
screen_name
))
...
...
@@ -429,7 +415,8 @@ class Shadowsocks
case
Some
(
profile
)
=>
profile
// updated
case
None
=>
// removed
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
()
...
...
@@ -509,6 +496,14 @@ class Shadowsocks
}
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
for
(
name
<-
Shadowsocks
.
PROXY_PREFS
)
{
val
pref
=
preferences
.
findPreference
(
name
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
42c5a01d
...
...
@@ -77,12 +77,14 @@ object ShadowsocksApplication {
.
build
())
def
profileId
=
settings
.
getInt
(
Key
.
profileId
,
-
1
)
def
profileId
(
i
:
Int
)
=
{
settings
.
edit
.
putInt
(
Key
.
profileId
,
i
).
apply
profileManager
.
load
(
i
)
}
def
profileId
(
i
:
Int
)
=
settings
.
edit
.
putInt
(
Key
.
profileId
,
i
).
apply
def
proxy
=
settings
.
getString
(
Key
.
proxy
,
""
)
def
currentProfile
=
profileManager
.
getProfile
(
profileId
)
def
switchProfile
(
id
:
Int
)
=
{
profileId
(
id
)
profileManager
.
load
(
id
)
}
}
class
ShadowsocksApplication
extends
Application
{
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
42c5a01d
...
...
@@ -163,4 +163,15 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
updateProfile
(
profile
)
profile
}
def
createDefault
()
:
Profile
=
{
val
profile
=
new
Profile
{
name
=
"Default"
host
=
"198.199.101.152"
remotePort
=
443
password
=
"u1rRWTssNv0p"
}
createOrUpdateProfile
(
profile
)
profile
}
}
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