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
58dc3e50
Commit
58dc3e50
authored
Sep 29, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine UI
parent
a2848ce5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
22 deletions
+61
-22
src/main/res/values/styles.xml
src/main/res/values/styles.xml
+5
-0
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+43
-6
src/main/scala/com/github/shadowsocks/database/MenuAdapter.scala
...n/scala/com/github/shadowsocks/database/MenuAdapter.scala
+8
-10
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+5
-6
No files found.
src/main/res/values/styles.xml
View file @
58dc3e50
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
<!-- Variation on the Light theme that turns off the title -->
<!-- Variation on the Light theme that turns off the title -->
<style
name=
"Theme.Shadowsocks"
parent=
"@style/Theme.Shadow"
>
<style
name=
"Theme.Shadowsocks"
parent=
"@style/Theme.Shadow"
>
<item
name=
"switchStyle"
>
@style/Widget.Shadow.Switch
</item>
<item
name=
"switchStyle"
>
@style/Widget.Shadow.Switch
</item>
<item
name=
"menuDrawerStyle"
>
@style/MenuDrawerStyle
</item>
</style>
</style>
<style
name=
"Theme.AppManager"
parent=
"@style/Theme.Shadow"
>
<style
name=
"Theme.AppManager"
parent=
"@style/Theme.Shadow"
>
...
@@ -60,5 +61,9 @@
...
@@ -60,5 +61,9 @@
<item
name=
"android:gravity"
>
center_vertical
</item>
<item
name=
"android:gravity"
>
center_vertical
</item>
</style>
</style>
<style
name=
"MenuDrawerStyle"
parent=
"Widget.MenuDrawer"
>
<item
name=
"mdActiveIndicator"
>
@drawable/menu_arrow
</item>
<item
name=
"mdMenuSize"
>
250dp
</item>
</style>
</resources>
</resources>
\ No newline at end of file
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
58dc3e50
...
@@ -289,6 +289,9 @@ class Shadowsocks
...
@@ -289,6 +289,9 @@ class Shadowsocks
private
val
MSG_CRASH_RECOVER
:
Int
=
1
private
val
MSG_CRASH_RECOVER
:
Int
=
1
private
val
MSG_INITIAL_FINISH
:
Int
=
2
private
val
MSG_INITIAL_FINISH
:
Int
=
2
private
val
STATE_MENUDRAWER
=
"com.github.shadowsocks.menuDrawer"
private
val
STATE_ACTIVE_VIEW_ID
=
"com.github.shadowsocks.activeViewId"
private
var
switchButton
:
Switch
=
null
private
var
switchButton
:
Switch
=
null
private
var
progressDialog
:
ProgressDialog
=
null
private
var
progressDialog
:
ProgressDialog
=
null
...
@@ -483,6 +486,8 @@ class Shadowsocks
...
@@ -483,6 +486,8 @@ class Shadowsocks
profileManager
.
getProfile
(
settings
.
getInt
(
Key
.
profileId
,
-
1
))
getOrElse
new
Profile
()
profileManager
.
getProfile
(
settings
.
getInt
(
Key
.
profileId
,
-
1
))
getOrElse
new
Profile
()
}
}
menuAdapter
.
setActiveId
(
settings
.
getInt
(
Key
.
profileId
,
-
1
))
menuAdapter
.
setListener
(
this
)
listView
.
setAdapter
(
menuAdapter
)
listView
.
setAdapter
(
menuAdapter
)
drawer
.
setMenuView
(
listView
)
drawer
.
setMenuView
(
listView
)
...
@@ -522,17 +527,53 @@ class Shadowsocks
...
@@ -522,17 +527,53 @@ class Shadowsocks
}
}
}
}
override
def
onRestoreInstanceState
(
inState
:
Bundle
)
{
super
.
onRestoreInstanceState
(
inState
)
drawer
.
restoreState
(
inState
.
getParcelable
(
STATE_MENUDRAWER
))
}
override
def
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
outState
.
putParcelable
(
STATE_MENUDRAWER
,
drawer
.
saveState
())
outState
.
putInt
(
STATE_ACTIVE_VIEW_ID
,
Shadowsocks
.
currentProfile
.
id
)
}
override
def
onBackPressed
()
{
val
drawerState
=
drawer
.
getDrawerState
if
(
drawerState
==
MenuDrawer
.
STATE_OPEN
||
drawerState
==
MenuDrawer
.
STATE_OPENING
)
{
drawer
.
closeMenu
()
return
}
super
.
onBackPressed
()
}
override
def
onActiveViewChanged
(
v
:
View
,
pos
:
Int
)
{
override
def
onActiveViewChanged
(
v
:
View
,
pos
:
Int
)
{
drawer
.
setActiveView
(
v
,
pos
)
drawer
.
setActiveView
(
v
,
pos
)
}
}
def
addProfile
(
id
:
Int
)
{
drawer
.
closeMenu
(
true
)
handler
.
postDelayed
(
new
Runnable
{
def
run
()
{
Shadowsocks
.
currentProfile
=
profileManager
.
reload
(
id
)
updatePreferenceScreen
()
profileManager
.
save
()
menuAdapter
.
updateList
(
getMenuList
,
Shadowsocks
.
currentProfile
.
id
)
}
},
600
)
if
(!
isSinglePane
)
sendBroadcast
(
new
Intent
(
Action
.
UPDATE_FRAGMENT
))
}
def
updateProfile
(
id
:
Int
)
{
def
updateProfile
(
id
:
Int
)
{
drawer
.
closeMenu
(
true
)
drawer
.
closeMenu
(
true
)
handler
.
postDelayed
(
new
Runnable
{
handler
.
postDelayed
(
new
Runnable
{
def
run
()
{
def
run
()
{
Shadowsocks
.
currentProfile
=
profileManager
.
load
(
id
)
Shadowsocks
.
currentProfile
=
profileManager
.
re
load
(
id
)
updatePreferenceScreen
()
updatePreferenceScreen
()
menuAdapter
.
setActiveId
(
id
)
}
}
},
600
)
},
600
)
...
@@ -573,11 +614,7 @@ class Shadowsocks
...
@@ -573,11 +614,7 @@ class Shadowsocks
buf
++=
getProfileList
buf
++=
getProfileList
buf
+=
new
Item
(-
1
,
getString
(
R
.
string
.
add_profile
),
android
.
R
.
drawable
.
ic_menu_add
,
_
=>
{
buf
+=
new
Item
(-
1
,
getString
(
R
.
string
.
add_profile
),
android
.
R
.
drawable
.
ic_menu_add
,
addProfile
)
updateProfile
(-
1
)
profileManager
.
save
()
menuAdapter
.
updateList
(
getMenuList
,
Shadowsocks
.
currentProfile
.
id
)
})
buf
+=
new
Category
(
"Settings"
)
buf
+=
new
Category
(
"Settings"
)
...
...
src/main/scala/com/github/shadowsocks/database/MenuAdapter.scala
View file @
58dc3e50
...
@@ -70,8 +70,8 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
...
@@ -70,8 +70,8 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
this
.
listener
=
listener
this
.
listener
=
listener
}
}
def
setActive
Position
(
activePosition
:
Int
)
{
def
setActive
Id
(
activeId
:
Int
)
{
this
.
active
Position
=
activePosition
this
.
active
Id
=
activeId
}
}
@Override
def
getCount
:
Int
=
{
@Override
def
getCount
:
Int
=
{
...
@@ -139,28 +139,26 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
...
@@ -139,28 +139,26 @@ class MenuAdapter(context: Context, var items: List[Any]) extends BaseAdapter {
v
.
setTag
(
R
.
id
.
mdItem
,
value
)
v
.
setTag
(
R
.
id
.
mdItem
,
value
)
if
(
value
.
id
==
activeId
)
{
if
(
listener
!=
null
)
listener
.
onActiveViewChanged
(
v
,
position
)
}
case
_
=>
case
_
=>
}
}
v
.
setTag
(
R
.
id
.
mdActiveViewPosition
,
position
)
v
.
setTag
(
R
.
id
.
mdActiveViewPosition
,
position
)
if
(
position
==
activePosition
)
{
if
(
listener
!=
null
)
listener
.
onActiveViewChanged
(
v
,
position
)
}
v
v
}
}
def
updateList
(
list
:
List
[
Any
],
activeId
:
Int
)
{
def
updateList
(
list
:
List
[
Any
],
activeId
:
Int
)
{
items
=
list
items
=
list
activePosition
=
items
.
indexWhere
{
this
.
activeId
=
activeId
case
item
:
Item
=>
item
.
id
==
activeId
case
_
=>
false
}
notifyDataSetChanged
()
notifyDataSetChanged
()
}
}
private
var
listener
:
MenuAdapter.MenuListener
=
null
private
var
listener
:
MenuAdapter.MenuListener
=
null
private
var
active
Position
:
Int
=
-
1
private
var
active
Id
:
Int
=
-
1
}
}
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
58dc3e50
...
@@ -91,11 +91,12 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
...
@@ -91,11 +91,12 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
}
}
}
}
def
load
(
id
:
Int
)
:
Profile
=
{
def
reload
(
id
:
Int
)
:
Profile
=
{
Log
.
d
(
Shadowsocks
.
TAG
,
id
+
" "
)
save
()
save
()
load
(
id
)
}
def
load
(
id
:
Int
)
:
Profile
=
{
val
profile
=
getProfile
(
id
)
getOrElse
{
val
profile
=
getProfile
(
id
)
getOrElse
{
val
p
=
new
Profile
()
val
p
=
new
Profile
()
...
@@ -103,8 +104,6 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
...
@@ -103,8 +104,6 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
p
p
}
}
Log
.
d
(
Shadowsocks
.
TAG
,
"load "
+
profile
.
id
+
" "
+
profile
.
name
)
val
edit
=
settings
.
edit
()
val
edit
=
settings
.
edit
()
edit
.
putBoolean
(
Key
.
isGlobalProxy
,
profile
.
global
)
edit
.
putBoolean
(
Key
.
isGlobalProxy
,
profile
.
global
)
edit
.
putBoolean
(
Key
.
isGFWList
,
profile
.
chnroute
)
edit
.
putBoolean
(
Key
.
isGFWList
,
profile
.
chnroute
)
...
...
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