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,7 +1,25 @@
package de.mm20.launcher2.ktx
import com.github.promeg.pinyinhelper.Pinyin
import java.net.URLDecoder
import java.util.*
fun String.decodeUrl(charset: String): String? {
return URLDecoder.decode(this, charset)
}
/**
* Normalize a string to lowercase ASCII
* TODO: Only supports Chinese/Pinyin at the moment
*/
fun String.normalize(): String {
return this.romanize().lowercase(Locale.getDefault())
}
/**
* Romanize a string, transliterate non-latin characters into latin
* TODO: Only supports Chinese/Pinyin at the moment
*/
fun String.romanize(): String {
return Pinyin.toPinyin(this, "")
}