fix toots showing too much whitespace (#1761)

* fix toots showing too much whitespace

* use isWhitespace extension function
This commit is contained in:
Konrad Pozniak 2020-04-20 23:06:39 +02:00 committed by GitHub
commit 89efd67015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 63 deletions

View file

@ -2,7 +2,8 @@
package com.keylesspalace.tusky.util
import java.util.Random
import android.text.Spanned
import java.util.*
private const val POSSIBLE_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -71,3 +72,11 @@ fun String.isLessThan(other: String): Boolean {
else -> this < other
}
}
fun Spanned.trimTrailingWhitespace(): Spanned {
var i = length
do {
i--
} while (i >= 0 && get(i).isWhitespace())
return subSequence(0, i + 1) as Spanned
}