mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
Added search back as it was
This commit is contained in:
parent
ef59d905ab
commit
7d540aa76d
2 changed files with 16 additions and 24 deletions
|
|
@ -160,7 +160,7 @@ class AppMenuActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener,
|
||||||
if (cleanQuery.isNullOrEmpty()) {
|
if (cleanQuery.isNullOrEmpty()) {
|
||||||
filteredApps.addAll(installedApps)
|
filteredApps.addAll(installedApps)
|
||||||
} else {
|
} else {
|
||||||
installedApps.forEach {
|
installedApps.forEachIndexed {index, it ->
|
||||||
val cleanItemText = sharedPreferenceManager.getAppName(this@AppMenuActivity, it.first.applicationInfo.packageName, it.second.second, it.first.applicationInfo.loadLabel(packageManager)).toString().clean()
|
val cleanItemText = sharedPreferenceManager.getAppName(this@AppMenuActivity, it.first.applicationInfo.packageName, it.second.second, it.first.applicationInfo.loadLabel(packageManager)).toString().clean()
|
||||||
if (cleanItemText.contains(cleanQuery, ignoreCase = true)) {
|
if (cleanItemText.contains(cleanQuery, ignoreCase = true)) {
|
||||||
filteredApps.add(it)
|
filteredApps.add(it)
|
||||||
|
|
@ -168,7 +168,7 @@ class AppMenuActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
//adapter.updateApps(filteredApps)
|
adapter.updateAllApps(filteredApps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,33 +210,16 @@ class AppMenuActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener,
|
||||||
job = CoroutineScope(Dispatchers.Default).launch {
|
job = CoroutineScope(Dispatchers.Default).launch {
|
||||||
while (true) {
|
while (true) {
|
||||||
val updatedApps = getInstalledApps()
|
val updatedApps = getInstalledApps()
|
||||||
if (!listsEqual(installedApps, updatedApps)) {
|
|
||||||
val changes = detectChanges(installedApps, updatedApps)
|
val changes = detectChanges(installedApps, updatedApps)
|
||||||
installedApps = updatedApps
|
installedApps = updatedApps
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
applyChanges(changes, installedApps)
|
applyChanges(changes, installedApps)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
delay(5000)
|
delay(5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listsEqual(
|
|
||||||
list1: List<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>,
|
|
||||||
list2: List<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>
|
|
||||||
): Boolean {
|
|
||||||
if (list1.size != list2.size) return false
|
|
||||||
|
|
||||||
for (i in list1.indices) {
|
|
||||||
if (list1[i].first.componentName != list2[i].first.componentName || list1[i].second.first != list2[i].second.first) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Change(val type: ChangeType, val position: Int)
|
data class Change(val type: ChangeType, val position: Int)
|
||||||
|
|
||||||
enum class ChangeType {
|
enum class ChangeType {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.ottop.yamlauncher
|
package eu.ottop.yamlauncher
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.LauncherActivityInfo
|
import android.content.pm.LauncherActivityInfo
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
|
|
@ -67,6 +68,7 @@ class AppMenuAdapter(
|
||||||
itemClickListener.onItemClick(app, apps[position].second.first)
|
itemClickListener.onItemClick(app, apps[position].second.first)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuMode == "app") {
|
if (menuMode == "app") {
|
||||||
textView.setOnLongClickListener {
|
textView.setOnLongClickListener {
|
||||||
val position = bindingAdapterPosition
|
val position = bindingAdapterPosition
|
||||||
|
|
@ -135,4 +137,11 @@ class AppMenuAdapter(
|
||||||
fun updateApp(position: Int, app: Pair<LauncherActivityInfo, Pair<UserHandle, Int>>) {
|
fun updateApp(position: Int, app: Pair<LauncherActivityInfo, Pair<UserHandle, Int>>) {
|
||||||
apps[position] = app
|
apps[position] = app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
fun updateAllApps(newApps: List<Pair<LauncherActivityInfo, Pair<UserHandle, Int>>>) {
|
||||||
|
apps.clear()
|
||||||
|
apps.addAll(newApps)
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue