Skip to content

Commit

Permalink
Quick Fix (No PR Needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat committed Mar 21, 2024
1 parent 0d524d7 commit 4422228
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package com.github.hecodes2much.fuzzywuzzy
import com.github.hecodes2much.mlauncher.data.AppModel
import java.util.*

fun scoreApp(app: AppModel, searchChars: String): Int {
fun scoreApp(app: AppModel, searchChars: String, topScore: Int): Int {
val appChars = app.appAlias.ifEmpty { app.appLabel }

val fuzzyScore = calculateFuzzyScore(
normalizeString(appChars),
normalizeString(searchChars)
)

return (fuzzyScore * 99).toInt()
return (fuzzyScore * topScore).toInt()
}

fun normalizeString(input: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.github.hecodes2much.fuzzywuzzy.scoreApp
import com.github.hecodes2much.mlauncher.R
import com.github.hecodes2much.mlauncher.data.AppModel
import com.github.hecodes2much.mlauncher.data.Constants
import com.github.hecodes2much.mlauncher.data.Constants.AppDrawerFlag
import com.github.hecodes2much.mlauncher.data.Prefs
import com.github.hecodes2much.mlauncher.databinding.AdapterAppDrawerBinding
Expand Down Expand Up @@ -90,7 +91,7 @@ class AppDrawerAdapter(

val scoredApps = mutableMapOf<AppModel, Int>()
for (app in appsList) {
scoredApps[app] = scoreApp(app, searchChars)
scoredApps[app] = scoreApp(app, searchChars, Constants.FILTER_STRENGTH_MAX)
}

val filteredApps = if (searchChars.isNotEmpty()) {
Expand Down

0 comments on commit 4422228

Please sign in to comment.