mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 21:17:38 +00:00
Make scrambled text prettier
This commit is contained in:
parent
19d76b635c
commit
497efc9f5e
@ -1,8 +1,22 @@
|
|||||||
package com.topjohnwu.magisk.extensions
|
package com.topjohnwu.magisk.extensions
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
|
import android.os.Build
|
||||||
|
|
||||||
val specialChars = arrayOf('!', '@', '#', '$', '%', '&', '?')
|
val specialChars = arrayOf('!', '@', '#', '$', '%', '&', '?')
|
||||||
|
val fullSpecialChars = arrayOf('!', '@', '#', '$', '%', '&', '?')
|
||||||
|
|
||||||
|
fun String.isCJK(): Boolean {
|
||||||
|
for (i in 0 until length)
|
||||||
|
if (isCJK(codePointAt(i)))
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isCJK(codepoint: Int): Boolean {
|
||||||
|
return if (Build.VERSION.SDK_INT < 19) false /* Pre 5.0 don't need to be pretty.. */
|
||||||
|
else Character.isIdeographic(codepoint)
|
||||||
|
}
|
||||||
|
|
||||||
fun String.replaceRandomWithSpecial(passes: Int): String {
|
fun String.replaceRandomWithSpecial(passes: Int): String {
|
||||||
var string = this
|
var string = this
|
||||||
@ -13,11 +27,12 @@ fun String.replaceRandomWithSpecial(passes: Int): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun String.replaceRandomWithSpecial(): String {
|
fun String.replaceRandomWithSpecial(): String {
|
||||||
|
val sp = if (isCJK()) fullSpecialChars else specialChars
|
||||||
var random: Char
|
var random: Char
|
||||||
do {
|
do {
|
||||||
random = random()
|
random = random()
|
||||||
} while (random == '.')
|
} while (random == '.')
|
||||||
return replace(random, specialChars.random())
|
return replace(random, sp.random())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun StringBuilder.appendIf(condition: Boolean, builder: StringBuilder.() -> Unit) =
|
fun StringBuilder.appendIf(condition: Boolean, builder: StringBuilder.() -> Unit) =
|
||||||
|
@ -65,9 +65,6 @@ class HomeViewModel(
|
|||||||
val stateMagiskProgress = KObservableField(0)
|
val stateMagiskProgress = KObservableField(0)
|
||||||
val stateManagerProgress = KObservableField(0)
|
val stateManagerProgress = KObservableField(0)
|
||||||
|
|
||||||
val stateMagiskExpanded = KObservableField(false)
|
|
||||||
val stateManagerExpanded = KObservableField(false)
|
|
||||||
|
|
||||||
val stateHideManagerName = R.string.manager.res().let {
|
val stateHideManagerName = R.string.manager.res().let {
|
||||||
if (!statePackageOriginal) {
|
if (!statePackageOriginal) {
|
||||||
it.replaceRandomWithSpecial(3)
|
it.replaceRandomWithSpecial(3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user