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
6f55861d
Commit
6f55861d
authored
Sep 28, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model ready
parent
dfe737a8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
224 additions
and
4 deletions
+224
-4
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+9
-2
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+5
-0
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+40
-1
src/main/scala/com/github/shadowsocks/database/MenuAdapter.scala
...n/scala/com/github/shadowsocks/database/MenuAdapter.scala
+39
-0
src/main/scala/com/github/shadowsocks/database/Profile.scala
src/main/scala/com/github/shadowsocks/database/Profile.scala
+40
-1
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+91
-0
No files found.
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
6f55861d
...
@@ -69,10 +69,11 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener
...
@@ -69,10 +69,11 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
com.google.ads.
{
AdRequest
,
AdSize
,
AdView
}
import
com.google.ads.
{
AdRequest
,
AdSize
,
AdView
}
import
net.simonvt.menudrawer.MenuDrawer
import
net.simonvt.menudrawer.MenuDrawer
import
com.github.shadowsocks.database.
{
MenuAdapter
,
Item
,
Category
}
import
com.github.shadowsocks.database.
_
import
scala.collection.mutable.ListBuffer
import
scala.collection.mutable.ListBuffer
import
com.github.shadowsocks.database.Category
import
com.github.shadowsocks.database.Category
import
com.github.shadowsocks.database.Item
import
com.github.shadowsocks.database.Item
import
com.github.shadowsocks.database.Profile
object
Shadowsocks
{
object
Shadowsocks
{
...
@@ -228,6 +229,7 @@ class Shadowsocks
...
@@ -228,6 +229,7 @@ class Shadowsocks
lazy
val
drawer
=
MenuDrawer
.
attach
(
this
)
lazy
val
drawer
=
MenuDrawer
.
attach
(
this
)
lazy
val
listView
=
new
ListView
(
this
)
lazy
val
listView
=
new
ListView
(
this
)
lazy
val
menuAdapter
=
new
MenuAdapter
(
this
,
getMenuList
)
lazy
val
menuAdapter
=
new
MenuAdapter
(
this
,
getMenuList
)
lazy
val
profileManager
=
getApplication
.
asInstanceOf
[
ShadowsocksApplication
].
profileManager
private
val
handler
:
Handler
=
new
Handler
{
private
val
handler
:
Handler
=
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
{
override
def
handleMessage
(
msg
:
Message
)
{
...
@@ -446,8 +448,13 @@ class Shadowsocks
...
@@ -446,8 +448,13 @@ class Shadowsocks
}
}
def
updateProfile
(
id
:
Int
)
{
}
def
getProfileList
:
List
[
Item
]
=
{
def
getProfileList
:
List
[
Item
]
=
{
List
[
Item
]()
val
list
=
profileManager
.
getAllProfiles
getOrElse
List
[
Profile
]()
list
.
map
(
p
=>
new
Item
(
p
.
id
,
p
.
name
,
-
1
,
updateProfile
))
}
}
def
getMenuList
:
List
[
Any
]
=
{
def
getMenuList
:
List
[
Any
]
=
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
6f55861d
...
@@ -40,9 +40,14 @@ package com.github.shadowsocks
...
@@ -40,9 +40,14 @@ package com.github.shadowsocks
import
android.app.Application
import
android.app.Application
import
com.google.analytics.tracking.android.EasyTracker
import
com.google.analytics.tracking.android.EasyTracker
import
com.github.shadowsocks.database.
{
ProfileManager
,
DBHelper
}
class
ShadowsocksApplication
extends
Application
{
class
ShadowsocksApplication
extends
Application
{
lazy
val
dbHelper
=
new
DBHelper
(
this
)
lazy
val
profileManager
=
new
ProfileManager
(
dbHelper
)
override
def
onCreate
()
{
override
def
onCreate
()
{
EasyTracker
.
getInstance
.
setContext
(
this
)
EasyTracker
.
getInstance
.
setContext
(
this
)
}
}
}
}
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
6f55861d
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.database
package
com.github.shadowsocks.database
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
...
@@ -7,7 +46,7 @@ import com.j256.ormlite.support.ConnectionSource
...
@@ -7,7 +46,7 @@ import com.j256.ormlite.support.ConnectionSource
import
com.j256.ormlite.table.TableUtils
import
com.j256.ormlite.table.TableUtils
import
com.j256.ormlite.dao.Dao
import
com.j256.ormlite.dao.Dao
class
DBHelper
(
implicit
val
context
:
Context
)
extends
OrmLiteSqliteOpenHelper
(
context
,
"postnauka
"
,
null
,
3
)
{
class
DBHelper
(
val
context
:
Context
)
extends
OrmLiteSqliteOpenHelper
(
context
,
"profile.db
"
,
null
,
3
)
{
lazy
val
profileDao
:
Dao
[
Profile
,
Int
]
=
getDao
(
classOf
[
Profile
])
lazy
val
profileDao
:
Dao
[
Profile
,
Int
]
=
getDao
(
classOf
[
Profile
])
...
...
src/main/scala/com/github/shadowsocks/database/MenuAdapter.scala
View file @
6f55861d
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.database
package
com.github.shadowsocks.database
import
android.content.
{
DialogInterface
,
Context
}
import
android.content.
{
DialogInterface
,
Context
}
...
...
src/main/scala/com/github/shadowsocks/database/Profile.scala
View file @
6f55861d
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.database
package
com.github.shadowsocks.database
import
com.j256.ormlite.field.
{
DataType
,
DatabaseField
}
import
com.j256.ormlite.field.
{
DataType
,
DatabaseField
}
...
@@ -9,7 +48,7 @@ class Profile {
...
@@ -9,7 +48,7 @@ class Profile {
@DatabaseField
@DatabaseField
var
name
:
String
=
null
var
name
:
String
=
null
@DatabaseField
(
foreign
=
true
,
canBeNull
=
false
)
@DatabaseField
var
host
:
String
=
null
var
host
:
String
=
null
@DatabaseField
@DatabaseField
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
0 → 100644
View file @
6f55861d
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.database
import
android.util.Log
import
com.github.shadowsocks.Shadowsocks
class
ProfileManager
(
dbHelper
:
DBHelper
)
{
def
addProfile
(
profile
:
Profile
)
:
Boolean
=
{
try
{
dbHelper
.
profileDao
.
createOrUpdate
(
profile
)
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
Shadowsocks
.
TAG
,
"addProfile"
,
ex
)
return
false
}
true
}
def
getProfile
(
id
:
Int
)
:
Option
[
Profile
]
=
{
try
{
dbHelper
.
profileDao
.
queryForId
(
id
)
match
{
case
profile
:
Profile
=>
Option
(
profile
)
case
_
=>
None
}
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
Shadowsocks
.
TAG
,
"getProfile"
,
ex
)
return
None
}
}
def
delProfile
(
id
:
Int
)
:
Boolean
=
{
try
{
dbHelper
.
profileDao
.
deleteById
(
id
)
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
Shadowsocks
.
TAG
,
"delProfile"
,
ex
)
return
false
}
true
}
def
getAllProfiles
:
Option
[
List
[
Profile
]]
=
{
try
{
import
scala.collection.JavaConversions._
Option
(
dbHelper
.
profileDao
.
queryForAll
().
toList
)
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
Shadowsocks
.
TAG
,
"getAllProfiles"
,
ex
)
None
}
}
}
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