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
6f6cb461
Commit
6f6cb461
authored
Nov 10, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ParserActivity
parent
42c5a01d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
34 deletions
+23
-34
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+4
-2
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
+5
-5
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+0
-8
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+4
-0
No files found.
src/main/AndroidManifest.xml
View file @
6f6cb461
...
@@ -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/scala/com/github/shadowsocks/ParserActivity.scala
View file @
6f6cb461
...
@@ -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 @
6f6cb461
...
@@ -82,10 +82,8 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
...
@@ -82,10 +82,8 @@ 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
)
{
...
@@ -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
}
}
}
}
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
6f6cb461
...
@@ -424,14 +424,6 @@ class Shadowsocks
...
@@ -424,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
...
...
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
6f6cb461
...
@@ -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
=>
...
...
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