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
c928dd7f
Unverified
Commit
c928dd7f
authored
Apr 16, 2021
by
Max Lv
Committed by
GitHub
Apr 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add search tool for profiles (#2682)
parent
21ceb3af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+24
-1
mobile/src/main/res/menu/profile_manager_menu.xml
mobile/src/main/res/menu/profile_manager_menu.xml
+4
-0
No files found.
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
c928dd7f
...
...
@@ -37,6 +37,7 @@ import android.widget.ImageView
import
android.widget.TextView
import
androidx.activity.result.ActivityResultLauncher
import
androidx.appcompat.widget.PopupMenu
import
androidx.appcompat.widget.SearchView
import
androidx.appcompat.widget.Toolbar
import
androidx.appcompat.widget.TooltipCompat
import
androidx.core.os.bundleOf
...
...
@@ -64,7 +65,7 @@ import com.google.zxing.WriterException
import
timber.log.Timber
import
java.nio.charset.StandardCharsets
class
ProfilesFragment
:
ToolbarFragment
(),
Toolbar
.
OnMenuItemClickListener
{
class
ProfilesFragment
:
ToolbarFragment
(),
Toolbar
.
OnMenuItemClickListener
,
SearchView
.
OnQueryTextListener
{
companion
object
{
/**
* used for callback from stateChanged from MainActivity
...
...
@@ -237,6 +238,17 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
notifyItemInserted
(
pos
)
}
fun
filter
(
name
:
String
)
{
val
active
=
ProfileManager
.
getActiveProfiles
()
?.
toMutableList
()
?:
mutableListOf
()
profiles
.
clear
()
active
.
forEach
{
if
(
it
.
name
?.
contains
(
name
,
true
)
?:
false
||
it
.
host
.
contains
(
name
,
true
))
{
profiles
.
add
(
it
)
}
}
notifyDataSetChanged
()
}
fun
move
(
from
:
Int
,
to
:
Int
)
{
undoManager
.
flush
()
val
first
=
profiles
[
from
]
...
...
@@ -322,6 +334,13 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
startActivity
(
Intent
(
context
,
ProfileConfigActivity
::
class
.
java
).
putExtra
(
Action
.
EXTRA_PROFILE_ID
,
profile
.
id
))
}
override
fun
onQueryTextChange
(
query
:
String
):
Boolean
{
profilesAdapter
.
filter
(
query
)
return
false
}
override
fun
onQueryTextSubmit
(
query
:
String
):
Boolean
=
false
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
layout_list
,
container
,
false
)
...
...
@@ -331,6 +350,10 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
toolbar
.
setTitle
(
R
.
string
.
profiles
)
toolbar
.
inflateMenu
(
R
.
menu
.
profile_manager_menu
)
toolbar
.
setOnMenuItemClickListener
(
this
)
val
searchView
=
toolbar
.
findViewById
<
SearchView
>(
R
.
id
.
action_search
)
searchView
.
setOnQueryTextListener
(
this
)
searchView
.
setQueryHint
(
getString
(
android
.
R
.
string
.
search_go
))
ProfileManager
.
ensureNotEmpty
()
profilesList
=
view
.
findViewById
(
R
.
id
.
list
)
ViewCompat
.
setOnApplyWindowInsetsListener
(
profilesList
,
MainListListener
)
...
...
mobile/src/main/res/menu/profile_manager_menu.xml
View file @
c928dd7f
...
...
@@ -47,4 +47,8 @@
app:alphabeticModifiers=
"CTRL|SHIFT"
/>
</menu>
</item>
<item
android:id=
"@+id/action_search"
android:title=
"@android:string/search_go"
app:actionViewClass=
"androidx.appcompat.widget.SearchView"
app:showAsAction=
"always"
/>
</menu>
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