DroidWorksStudio/mLauncher

[Question][Maybe Bugreport] Does "Filter Strength" do anything?

Closed this issue · 15 comments

Checklist

  • I will make sure to have the issue written in English with an English title.
  • I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • I have already checked the WIKI pages.
  • I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise.

What is/are your question(s)?

Does the Filter Strength in settings actually do something? No metter the value nothing changes.
I'm not even sure if it should do what I think it does, so let me start by asking:
Filter Strength decides how strict the search term in the app-Drawer is, right?

An Example:
In oLauncher if I type in "fd" F-Droid automatically opens, as there's no other app the has that sequence in the name.
In mLauncher on the other hand, i get a list of F-Droid, foodora AT and Peakfinder. This doesn't change when I change the Filter Strength. It's always the same, doesn't metter if filter-strength is 1, 50 or 99.

Can you enlighten me?
Thank you :)

Additional information

Android,14 mLauncher Version 1.2.1 (which is in the bottom corner, not in the topleft as Github Bugreport suggests).

Terms and Conditions

  • I have read all the rules above and filled in the requiered fields to the best of my ability.
  • I accept that if I fail to follow the rules stated above that I will recieve a 30 day block.

👋 Thanks for reporting!

We will get back to you soon about this issue.

I'll have a look in the morning and get back to you if it's a bug.

I second this, on Android 13 with versions 1.1.2, 1.2.0 and 1.2.1 from FDroid. For me this is the main characteristic of olauncher forks, would love to use this one !

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.

@Lealchimie on version 1.3.5 when i release it this should be fixed. i forgot to do the check and had it only checking 0.0 and not reading that setting sorry for the long time waiting for this.

@HeCodes2Much Thanks for checking ! Testing on 1.4.1, I'm a bit confused about what the setting does :

To illustrate, I try openning F-Droid by typing fd, as in the original issue.

with filter strenght by default on 25

when I type "f", the only app that shows up is FKM. Then if I type "fd", it show f-droid, fedilab and feeder.
Expected behaviour : every app containg '"f" in their title should show, whatever strenght is chosen, then when typing "fd", i should only see those applications with both letters in it at a given distance depending on the value of the filter. Or is it now how it is supposed to work ?

the fact that only fkm shows up when i input "f' makes it impossible to use the autostart applications feature.

with filter strength on 30

same behaviour, only FKM show when i type "f" and then f-droid and feeder with "fd"
Expected behaviour : if the filter strength is higher than before, fedilab should still show with fd but not feeder (since the f and d are farther appart in feeer than in fedilab)

with filter strength on 50

nothing shows up for 'f', 'fd', 'fdr', then fdroid finally shows up with 'fdro'

with filter strength on 99

no application matches "f', nor any other input

an other example of weird behaviour

(with filter strength on 34) : I have both OLauncher and OLauncher Clutter Free installed. When I search for 'Olaunch', only Olauncher shows and if I type 'Olaunche' then both OLauncher and OLauncher clutter free are displayed.

The way it works now seems like you parse a distance from the query and shows words at a distance < something depending on the filter. The expected way, at least for me, is that the number of results should decrease with every new letter I input. It is quite strange to see no results with 'f' but then one result with 'fdro' (or one result with 'f' and 3 results with 'fd'. Or maybe I understand incorrectly, if so could you explain how the filter is intended to work ?

OK so for example...

If you have OLauncher and you have it set to 25 then you would need to do 25% of the word in the order it is seen for example oanch should work as that is more then 25% and its in the order that the letters are.

Below is the function to find the score and topScore is 99 in this case

package com.github.hecodes2much.fuzzywuzzy

import com.github.hecodes2much.mlauncher.data.AppModel
import java.util.*

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 * topScore).toInt()
}

fun normalizeString(input: String): String {
    // Remove diacritical marks and special characters, and convert to uppercase
    return input
        .uppercase(Locale.getDefault())
        .replace(Regex("[\\p{InCombiningDiacriticalMarks}-_+,.]"), "")
}

fun calculateFuzzyScore(s1: String, s2: String): Float {
    val m = s1.length
    val n = s2.length
    var matchCount = 0
    var s1Index = 0

    // Iterate over each character in s2 and check if it exists in s1
    for (c2 in s2) {
        var found = false

        // Start searching for c2 from the current s1Index
        for (j in s1Index until m) {
            if (s1[j] == c2) {
                found = true
                // Update s1Index to the next position for the next iteration
                s1Index = j + 1
                break
            }
        }

        // If the current character in s2 is not found in s1, return a score of 0
        if (!found) {
            return 0f
        }

        // Increment the match count
        matchCount++
    }

    // Calculate the score as the ratio of matched characters to the longer string length
    return matchCount.toFloat() / maxOf(m, n)
}

Ah ok, thanks you for clarifying. I guess it is a different way to think about fuzzy matching than the ones I'm used to (fzf, rofi).

I think it is a very nice feature of OLauncher to have a "strict" search, allowing to quickly launch apps. Would you consider adding an option to choose between strict search (the OLauncher one) instead of fuzzy ?

Would you consider adding an option to choose between strict search (the OLauncher one) instead of fuzzy?

Yes i could take a look at having a toggle in the settings for the different search options.

Ok then, I'll stop commenting the closed issue ! Thanks for your time, I'll check if you decide to add the option :)

PS : You could add a 0% value with this setting on the slider instead of a new button

To be honest 1% will almost always match unless the app name was 90+ characters long.

Can confirm setting to 0 works now, thank you !!!

Can confirm setting to 0 works now, thank you !!!

You are very welcome.