Fix a few crashes on search functions, remove useless permissions, update translations

This commit is contained in:
frknkrc44 2025-09-12 17:30:44 +03:00 • committed by Cuynu
commit 4942a02337
4 changed files with 28 additions and 11 deletions

View file

@ -6,8 +6,6 @@
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="icu.nullptr.hidemyapplist.MyApp"
android:allowBackup="true"

View file

@ -21,7 +21,7 @@ abstract class AppSelectAdapter(
private inner class AppFilter : Filter() {
override fun performFiltering(constraint: CharSequence): FilterResults {
return runBlocking {
val constraintLowered = constraint.toString().lowercase()
val constraintLowered = constraint.toString().trim().lowercase()
val filteredList = PackageHelper.appList.first().filter {
if (firstFilter?.invoke(it) == false) return@filter false
if (!PrefManager.appFilter_showSystem && PackageHelper.isSystem(it)) return@filter false
@ -38,8 +38,11 @@ abstract class AppSelectAdapter(
@Suppress("UNCHECKED_CAST", "NotifyDataSetChanged")
override fun publishResults(constraint: CharSequence, results: FilterResults) {
filteredList = results.values as List<String>
notifyDataSetChanged()
val values = results.values
if (values != null) {
filteredList = values as List<String>
notifyDataSetChanged()
}
}
}

View file

@ -175,8 +175,14 @@ abstract class AppSelectFragment : Fragment(R.layout.fragment_app_select) {
}
}
val atLeastEntryCount: Int get() {
if (!search.isBlank()) return 0
return if (fragmentType < 2) 1 else 2
}
private fun checkIfEmpty() {
val emptyViewVisible = recyclerView.adapter!!.itemCount < if (fragmentType < 2) 1 else 2
val emptyViewVisible = recyclerView.adapter!!.itemCount < atLeastEntryCount
emptyView.visibility = if (emptyViewVisible) View.VISIBLE else View.GONE
if (emptyViewVisible) {
emptyView.findViewById<TextView>(R.id.list_empty_text).text = getString(

View file

@ -40,11 +40,18 @@ class AppPresetAdapter(
override fun performFiltering(constraint: CharSequence): FilterResults {
return runBlocking {
val constraintLowered = constraint.toString().lowercase()
val constraintLowered = constraint.toString().trim().lowercase()
val filteredList = packages.filter {
if (constraintLowered.isEmpty()) return@filter true
val label = PackageHelper.loadAppLabel(it)
label.lowercase().contains(constraintLowered) || it.lowercase().contains(constraintLowered)
if (it.lowercase().contains(constraintLowered)) return@filter true
try {
val label = PackageHelper.loadAppLabel(it)
return@filter label.lowercase().contains(constraintLowered)
} catch (e: Throwable) {
return@filter false
}
}
FilterResults().also { it.values = filteredList }
@ -53,8 +60,11 @@ class AppPresetAdapter(
@Suppress("UNCHECKED_CAST", "NotifyDataSetChanged")
override fun publishResults(constraint: CharSequence, results: FilterResults) {
filteredList = results.values as List<String>
notifyDataSetChanged()
val values = results.values
if (values != null) {
filteredList = values as List<String>
notifyDataSetChanged()
}
}
}