Commit cbe5b1e3 authored by Mygod's avatar Mygod

Refine search to respect locale

parent a98ab6df
...@@ -239,11 +239,11 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, Sea ...@@ -239,11 +239,11 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, Sea
fun filter(name: String) { fun filter(name: String) {
val active = ProfileManager.getActiveProfiles()?.toMutableList() ?: mutableListOf() val active = ProfileManager.getActiveProfiles()?.toMutableList() ?: mutableListOf()
profiles.clear() profiles.clear()
active.forEach { val locale = resources.configuration.locale
if (it.name?.contains(name, true) ?: false || it.host.contains(name, true)) { val lower = name.lowercase(locale)
profiles.add(it) profiles.addAll(active.filter {
} it.name?.lowercase(locale)?.contains(lower) == true || it.host.lowercase(locale).contains(lower)
} })
notifyDataSetChanged() notifyDataSetChanged()
} }
...@@ -350,7 +350,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, Sea ...@@ -350,7 +350,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, Sea
toolbar.setOnMenuItemClickListener(this) toolbar.setOnMenuItemClickListener(this)
val searchView = toolbar.findViewById<SearchView>(R.id.action_search) val searchView = toolbar.findViewById<SearchView>(R.id.action_search)
searchView.setOnQueryTextListener(this) searchView.setOnQueryTextListener(this)
searchView.setQueryHint(getString(android.R.string.search_go)) searchView.queryHint = getString(android.R.string.search_go)
ProfileManager.ensureNotEmpty() ProfileManager.ensureNotEmpty()
profilesList = view.findViewById(R.id.list) profilesList = view.findViewById(R.id.list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment