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
cd25dcdc
Commit
cd25dcdc
authored
Dec 17, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a confirm dialog before discarding changes
parent
859ef530
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
5 deletions
+28
-5
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+1
-2
src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala
.../scala/com/github/shadowsocks/ProfileConfigActivity.scala
+12
-1
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
.../scala/com/github/shadowsocks/ProfileConfigFragment.scala
+12
-1
src/main/scala/com/github/shadowsocks/database/Profile.scala
src/main/scala/com/github/shadowsocks/database/Profile.scala
+1
-1
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+2
-0
No files found.
src/main/AndroidManifest.xml
View file @
cd25dcdc
...
...
@@ -68,8 +68,7 @@
android:name=
".ProfileConfigActivity"
android:excludeFromRecents=
"true"
android:label=
"Profile config"
android:launchMode=
"singleTask"
android:parentActivityName=
".MainActivity"
/>
android:launchMode=
"singleTask"
/>
<activity
android:name=
".ShadowsocksRunnerActivity"
...
...
src/main/scala/com/github/shadowsocks/ProfileConfigActivity.scala
View file @
cd25dcdc
package
com.github.shadowsocks
import
android.app.Activity
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
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
...
...
@@ -12,9 +16,16 @@ class ProfileConfigActivity extends Activity {
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
"Profile config"
)
// TODO
toolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_navigation_close
)
toolbar
.
setNavigationOnClickListener
(
_
=>
finish
())
toolbar
.
setNavigationOnClickListener
(
_
=>
onBackPressed
())
toolbar
.
inflateMenu
(
R
.
menu
.
profile_config_menu
)
toolbar
.
setOnMenuItemClickListener
(
getFragmentManager
.
findFragmentById
(
R
.
id
.
content
)
.
asInstanceOf
[
OnMenuItemClickListener
])
}
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
)
.
create
()
.
show
()
else
super
.
onBackPressed
()
}
src/main/scala/com/github/shadowsocks/ProfileConfigFragment.scala
View file @
cd25dcdc
...
...
@@ -20,6 +20,7 @@
package
com.github.shadowsocks
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content._
import
android.os._
import
android.support.v14.preference.SwitchPreference
...
...
@@ -34,7 +35,8 @@ import com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.preferences.KcpCliPreferenceDialogFragment
import
com.github.shadowsocks.utils.
{
Action
,
Key
,
Utils
}
class
ProfileConfigFragment
extends
PreferenceFragment
with
OnMenuItemClickListener
{
class
ProfileConfigFragment
extends
PreferenceFragment
with
OnMenuItemClickListener
with
OnSharedPreferenceChangeListener
{
private
lazy
val
clipboard
=
getActivity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
).
asInstanceOf
[
ClipboardManager
]
private
var
profile
:
Profile
=
_
private
var
isProxyApps
:
SwitchPreference
=
_
...
...
@@ -59,6 +61,15 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
isProxyApps
.
setChecked
(
true
)
false
})
app
.
settings
.
registerOnSharedPreferenceChangeListener
(
this
)
}
override
def
onSharedPreferenceChanged
(
sharedPreferences
:
SharedPreferences
,
key
:
String
)
:
Unit
=
if
(
findPreference
(
key
)
!=
null
)
app
.
editor
.
putBoolean
(
Key
.
dirty
,
true
).
apply
()
override
def
onDestroy
()
{
app
.
settings
.
unregisterOnSharedPreferenceChangeListener
(
this
)
super
.
onDestroy
()
}
override
def
onResume
()
{
...
...
src/main/scala/com/github/shadowsocks/database/Profile.scala
View file @
cd25dcdc
...
...
@@ -119,7 +119,7 @@ class Profile {
.
putString
(
Key
.
individual
,
individual
)
.
putBoolean
(
Key
.
kcp
,
kcp
)
.
putInt
(
Key
.
kcpPort
,
kcpPort
)
.
putString
(
Key
.
kcpcli
,
kcpcli
)
.
remove
(
Key
.
dirty
)
def
deserialize
(
pref
:
SharedPreferences
)
{
// It's assumed that default values are never used, so 0/false/null is always used even if that isn't the case
name
=
pref
.
getString
(
Key
.
name
,
null
)
...
...
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
cd25dcdc
...
...
@@ -155,6 +155,8 @@ object Key {
val
kcpPort
=
"kcpPort"
val
kcpcli
=
"kcpcli"
val
dirty
=
"profileDirty"
val
tfo
=
"tcp_fastopen"
val
currentVersionCode
=
"currentVersionCode"
}
...
...
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