Skip to content

Commit ed61269

Browse files
feat(search): Prioritize app aliases for fuzzy search only
This commit enhances the fuzzy search logic to prioritize user-defined app aliases over the default app labels. The `FuzzyFinder.scoreApp` function now accepts a `Context` to access `Prefs` and retrieve any available alias for an app. If an alias is found, it is used for the search scoring; otherwise, the default `activityLabel` is used. This change ensures that search results more accurately reflect user-customized app names, improving the overall user experience of the app search functionality.
1 parent 3aa41c6 commit ed61269

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/src/main/java/com/github/codeworkscreativehub/fuzzywuzzy/FuzzyFinder.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.codeworkscreativehub.fuzzywuzzy
22

3+
import android.content.Context
34
import com.github.codeworkscreativehub.common.AppLogger
45
import com.github.codeworkscreativehub.mlauncher.data.AppListItem
56
import com.github.codeworkscreativehub.mlauncher.data.ContactListItem
@@ -13,8 +14,11 @@ object FuzzyFinder {
1314
/**
1415
* Scores an AppListItem based on its activity label.
1516
*/
16-
fun scoreApp(app: AppListItem, searchChars: String, topScore: Int): Int {
17-
val appLabel = app.activityLabel
17+
fun scoreApp(context: Context, app: AppListItem, searchChars: String, topScore: Int): Int {
18+
val prefs = Prefs(context)
19+
val appLabel = prefs.getAppAlias(app.activityPackage)
20+
.takeIf { it.isNotBlank() }
21+
?: app.activityLabel
1822
val normalizedAppLabel = normalizeTarget(appLabel)
1923
val normalizedSearchChars = normalizeSearch(searchChars)
2024

app/src/main/java/com/github/codeworkscreativehub/mlauncher/ui/adapter/AppDrawerAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class AppDrawerAdapter(
215215
prefs = Prefs(context),
216216
scoreProvider = { app, q ->
217217
if (isTagSearch) FuzzyFinder.scoreString(app.tag, q, Constants.MAX_FILTER_STRENGTH)
218-
else FuzzyFinder.scoreApp(app, q, Constants.MAX_FILTER_STRENGTH)
218+
else FuzzyFinder.scoreApp(context, app, q, Constants.MAX_FILTER_STRENGTH)
219219
},
220220
labelProvider = { app -> if (isTagSearch) app.tag else app.activityLabel },
221221
loggerTag = "appScore"

0 commit comments

Comments
 (0)