Revert "Reuse collator instance"

This reverts commit 90de026e49a02ee42d6d406a19e3807e6786c951.

Close #915, Close #907
This commit is contained in:
MM20 2024-07-03 22:41:33 +02:00
parent 0a90b5621e
commit 3331ea024b
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
3 changed files with 6 additions and 21 deletions

View File

@ -6,7 +6,7 @@ import android.os.Bundle
import de.mm20.launcher2.icons.LauncherIcon
import de.mm20.launcher2.icons.StaticLauncherIcon
import de.mm20.launcher2.ktx.romanize
import de.mm20.launcher2.text.Collator
import java.text.Collator
interface SavableSearchable : Searchable, Comparable<SavableSearchable> {
val key: String
@ -37,7 +37,8 @@ interface SavableSearchable : Searchable, Comparable<SavableSearchable> {
override fun compareTo(other: SavableSearchable): Int {
val label1 = labelOverride ?: label
val label2 = other.labelOverride ?: other.label
return Collator.compare(label1.romanize(), label2.romanize())
return Collator.getInstance().apply { strength = Collator.SECONDARY }
.compare(label1.romanize(), label2.romanize())
}
val domain: String

View File

@ -1,17 +0,0 @@
package de.mm20.launcher2.text
import android.icu.text.Collator
import kotlin.concurrent.getOrSet
private val threadLocalCollator = ThreadLocal.withInitial {
android.icu.text.Collator.getInstance().apply {
strength = android.icu.text.Collator.SECONDARY
}
}
val Collator = threadLocalCollator.getOrSet {
android.icu.text.Collator.getInstance().apply {
strength = android.icu.text.Collator.SECONDARY
}
}

View File

@ -9,9 +9,9 @@ import android.os.Process
import androidx.core.content.getSystemService
import de.mm20.launcher2.ktx.romanize
import de.mm20.launcher2.search.AppProfile
import de.mm20.launcher2.text.Collator
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import java.text.Collator
class AppShortcutConfigActivity(
private val launcherActivityInfo: LauncherActivityInfo,
@ -32,6 +32,7 @@ class AppShortcutConfigActivity(
val label1 = label
val label2 = other.label
return Collator.compare(label1.romanize(), label2.romanize())
return Collator.getInstance().apply { strength = Collator.SECONDARY }
.compare(label1.romanize(), label2.romanize())
}
}