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
f01cbe15
Commit
f01cbe15
authored
Dec 24, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prompt to save changes when exiting profile config
parent
f9e504b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
16 deletions
+21
-16
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+1
-1
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+2
-2
src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala
.../scala/com/github/shadowsocks/ProfileConfigActivity.scala
+7
-6
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
.../scala/com/github/shadowsocks/ProfileConfigFragment.scala
+11
-7
No files found.
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
f01cbe15
...
...
@@ -259,7 +259,7 @@ trait BaseService extends Service {
override
def
onCreate
()
{
super
.
onCreate
()
app
.
refreshContainerHolder
app
.
refreshContainerHolder
()
app
.
updateAssets
()
}
...
...
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
f01cbe15
...
...
@@ -327,9 +327,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
}
val
dialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
add_profile_dialog
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
_
,
_
)
=>
.
setPositiveButton
(
"Yes"
,
((
_
,
_
)
=>
// TODO
profiles
.
foreach
(
app
.
profileManager
.
createProfile
))
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
null
)
.
setNegativeButton
(
"No"
,
null
)
.
setMessage
(
profiles
.
mkString
(
"\n"
))
.
create
()
dialog
.
show
()
...
...
src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala
View file @
f01cbe15
...
...
@@ -5,11 +5,12 @@ import android.content.DialogInterface
import
android.os.Bundle
import
android.support.v7.app.AlertDialog
import
android.support.v7.widget.Toolbar
import
android.support.v7.widget.Toolbar.OnMenuItemClickListener
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.Key
class
ProfileConfigActivity
extends
Activity
{
private
lazy
val
child
=
getFragmentManager
.
findFragmentById
(
R
.
id
.
content
).
asInstanceOf
[
ProfileConfigFragment
]
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_profile_config
)
...
...
@@ -18,14 +19,14 @@ class ProfileConfigActivity extends Activity {
toolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_navigation_close
)
toolbar
.
setNavigationOnClickListener
(
_
=>
onBackPressed
())
toolbar
.
inflateMenu
(
R
.
menu
.
profile_config_menu
)
toolbar
.
setOnMenuItemClickListener
(
getFragmentManager
.
findFragmentById
(
R
.
id
.
content
)
.
asInstanceOf
[
OnMenuItemClickListener
])
toolbar
.
setOnMenuItemClickListener
(
child
)
}
override
def
onBackPressed
()
:
Unit
=
if
(
app
.
settings
.
getBoolean
(
Key
.
dirty
,
false
))
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
"Confirm?"
)
// TODO
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
_
,
_
)
=>
finish
())
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
null
)
.
setTitle
(
"Changes not saved. Do you want to save?"
)
// TODO: localizations
.
setPositiveButton
(
"Yes"
,
((
_
,
_
)
=>
child
.
saveAndExit
())
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
"No"
,
((
_
,
_
)
=>
finish
())
:
DialogInterface.OnClickListener
)
.
setNeutralButton
(
android
.
R
.
string
.
cancel
,
null
)
.
create
()
.
show
()
else
super
.
onBackPressed
()
}
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
View file @
f01cbe15
...
...
@@ -92,23 +92,27 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
case
R
.
id
.
action_delete
=>
new
AlertDialog
.
Builder
(
getActivity
)
.
setTitle
(
"Confirm?"
)
// TODO
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
((
_
,
_
)
=>
{
.
setPositiveButton
(
"Yes"
,
((
_
,
_
)
=>
{
app
.
profileManager
.
delProfile
(
profile
.
id
)
LocalBroadcastManager
.
getInstance
(
getActivity
)
.
sendBroadcast
(
new
Intent
(
Action
.
PROFILE_REMOVED
).
putExtra
(
Action
.
EXTRA_PROFILE_ID
,
profile
.
id
))
getActivity
.
finish
()
})
:
DialogInterface.OnClickListener
)
.
setNegativeButton
(
android
.
R
.
string
.
no
,
null
)
.
setNegativeButton
(
"No"
,
null
)
.
create
()
.
show
()
true
case
R
.
id
.
action_apply
=>
profile
.
deserialize
(
app
.
settings
)
app
.
profileManager
.
updateProfile
(
profile
)
LocalBroadcastManager
.
getInstance
(
getActivity
)
.
sendBroadcast
(
new
Intent
(
Action
.
PROFILE_CHANGED
).
putExtra
(
Action
.
EXTRA_PROFILE_ID
,
profile
.
id
))
getActivity
.
finish
()
saveAndExit
()
true
case
_
=>
false
}
def
saveAndExit
()
{
profile
.
deserialize
(
app
.
settings
)
app
.
profileManager
.
updateProfile
(
profile
)
LocalBroadcastManager
.
getInstance
(
getActivity
)
.
sendBroadcast
(
new
Intent
(
Action
.
PROFILE_CHANGED
).
putExtra
(
Action
.
EXTRA_PROFILE_ID
,
profile
.
id
))
getActivity
.
finish
()
}
}
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