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
341c8504
Commit
341c8504
authored
Jan 07, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fast scroller to custom rules and per-app proxy config
parent
35d76115
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
22 deletions
+87
-22
build.sbt
build.sbt
+1
-0
src/main/res/layout/layout_apps.xml
src/main/res/layout/layout_apps.xml
+16
-4
src/main/res/layout/layout_apps_item.xml
src/main/res/layout/layout_apps_item.xml
+1
-1
src/main/res/layout/layout_custom_rules.xml
src/main/res/layout/layout_custom_rules.xml
+28
-0
src/main/res/layout/layout_list.xml
src/main/res/layout/layout_list.xml
+1
-2
src/main/res/values/styles.xml
src/main/res/values/styles.xml
+5
-0
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+19
-3
src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
...cala/com/github/shadowsocks/acl/CustomRulesFragment.scala
+16
-2
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+0
-10
No files found.
build.sbt
View file @
341c8504
...
...
@@ -37,6 +37,7 @@ libraryDependencies ++=
"com.android.support"
%
"design"
%
"25.1.0"
::
"com.android.support"
%
"gridlayout-v7"
%
"25.1.0"
::
"com.android.support"
%
"preference-v14"
%
"25.1.0"
::
"com.futuremind.recyclerfastscroll"
%
"fastscroll"
%
"0.2.5"
::
"com.evernote"
%
"android-job"
%
"1.1.3"
::
"com.github.jorgecastilloprz"
%
"fabprogresscircle"
%
"1.01"
::
"com.google.android.gms"
%
"play-services-ads"
%
"10.0.1"
::
...
...
src/main/res/layout/layout_apps.xml
View file @
341c8504
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
...
...
@@ -19,7 +20,7 @@
android:textSize=
"18sp"
android:textColor=
"?android:attr/textColorSecondary"
android:paddingStart=
"60dp"
android:paddingEnd=
"
8
dp"
android:paddingEnd=
"
16
dp"
android:paddingTop=
"12dp"
android:paddingBottom=
"12dp"
android:layout_width=
"match_parent"
...
...
@@ -30,7 +31,7 @@
android:textSize=
"18sp"
android:textColor=
"?android:attr/textColorSecondary"
android:paddingStart=
"60dp"
android:paddingEnd=
"
8
dp"
android:paddingEnd=
"
16
dp"
android:paddingTop=
"12dp"
android:paddingBottom=
"12dp"
android:layout_width=
"match_parent"
...
...
@@ -46,8 +47,19 @@
<android.support.v7.widget.RecyclerView
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:id=
"@+id/applistview"
android:scrollbars=
"vertical"
android:id=
"@+id/list"
android:visibility=
"gone"
/>
<com.futuremind.recyclerviewfastscroll.FastScroller
android:id=
"@+id/fastscroller"
android:orientation=
"vertical"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"end"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"8dp"
android:visibility=
"gone"
app:fastscroll__handleColor=
"@color/material_primary_500"
app:fastscroll__bubbleColor=
"@color/material_primary_500"
app:fastscroll__bubbleTextAppearance=
"@style/StyledScrollerTextAppearance"
/>
</FrameLayout>
</LinearLayout>
src/main/res/layout/layout_apps_item.xml
View file @
341c8504
...
...
@@ -28,6 +28,6 @@
android:focusable=
"false"
android:focusableInTouchMode=
"false"
android:clickable=
"false"
android:layout_marginEnd=
"
8
dp"
/>
android:layout_marginEnd=
"
16
dp"
/>
</LinearLayout>
src/main/res/layout/layout_custom_rules.xml
0 → 100644
View file @
341c8504
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/toolbar_light_dark"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"32dp"
android:clipToPadding=
"false"
/>
<com.futuremind.recyclerviewfastscroll.FastScroller
android:id=
"@+id/fastscroller"
android:orientation=
"vertical"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"end"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"32dp"
app:fastscroll__handleColor=
"@color/material_primary_500"
app:fastscroll__bubbleColor=
"@color/material_primary_500"
app:fastscroll__bubbleTextAppearance=
"@style/StyledScrollerTextAppearance"
/>
</FrameLayout>
</LinearLayout>
src/main/res/layout/layout_list.xml
View file @
341c8504
...
...
@@ -4,8 +4,7 @@
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/toolbar_light_dark"
/>
<android.support.v7.widget.RecyclerView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/list"
<android.support.v7.widget.RecyclerView
android:id=
"@+id/list"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
...
...
src/main/res/values/styles.xml
View file @
341c8504
...
...
@@ -49,5 +49,10 @@
<style
name=
"NumberPickerStyle"
>
<item
name=
"android:textSize"
>
14sp
</item>
</style>
<style
name=
"StyledScrollerTextAppearance"
parent=
"@android:style/TextAppearance"
>
<item
name=
"android:textSize"
>
24sp
</item>
<item
name=
"android:textStyle"
>
bold
</item>
<item
name=
"android:textColor"
>
@android:color/white
</item>
</style>
</resources>
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
341c8504
...
...
@@ -23,6 +23,7 @@ package com.github.shadowsocks
import
java.util.concurrent.atomic.AtomicBoolean
import
android.Manifest.permission
import
android.animation.
{
Animator
,
AnimatorListenerAdapter
}
import
android.app.TaskStackBuilder
import
android.content._
import
android.content.pm.PackageManager
...
...
@@ -33,6 +34,7 @@ import android.support.v7.widget.Toolbar.OnMenuItemClickListener
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.view._
import
android.widget._
import
com.futuremind.recyclerviewfastscroll.
{
FastScroller
,
SectionTitleProvider
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.
{
Key
,
Utils
}
...
...
@@ -102,7 +104,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
}
}
private
final
class
AppsAdapter
extends
RecyclerView
.
Adapter
[
AppViewHolder
]
{
private
final
class
AppsAdapter
extends
RecyclerView
.
Adapter
[
AppViewHolder
]
with
SectionTitleProvider
{
private
val
apps
=
getApps
(
getPackageManager
).
sortWith
((
a
,
b
)
=>
{
val
aProxied
=
proxiedApps
.
contains
(
a
.
packageName
)
if
(
aProxied
^
proxiedApps
.
contains
(
b
.
packageName
))
aProxied
else
a
.
name
.
compareToIgnoreCase
(
b
.
name
)
<
0
...
...
@@ -112,12 +114,14 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
def
onBindViewHolder
(
vh
:
AppViewHolder
,
i
:
Int
)
:
Unit
=
vh
.
bind
(
apps
(
i
))
def
onCreateViewHolder
(
vg
:
ViewGroup
,
i
:
Int
)
=
new
AppViewHolder
(
LayoutInflater
.
from
(
vg
.
getContext
).
inflate
(
R
.
layout
.
layout_apps_item
,
vg
,
false
))
def
getSectionTitle
(
i
:
Int
)
:
String
=
apps
(
i
).
name
.
substring
(
0
,
1
)
}
private
var
proxiedApps
:
mutable.HashSet
[
String
]
=
_
private
var
toolbar
:
Toolbar
=
_
private
var
bypassSwitch
:
Switch
=
_
private
var
appListView
:
RecyclerView
=
_
private
var
fastScroller
:
FastScroller
=
_
private
var
loadingView
:
View
=
_
private
val
appsLoading
=
new
AtomicBoolean
private
var
handler
:
Handler
=
_
...
...
@@ -170,6 +174,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
app
.
editor
.
putString
(
Key
.
individual
,
apps
).
putBoolean
(
Key
.
dirty
,
true
).
apply
()
Toast
.
makeText
(
this
,
R
.
string
.
action_import_msg
,
Toast
.
LENGTH_SHORT
).
show
()
appListView
.
setVisibility
(
View
.
GONE
)
fastScroller
.
setVisibility
(
View
.
GONE
)
loadingView
.
setVisibility
(
View
.
VISIBLE
)
initProxiedApps
(
apps
)
reloadApps
()
...
...
@@ -220,9 +225,11 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
initProxiedApps
()
loadingView
=
findViewById
(
R
.
id
.
loading
)
appListView
=
findViewById
(
R
.
id
.
applistview
).
asInstanceOf
[
RecyclerView
]
appListView
=
findViewById
(
R
.
id
.
list
).
asInstanceOf
[
RecyclerView
]
appListView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
))
appListView
.
setItemAnimator
(
new
DefaultItemAnimator
)
fastScroller
=
findViewById
(
R
.
id
.
fastscroller
).
asInstanceOf
[
FastScroller
]
fastScroller
.
setRecyclerView
(
appListView
)
instance
=
this
loadAppsAsync
()
...
...
@@ -239,7 +246,16 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
}
while
(!
appsLoading
.
compareAndSet
(
true
,
false
))
handler
.
post
(()
=>
{
appListView
.
setAdapter
(
adapter
)
Utils
.
crossFade
(
AppManager
.
this
,
loadingView
,
appListView
)
val
shortAnimTime
=
getResources
.
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
)
appListView
.
setAlpha
(
0
)
appListView
.
setVisibility
(
View
.
VISIBLE
)
appListView
.
animate
().
alpha
(
1
).
setDuration
(
shortAnimTime
)
fastScroller
.
setAlpha
(
0
)
fastScroller
.
setVisibility
(
View
.
VISIBLE
)
fastScroller
.
animate
().
alpha
(
1
).
setDuration
(
shortAnimTime
)
loadingView
.
animate
().
alpha
(
0
).
setDuration
(
shortAnimTime
).
setListener
(
new
AnimatorListenerAdapter
{
override
def
onAnimationEnd
(
animation
:
Animator
)
:
Unit
=
loadingView
.
setVisibility
(
View
.
GONE
)
})
})
}
}
...
...
src/main/scala/com/github/shadowsocks/acl/CustomRulesFragment.scala
View file @
341c8504
...
...
@@ -12,6 +12,7 @@ import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
import
android.support.v7.widget.
{
DefaultItemAnimator
,
LinearLayoutManager
,
RecyclerView
,
Toolbar
}
import
android.view._
import
android.widget.
{
EditText
,
Spinner
,
TextView
,
Toast
}
import
com.futuremind.recyclerviewfastscroll.
{
FastScroller
,
SectionTitleProvider
}
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.State
import
com.github.shadowsocks.widget.UndoSnackbarManager
...
...
@@ -103,7 +104,7 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
}
}
private
final
class
AclRulesAdapter
extends
RecyclerView
.
Adapter
[
AclRuleViewHolder
]
{
private
final
class
AclRulesAdapter
extends
RecyclerView
.
Adapter
[
AclRuleViewHolder
]
with
SectionTitleProvider
{
private
val
acl
=
Acl
.
customRules
private
var
savePending
:
Boolean
=
_
private
def
apply
()
=
if
(!
savePending
)
{
...
...
@@ -192,6 +193,17 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
onSelectedItemsUpdated
()
notifyDataSetChanged
()
}
def
getSectionTitle
(
i
:
Int
)
:
String
=
{
val
j
=
i
-
acl
.
subnets
.
size
(
if
(
j
<
0
)
acl
.
subnets
(
i
).
address
.
toString
.
charAt
(
0
).
toString
else
{
val
hostname
=
acl
.
proxyHostnames
(
i
)
PATTERN_DOMAIN
.
findFirstMatchIn
(
hostname
)
match
{
case
Some
(
m
)
=>
m
.
matched
.
replaceAll
(
"\\\\."
,
"."
)
// don't convert IDN yet
case
None
=>
hostname
}
}).
substring
(
0
,
1
)
}
}
private
lazy
val
adapter
=
new
AclRulesAdapter
()
...
...
@@ -201,7 +213,7 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
private
lazy
val
clipboard
=
getActivity
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
).
asInstanceOf
[
ClipboardManager
]
override
def
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
,
savedInstanceState
:
Bundle
)
:
View
=
inflater
.
inflate
(
R
.
layout
.
layout_
list
,
container
,
false
)
inflater
.
inflate
(
R
.
layout
.
layout_
custom_rules
,
container
,
false
)
override
def
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
if
(
savedInstanceState
!=
null
)
{
...
...
@@ -224,6 +236,8 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
list
.
setLayoutManager
(
new
LinearLayoutManager
(
getActivity
,
LinearLayoutManager
.
VERTICAL
,
false
))
list
.
setItemAnimator
(
new
DefaultItemAnimator
)
list
.
setAdapter
(
adapter
)
val
fastScroller
=
view
.
findViewById
(
R
.
id
.
fastscroller
).
asInstanceOf
[
FastScroller
]
fastScroller
.
setRecyclerView
(
list
)
undoManager
=
new
UndoSnackbarManager
[
AnyRef
](
getActivity
.
findViewById
(
R
.
id
.
snackbar
),
adapter
.
undo
)
new
ItemTouchHelper
(
new
SimpleCallback
(
0
,
ItemTouchHelper
.
START
|
ItemTouchHelper
.
END
)
{
override
def
getSwipeDirs
(
recyclerView
:
RecyclerView
,
viewHolder
:
ViewHolder
)
:
Int
=
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
341c8504
...
...
@@ -82,16 +82,6 @@ object Utils {
toast
}
def
crossFade
(
context
:
Context
,
from
:
View
,
to
:
View
)
{
def
shortAnimTime
=
context
.
getResources
.
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
)
to
.
setAlpha
(
0
)
to
.
setVisibility
(
View
.
VISIBLE
)
to
.
animate
().
alpha
(
1
).
setDuration
(
shortAnimTime
)
from
.
animate
().
alpha
(
0
).
setDuration
(
shortAnimTime
).
setListener
(
new
AnimatorListenerAdapter
{
override
def
onAnimationEnd
(
animation
:
Animator
)
:
Unit
=
from
.
setVisibility
(
View
.
GONE
)
})
}
def
readAllLines
(
f
:
File
)
:
String
=
{
val
scanner
=
new
Scanner
(
f
)
try
{
...
...
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