mirror of
https://github.com/oxen-io/session-android.git
synced 2025-07-16 22:58:40 +00:00
Do not parse public key to a number if it's shorter than 12 chars.
This commit is contained in:
parent
ad67f478c8
commit
f9b1166587
@ -19,11 +19,10 @@ object AvatarPlaceholderGenerator {
|
|||||||
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
|
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
|
||||||
//TODO That should be replaced with a proper hash extraction code.
|
//TODO That should be replaced with a proper hash extraction code.
|
||||||
val hash: Long
|
val hash: Long
|
||||||
val hexRegex = Regex("^[0-9A-Fa-f]+\$")
|
if (hashString.length >= 12 && hashString.matches(Regex("^[0-9A-Fa-f]+\$"))) {
|
||||||
if (hashString.length >= 12 && hashString.matches(hexRegex)) {
|
|
||||||
hash = hashString.substring(0 until 12).toLong(16)
|
hash = hashString.substring(0 until 12).toLong(16)
|
||||||
} else {
|
} else {
|
||||||
hash = hashString.toLong(16)
|
hash = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not cache color array, it may be different depends on the current theme.
|
// Do not cache color array, it may be different depends on the current theme.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user