diff --git a/app/src/main/java/io/github/dovecoteescapee/byedpi/fragments/VpnAppsFilterFragment.kt b/app/src/main/java/io/github/dovecoteescapee/byedpi/fragments/VpnAppsFilterFragment.kt index 282c307..e05c5af 100644 --- a/app/src/main/java/io/github/dovecoteescapee/byedpi/fragments/VpnAppsFilterFragment.kt +++ b/app/src/main/java/io/github/dovecoteescapee/byedpi/fragments/VpnAppsFilterFragment.kt @@ -13,6 +13,7 @@ import androidx.core.content.edit import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -20,6 +21,9 @@ import io.github.dovecoteescapee.byedpi.adapters.AppItemAdapter import io.github.dovecoteescapee.byedpi.R import io.github.dovecoteescapee.byedpi.databinding.FragmentFilterBinding import io.github.dovecoteescapee.byedpi.utility.getPreferences +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext class VpnAppsFilterFragment : Fragment(), MenuProvider { @@ -67,16 +71,13 @@ class VpnAppsFilterFragment : Fragment(), MenuProvider { binding.appList.adapter = adapter - Thread { - apps = collectApps() + lifecycleScope.launch { + apps = withContext(Dispatchers.IO) { collectApps() } + adapter.setList(apps) - activity.runOnUiThread { - adapter.setList(apps) - - binding.progressCircular.visibility = View.GONE - binding.appList.visibility = View.VISIBLE - } - }.start() + binding.progressCircular.visibility = View.GONE + binding.appList.visibility = View.VISIBLE + } requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) @@ -113,6 +114,7 @@ class VpnAppsFilterFragment : Fragment(), MenuProvider { return false } }) + searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { override fun onMenuItemActionExpand(item: MenuItem): Boolean { return true diff --git a/app/src/main/java/io/github/dovecoteescapee/byedpi/services/ByeDpiVpnService.kt b/app/src/main/java/io/github/dovecoteescapee/byedpi/services/ByeDpiVpnService.kt index bf62626..feb7241 100644 --- a/app/src/main/java/io/github/dovecoteescapee/byedpi/services/ByeDpiVpnService.kt +++ b/app/src/main/java/io/github/dovecoteescapee/byedpi/services/ByeDpiVpnService.kt @@ -308,6 +308,7 @@ class ByeDpiVpnService : LifecycleVpnService() { } builder.addDisallowedApplication(applicationContext.packageName) } + "whitelist" -> { filter.forEach { try { @@ -315,6 +316,7 @@ class ByeDpiVpnService : LifecycleVpnService() { } catch (ignore: PackageManager.NameNotFoundException) {} } } + else -> { Log.w(TAG, "Invalid VPN filter mode: $filterMode") }