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
f218282e
Commit
f218282e
authored
Mar 08, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use require* in support library
parent
6d866633
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
30 deletions
+32
-30
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
...om/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
...main/java/com/github/shadowsocks/ProfileConfigFragment.kt
+4
-4
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+13
-13
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
...in/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
+8
-7
mobile/src/main/java/com/github/shadowsocks/preference/BottomSheetPreferenceDialogFragment.kt
...owsocks/preference/BottomSheetPreferenceDialogFragment.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.kt
...adowsocks/preference/PluginConfigurationDialogFragment.kt
+3
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/GlobalSettingsPreferenceFragment.kt
View file @
f218282e
...
...
@@ -50,7 +50,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
boot
.
isChecked
=
BootReceiver
.
enabled
val
dba
=
findPreference
(
Key
.
directBootAware
)
if
(
Build
.
VERSION
.
SDK_INT
>=
24
&&
context
!!
.
getSystemService
(
DevicePolicyManager
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
24
&&
requireContext
()
.
getSystemService
(
DevicePolicyManager
::
class
.
java
)
.
storageEncryptionStatus
==
DevicePolicyManager
.
ENCRYPTION_STATUS_ACTIVE_PER_USER
)
dba
.
onPreferenceChangeListener
=
directBootAwareListener
else
dba
.
parent
!!
.
removePreference
(
dba
)
...
...
@@ -59,7 +59,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
tfo
.
setOnPreferenceChangeListener
{
_
,
value
->
val
result
=
TcpFastOpen
.
enabled
(
value
as
Boolean
)
if
(
result
!=
null
&&
result
!=
"Success."
)
Snackbar
.
make
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
Snackbar
.
make
(
requireActivity
()
.
findViewById
(
R
.
id
.
snackbar
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
value
==
TcpFastOpen
.
sendEnabled
}
if
(!
TcpFastOpen
.
supported
)
{
...
...
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
View file @
f218282e
...
...
@@ -65,7 +65,7 @@ class ProfileConfigFragment : PreferenceFragmentCompatDividers(), Toolbar.OnMenu
override
fun
onCreatePreferencesFix
(
savedInstanceState
:
Bundle
?,
rootKey
:
String
?)
{
preferenceManager
.
preferenceDataStore
=
DataStore
.
privateStore
val
activity
=
activity
!!
val
activity
=
requireActivity
()
val
profile
=
ProfileManager
.
getProfile
(
activity
.
intent
.
getIntExtra
(
Action
.
EXTRA_PROFILE_ID
,
-
1
))
if
(
profile
==
null
)
{
activity
.
finish
()
...
...
@@ -134,7 +134,7 @@ class ProfileConfigFragment : PreferenceFragmentCompatDividers(), Toolbar.OnMenu
ProfileManager
.
updateProfile
(
profile
)
ProfilesFragment
.
instance
?.
profilesAdapter
?.
deepRefreshId
(
profile
.
id
)
if
(
DataStore
.
profileId
==
profile
.
id
&&
DataStore
.
directBootAware
)
DirectBoot
.
update
()
activity
!!
.
finish
()
requireActivity
()
.
finish
()
}
override
fun
onResume
()
{
...
...
@@ -161,7 +161,7 @@ class ProfileConfigFragment : PreferenceFragmentCompatDividers(), Toolbar.OnMenu
override
fun
onDisplayPreferenceDialog
(
preference
:
Preference
)
{
if
(
preference
.
key
==
Key
.
pluginConfigure
)
{
val
intent
=
PluginManager
.
buildIntent
(
pluginConfiguration
.
selected
,
PluginContract
.
ACTION_CONFIGURE
)
if
(
intent
.
resolveActivity
(
activity
!!
.
packageManager
)
!=
null
)
if
(
intent
.
resolveActivity
(
requireContext
()
.
packageManager
)
!=
null
)
startActivityForResult
(
intent
.
putExtra
(
PluginContract
.
EXTRA_OPTIONS
,
pluginConfiguration
.
selectedOptions
.
toString
()),
REQUEST_CODE_PLUGIN_CONFIGURE
)
else
{
showPluginEditor
()
...
...
@@ -183,7 +183,7 @@ class ProfileConfigFragment : PreferenceFragmentCompatDividers(), Toolbar.OnMenu
override
fun
onMenuItemClick
(
item
:
MenuItem
)
=
when
(
item
.
itemId
)
{
R
.
id
.
action_delete
->
{
val
activity
=
activity
!!
val
activity
=
requireActivity
()
AlertDialog
.
Builder
(
activity
)
.
setTitle
(
R
.
string
.
delete_confirm_prompt
)
.
setPositiveButton
(
R
.
string
.
yes
,
{
_
,
_
->
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
f218282e
...
...
@@ -128,7 +128,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
itemView
.
setOnClickListener
(
this
)
val
share
=
itemView
.
findViewById
<
View
>(
R
.
id
.
share
)
share
.
setOnClickListener
{
val
popup
=
PopupMenu
(
activity
!!
,
share
)
val
popup
=
PopupMenu
(
requireContext
()
,
share
)
popup
.
menuInflater
.
inflate
(
R
.
menu
.
profile_share_popup
,
popup
.
menu
)
popup
.
setOnMenuItemClickListener
(
this
)
popup
.
show
()
...
...
@@ -173,10 +173,10 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
var
adView
=
adView
if
(
item
.
host
==
"198.199.101.152"
)
{
if
(
adView
==
null
)
{
val
params
=
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
val
params
=
LinearLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
params
.
gravity
=
Gravity
.
CENTER_HORIZONTAL
val
context
=
context
!!
val
context
=
requireContext
()
adView
=
AdView
(
context
)
adView
.
layoutParams
=
params
adView
.
adUnitId
=
"ca-app-pub-9097031975646651/7760346322"
...
...
@@ -208,7 +208,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override
fun
onMenuItemClick
(
item
:
MenuItem
):
Boolean
=
when
(
item
.
itemId
)
{
R
.
id
.
action_qr_code_nfc
->
{
fragmentManager
!!
.
beginTransaction
().
add
(
QRCodeDialog
(
this
.
item
.
toString
()),
""
)
requireFragmentManager
()
.
beginTransaction
().
add
(
QRCodeDialog
(
this
.
item
.
toString
()),
""
)
.
commitAllowingStateLoss
()
true
}
...
...
@@ -230,7 +230,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override
fun
onBindViewHolder
(
holder
:
ProfileViewHolder
,
position
:
Int
)
=
holder
.
bind
(
profiles
[
position
])
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ProfileViewHolder
=
ProfileViewHolder
(
LayoutInflater
.
from
(
parent
!!
.
context
).
inflate
(
R
.
layout
.
layout_profile
,
parent
,
false
))
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
layout_profile
,
parent
,
false
))
override
fun
getItemCount
():
Int
=
profiles
.
size
override
fun
getItemId
(
position
:
Int
):
Long
=
profiles
[
position
].
id
.
toLong
()
...
...
@@ -305,7 +305,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
private
var
txTotal
:
Long
=
0L
private
var
rxTotal
:
Long
=
0L
private
val
clipboard
by
lazy
{
activity
!!
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
}
private
val
clipboard
by
lazy
{
requireContext
()
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
}
private
fun
startConfig
(
id
:
Int
)
=
startActivity
(
Intent
(
context
,
ProfileConfigActivity
::
class
.
java
)
.
putExtra
(
Action
.
EXTRA_PROFILE_ID
,
id
))
...
...
@@ -331,7 +331,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesList
.
itemAnimator
=
animator
profilesList
.
adapter
=
profilesAdapter
instance
=
this
undoManager
=
UndoSnackbarManager
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
undoManager
=
UndoSnackbarManager
(
requireActivity
()
.
findViewById
(
R
.
id
.
snackbar
),
profilesAdapter
::
undo
,
profilesAdapter
::
commit
)
ItemTouchHelper
(
object
:
ItemTouchHelper
.
SimpleCallback
(
ItemTouchHelper
.
UP
or
ItemTouchHelper
.
DOWN
,
ItemTouchHelper
.
START
or
ItemTouchHelper
.
END
)
{
...
...
@@ -351,7 +351,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesAdapter
.
move
(
viewHolder
.
adapterPosition
,
target
.
adapterPosition
)
return
true
}
override
fun
clearView
(
recyclerView
:
RecyclerView
?,
viewHolder
:
RecyclerView
.
ViewHolder
?
)
{
override
fun
clearView
(
recyclerView
:
RecyclerView
,
viewHolder
:
RecyclerView
.
ViewHolder
)
{
super
.
clearView
(
recyclerView
,
viewHolder
)
profilesAdapter
.
commitMove
()
}
...
...
@@ -369,13 +369,13 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
val
profiles
=
Profile
.
findAll
(
clipboard
.
primaryClip
.
getItemAt
(
0
).
text
).
toList
()
if
(
profiles
.
isNotEmpty
())
{
profiles
.
forEach
{
ProfileManager
.
createProfile
(
it
)
}
Snackbar
.
make
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_msg
,
Snackbar
.
make
(
requireActivity
()
.
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_msg
,
Snackbar
.
LENGTH_LONG
).
show
()
return
true
}
}
catch
(
_
:
IndexOutOfBoundsException
)
{
}
Snackbar
.
make
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_err
,
Snackbar
.
LENGTH_LONG
)
.
show
()
Snackbar
.
make
(
requireActivity
().
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_err
,
Snackbar
.
LENGTH_LONG
)
.
show
()
true
}
R
.
id
.
action_manual_settings
->
{
...
...
@@ -384,7 +384,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
}
R
.
id
.
action_export
->
{
val
profiles
=
ProfileManager
.
getAllProfiles
()
Snackbar
.
make
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
if
(
profiles
!=
null
)
{
Snackbar
.
make
(
requireActivity
()
.
findViewById
(
R
.
id
.
snackbar
),
if
(
profiles
!=
null
)
{
clipboard
.
primaryClip
=
ClipData
.
newPlainText
(
null
,
profiles
.
joinToString
(
"\n"
))
R
.
string
.
action_export_msg
}
else
R
.
string
.
action_export_err
,
Snackbar
.
LENGTH_LONG
).
show
()
...
...
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
View file @
f218282e
...
...
@@ -80,7 +80,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
private
lateinit
var
positive
:
Button
init
{
val
activity
=
activity
!!
val
activity
=
requireActivity
()
val
view
=
activity
.
layoutInflater
.
inflate
(
R
.
layout
.
dialog_acl_rule
,
null
)
templateSelector
=
view
.
findViewById
(
R
.
id
.
template_selector
)
editText
=
view
.
findViewById
(
R
.
id
.
content
)
...
...
@@ -360,7 +360,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
private
lateinit
var
list
:
RecyclerView
private
var
mode
:
ActionMode
?
=
null
private
lateinit
var
undoManager
:
UndoSnackbarManager
<
Any
>
private
val
clipboard
by
lazy
{
activity
!!
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
}
private
val
clipboard
by
lazy
{
requireContext
()
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
}
private
fun
onSelectedItemsUpdated
()
{
if
(
selectedItems
.
isEmpty
())
mode
?.
finish
()
else
if
(
mode
==
null
)
mode
=
toolbar
.
startActionMode
(
this
)
...
...
@@ -383,12 +383,13 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
toolbar
.
setTitle
(
R
.
string
.
custom_rules
)
toolbar
.
inflateMenu
(
R
.
menu
.
custom_rules_menu
)
toolbar
.
setOnMenuItemClickListener
(
this
)
val
activity
=
requireActivity
()
list
=
view
.
findViewById
(
R
.
id
.
list
)
list
.
layoutManager
=
LinearLayoutManager
(
activity
,
LinearLayoutManager
.
VERTICAL
,
false
)
list
.
itemAnimator
=
DefaultItemAnimator
()
list
.
adapter
=
adapter
view
.
findViewById
<
FastScroller
>(
R
.
id
.
fastscroller
).
setRecyclerView
(
list
)
undoManager
=
UndoSnackbarManager
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
adapter
::
undo
)
undoManager
=
UndoSnackbarManager
(
activity
.
findViewById
(
R
.
id
.
snackbar
),
adapter
::
undo
)
ItemTouchHelper
(
object
:
ItemTouchHelper
.
SimpleCallback
(
0
,
ItemTouchHelper
.
START
or
ItemTouchHelper
.
END
)
{
override
fun
getSwipeDirs
(
recyclerView
:
RecyclerView
,
viewHolder
:
RecyclerView
.
ViewHolder
):
Int
=
if
(
isEnabled
&&
selectedItems
.
isEmpty
())
super
.
getSwipeDirs
(
recyclerView
,
viewHolder
)
else
0
...
...
@@ -439,8 +440,8 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
try
{
adapter
.
addToProxy
(
clipboard
.
primaryClip
.
getItemAt
(
0
).
text
.
toString
())
!=
null
}
catch
(
exc
:
Exception
)
{
Snackbar
.
make
(
activity
!!
.
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_err
,
Snackbar
.
LENGTH_LONG
)
.
show
()
Snackbar
.
make
(
requireActivity
().
findViewById
(
R
.
id
.
snackbar
),
R
.
string
.
action_import_err
,
Snackbar
.
LENGTH_LONG
)
.
show
()
app
.
track
(
exc
)
}
true
...
...
@@ -462,7 +463,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
}
override
fun
onCreateActionMode
(
mode
:
ActionMode
,
menu
:
Menu
):
Boolean
{
val
activity
=
activity
!!
val
activity
=
requireActivity
()
val
window
=
activity
.
window
// In the end material_grey_100 is used for background, see AppCompatDrawableManager (very complicated)
if
(
Build
.
VERSION
.
SDK_INT
>=
23
)
{
...
...
@@ -495,7 +496,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
else
->
false
}
override
fun
onDestroyActionMode
(
mode
:
ActionMode
)
{
val
activity
=
activity
!!
val
activity
=
requireActivity
()
val
window
=
activity
.
window
window
.
statusBarColor
=
ContextCompat
.
getColor
(
activity
,
activity
.
theme
.
resolveResourceId
(
android
.
R
.
attr
.
statusBarColor
))
...
...
mobile/src/main/java/com/github/shadowsocks/preference/BottomSheetPreferenceDialogFragment.kt
View file @
f218282e
...
...
@@ -101,8 +101,8 @@ class BottomSheetPreferenceDialogFragment : PreferenceDialogFragmentCompat() {
private
var
clickedIndex
=
-
1
override
fun
onCreateDialog
(
savedInstanceState
:
Bundle
?):
Dialog
{
val
activity
=
activity
val
dialog
=
BottomSheetDialog
(
activity
!!
,
theme
)
val
activity
=
requireActivity
()
val
dialog
=
BottomSheetDialog
(
activity
,
theme
)
val
recycler
=
RecyclerView
(
activity
)
val
padding
=
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
bottom_sheet_padding
)
recycler
.
setPadding
(
0
,
padding
,
0
,
padding
)
...
...
mobile/src/main/java/com/github/shadowsocks/preference/PluginConfigurationDialogFragment.kt
View file @
f218282e
...
...
@@ -40,8 +40,9 @@ class PluginConfigurationDialogFragment : EditTextPreferenceDialogFragmentCompat
super
.
onPrepareDialogBuilder
(
builder
)
val
intent
=
PluginManager
.
buildIntent
(
arguments
!!
.
getString
(
PLUGIN_ID_FRAGMENT_TAG
),
PluginContract
.
ACTION_HELP
)
if
(
intent
.
resolveActivity
(
activity
!!
.
packageManager
)
!=
null
)
builder
.
setNeutralButton
(
"?"
,
{
_
,
_
->
activity
!!
.
startActivityForResult
(
intent
.
putExtra
(
PluginContract
.
EXTRA_OPTIONS
,
editText
.
text
.
toString
()),
val
activity
=
requireActivity
()
if
(
intent
.
resolveActivity
(
activity
.
packageManager
)
!=
null
)
builder
.
setNeutralButton
(
"?"
,
{
_
,
_
->
activity
.
startActivityForResult
(
intent
.
putExtra
(
PluginContract
.
EXTRA_OPTIONS
,
editText
.
text
.
toString
()),
ProfileConfigActivity
.
REQUEST_CODE_PLUGIN_HELP
)
})
}
...
...
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