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
719d8eaa
Commit
719d8eaa
authored
Dec 24, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move reset functionality to drawer
parent
34fe03c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
41 deletions
+37
-41
src/main/res/xml/pref_global.xml
src/main/res/xml/pref_global.xml
+0
-3
src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala
...n/scala/com/github/shadowsocks/GlobalConfigFragment.scala
+2
-34
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+35
-4
No files found.
src/main/res/xml/pref_global.xml
View file @
719d8eaa
...
@@ -10,7 +10,4 @@
...
@@ -10,7 +10,4 @@
<SwitchPreference
android:key=
"isNAT"
<SwitchPreference
android:key=
"isNAT"
android:title=
"@string/nat"
android:title=
"@string/nat"
android:summary=
"@string/nat_summary"
/>
android:summary=
"@string/nat_summary"
/>
<Preference
android:key=
"recovery"
android:title=
"@string/recovery"
android:summary=
"@string/recovery_summary"
/>
</PreferenceScreen>
</PreferenceScreen>
src/main/scala/com/github/shadowsocks/GlobalConfigFragment.scala
View file @
719d8eaa
package
com.github.shadowsocks
package
com.github.shadowsocks
import
android.app.ProgressDialog
import
android.os.Bundle
import
android.os.
{
Bundle
,
Handler
,
Message
}
import
android.support.design.widget.Snackbar
import
android.support.design.widget.Snackbar
import
android.support.v14.preference.SwitchPreference
import
android.support.v14.preference.SwitchPreference
import
be.mygod.preference.PreferenceFragment
import
be.mygod.preference.PreferenceFragment
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.
{
Key
,
TcpFastOpen
}
import
com.github.shadowsocks.utils.
{
Key
,
TcpFastOpen
,
Utils
}
class
GlobalConfigFragment
extends
PreferenceFragment
{
class
GlobalConfigFragment
extends
PreferenceFragment
{
private
var
progressDialog
:
ProgressDialog
=
_
override
def
onCreatePreferences
(
bundle
:
Bundle
,
key
:
String
)
{
override
def
onCreatePreferences
(
bundle
:
Bundle
,
key
:
String
)
{
addPreferencesFromResource
(
R
.
xml
.
pref_global
)
addPreferencesFromResource
(
R
.
xml
.
pref_global
)
val
switch
=
findPreference
(
Key
.
isAutoConnect
).
asInstanceOf
[
SwitchPreference
]
val
switch
=
findPreference
(
Key
.
isAutoConnect
).
asInstanceOf
[
SwitchPreference
]
...
@@ -37,33 +33,5 @@ class GlobalConfigFragment extends PreferenceFragment {
...
@@ -37,33 +33,5 @@ class GlobalConfigFragment extends PreferenceFragment {
tfo
.
setEnabled
(
false
)
tfo
.
setEnabled
(
false
)
tfo
.
setSummary
(
getString
(
R
.
string
.
tcp_fastopen_summary_unsupported
,
java
.
lang
.
System
.
getProperty
(
"os.version"
)))
tfo
.
setSummary
(
getString
(
R
.
string
.
tcp_fastopen_summary_unsupported
,
java
.
lang
.
System
.
getProperty
(
"os.version"
)))
}
}
findPreference
(
"recovery"
).
setOnPreferenceClickListener
(
_
=>
{
app
.
track
(
"GlobalConfigFragment"
,
"reset"
)
Utils
.
stopSsService
(
getActivity
)
val
h
=
showProgress
(
R
.
string
.
recovering
)
Utils
.
ThrowableFuture
{
app
.
copyAssets
()
h
.
sendEmptyMessage
(
0
)
}
true
})
}
private
def
showProgress
(
msg
:
Int
)
:
Handler
=
{
clearDialog
()
progressDialog
=
ProgressDialog
.
show
(
getActivity
,
""
,
getString
(
msg
),
true
,
false
)
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
{
clearDialog
()
}
}
}
def
clearDialog
()
{
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
)
{
if
(!
getActivity
.
isDestroyed
)
progressDialog
.
dismiss
()
progressDialog
=
null
}
}
}
}
}
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
719d8eaa
...
@@ -24,13 +24,13 @@ import java.lang.System.currentTimeMillis
...
@@ -24,13 +24,13 @@ import java.lang.System.currentTimeMillis
import
java.net.
{
HttpURLConnection
,
URL
}
import
java.net.
{
HttpURLConnection
,
URL
}
import
java.util.Locale
import
java.util.Locale
import
android.app.
Activity
import
android.app.
{
Activity
,
ProgressDialog
}
import
android.app.backup.BackupManager
import
android.app.backup.BackupManager
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content._
import
android.content._
import
android.net.
{
Uri
,
VpnService
}
import
android.net.
{
Uri
,
VpnService
}
import
android.nfc.
{
NdefMessage
,
NfcAdapter
}
import
android.nfc.
{
NdefMessage
,
NfcAdapter
}
import
android.os.
{
Build
,
Bundle
,
Handler
}
import
android.os.
{
Build
,
Bundle
,
Handler
,
Message
}
import
android.support.design.widget.
{
FloatingActionButton
,
Snackbar
}
import
android.support.design.widget.
{
FloatingActionButton
,
Snackbar
}
import
android.support.v4.content.ContextCompat
import
android.support.v4.content.ContextCompat
import
android.support.v7.app.AlertDialog
import
android.support.v7.app.AlertDialog
...
@@ -57,8 +57,9 @@ object MainActivity {
...
@@ -57,8 +57,9 @@ object MainActivity {
private
final
val
DRAWER_PROFILES
=
0L
private
final
val
DRAWER_PROFILES
=
0L
// sticky drawer items have negative ids
// sticky drawer items have negative ids
private
final
val
DRAWER_GLOBAL_SETTINGS
=
-
1L
private
final
val
DRAWER_RECOVERY
=
-
1L
private
final
val
DRAWER_ABOUT
=
-
2L
private
final
val
DRAWER_GLOBAL_SETTINGS
=
-
2L
private
final
val
DRAWER_ABOUT
=
-
3L
}
}
class
MainActivity
extends
Activity
with
ServiceBoundContext
with
Drawer
.
OnDrawerItemClickListener
class
MainActivity
extends
Activity
with
ServiceBoundContext
with
Drawer
.
OnDrawerItemClickListener
...
@@ -73,6 +74,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -73,6 +74,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
var
currentProfile
=
new
Profile
var
currentProfile
=
new
Profile
var
drawer
:
Drawer
=
_
var
drawer
:
Drawer
=
_
private
var
progressDialog
:
ProgressDialog
=
_
private
var
currentFragment
:
ToolbarFragment
=
_
private
var
currentFragment
:
ToolbarFragment
=
_
private
lazy
val
profilesFragment
=
new
ProfilesFragment
()
private
lazy
val
profilesFragment
=
new
ProfilesFragment
()
private
lazy
val
globalSettingsFragment
=
new
GlobalSettingsFragment
()
private
lazy
val
globalSettingsFragment
=
new
GlobalSettingsFragment
()
...
@@ -219,6 +221,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -219,6 +221,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
.
withIconTintingEnabled
(
true
)
.
withIconTintingEnabled
(
true
)
)
)
.
addStickyDrawerItems
(
.
addStickyDrawerItems
(
new
SecondaryDrawerItem
()
.
withIdentifier
(
DRAWER_RECOVERY
)
.
withName
(
R
.
string
.
recovery
)
.
withIcon
(
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
ic_navigation_refresh
))
.
withIconTintingEnabled
(
true
)
.
withSelectable
(
false
),
new
SecondaryDrawerItem
()
new
SecondaryDrawerItem
()
.
withIdentifier
(
DRAWER_GLOBAL_SETTINGS
)
.
withIdentifier
(
DRAWER_GLOBAL_SETTINGS
)
.
withName
(
R
.
string
.
settings
)
.
withName
(
R
.
string
.
settings
)
...
@@ -355,6 +363,14 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -355,6 +363,14 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
override
def
onItemClick
(
view
:
View
,
position
:
Int
,
drawerItem
:
IDrawerItem
[
_
,
_
<:
ViewHolder
])
:
Boolean
=
{
override
def
onItemClick
(
view
:
View
,
position
:
Int
,
drawerItem
:
IDrawerItem
[
_
,
_
<:
ViewHolder
])
:
Boolean
=
{
drawerItem
.
getIdentifier
match
{
drawerItem
.
getIdentifier
match
{
case
DRAWER_PROFILES
=>
displayFragment
(
profilesFragment
)
case
DRAWER_PROFILES
=>
displayFragment
(
profilesFragment
)
case
DRAWER_RECOVERY
=>
app
.
track
(
"GlobalConfigFragment"
,
"reset"
)
serviceStop
()
val
handler
=
showProgress
(
R
.
string
.
recovering
)
Utils
.
ThrowableFuture
{
app
.
copyAssets
()
handler
.
sendEmptyMessage
(
0
)
}
case
DRAWER_GLOBAL_SETTINGS
=>
displayFragment
(
globalSettingsFragment
)
case
DRAWER_GLOBAL_SETTINGS
=>
displayFragment
(
globalSettingsFragment
)
case
DRAWER_ABOUT
=>
case
DRAWER_ABOUT
=>
app
.
track
(
TAG
,
"about"
)
app
.
track
(
TAG
,
"about"
)
...
@@ -378,6 +394,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -378,6 +394,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
true
// unexpected cases will throw exception
true
// unexpected cases will throw exception
}
}
private
def
showProgress
(
msg
:
Int
)
:
Handler
=
{
clearDialog
()
progressDialog
=
ProgressDialog
.
show
(
this
,
""
,
getString
(
msg
),
true
,
false
)
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
:
Unit
=
clearDialog
()
}
}
private
def
clearDialog
()
{
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
)
{
if
(!
isDestroyed
)
progressDialog
.
dismiss
()
progressDialog
=
null
}
}
private
def
hideCircle
()
{
private
def
hideCircle
()
{
try
{
try
{
fabProgressCircle
.
hide
()
fabProgressCircle
.
hide
()
...
...
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