Sort chinese apps by their pinyin transliteration

Close #61
This commit is contained in:
MM20
2022-06-12 15:50:05 +02:00
parent a064e800b6
commit b436f75f17
7 changed files with 40 additions and 24 deletions
@@ -1,13 +1,12 @@
package de.mm20.launcher2.search.data
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import de.mm20.launcher2.icons.LauncherIcon
import de.mm20.launcher2.ktx.romanize
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.preferences.Settings
import de.mm20.launcher2.preferences.Settings.IconSettings.LegacyIconBackground
import de.mm20.launcher2.search.R
import java.text.Collator
@@ -26,16 +25,26 @@ abstract class Searchable : Comparable<Searchable> {
return if (context.tryStartActivity(intent, options)) {
true
} else {
Toast.makeText(context, context.getString(R.string.error_activity_not_found, label), Toast.LENGTH_SHORT).show()
Toast.makeText(
context,
context.getString(R.string.error_activity_not_found, label),
Toast.LENGTH_SHORT
).show()
false
}
}
open suspend fun loadIcon(context: Context, size: Int, legacyIconBackground: LegacyIconBackground): LauncherIcon? = null
open suspend fun loadIcon(
context: Context,
size: Int,
legacyIconBackground: LegacyIconBackground
): LauncherIcon? = null
abstract fun getPlaceholderIcon(context: Context): LauncherIcon
override fun compareTo(other: Searchable): Int {
return Collator.getInstance().apply { strength = Collator.SECONDARY }.compare(label, other.label)
return Collator.getInstance().apply { strength = Collator.SECONDARY }
.compare(label.romanize(), other.label.romanize())
}
override fun equals(other: Any?): Boolean {