Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
497efc9f
Commit
497efc9f
authored
Jan 30, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make scrambled text prettier
parent
19d76b63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
XString.kt
app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt
+18
-3
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+0
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/extensions/XString.kt
View file @
497efc9f
package
com.topjohnwu.magisk.extensions
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
{
var
string
=
this
...
...
@@ -13,11 +27,12 @@ fun String.replaceRandomWithSpecial(passes: Int): String {
}
fun
String
.
replaceRandomWithSpecial
():
String
{
val
sp
=
if
(
isCJK
())
fullSpecialChars
else
specialChars
var
random
:
Char
do
{
random
=
random
()
}
while
(
random
==
'.'
)
return
replace
(
random
,
sp
ecialChars
.
random
())
return
replace
(
random
,
sp
.
random
())
}
fun
StringBuilder
.
appendIf
(
condition
:
Boolean
,
builder
:
StringBuilder
.()
->
Unit
)
=
...
...
@@ -34,4 +49,4 @@ fun String.legalFilename() = replace(" ", "_").replace("'", "").replace("\"", ""
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"*"
,
""
).
replace
(
"/"
,
"_"
)
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"\\"
,
"_"
)
fun
String
.
isEmptyInternal
()
=
isNullOrBlank
()
\ No newline at end of file
fun
String
.
isEmptyInternal
()
=
isNullOrBlank
()
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
497efc9f
...
...
@@ -65,9 +65,6 @@ class HomeViewModel(
val
stateMagiskProgress
=
KObservableField
(
0
)
val
stateManagerProgress
=
KObservableField
(
0
)
val
stateMagiskExpanded
=
KObservableField
(
false
)
val
stateManagerExpanded
=
KObservableField
(
false
)
val
stateHideManagerName
=
R
.
string
.
manager
.
res
().
let
{
if
(!
statePackageOriginal
)
{
it
.
replaceRandomWithSpecial
(
3
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment