update minSdk to 24, cleanup code (#4014)
closes https://github.com/tuskyapp/Tusky/issues/2607 redo of https://github.com/tuskyapp/Tusky/pull/3593
This commit is contained in:
parent
0768dcd374
commit
7dfc8790c7
16 changed files with 72 additions and 204 deletions
|
|
@ -48,7 +48,7 @@ class ListStatusAccessibilityDelegate(
|
|||
val pos = recyclerView.getChildAdapterPosition(host)
|
||||
val status = statusProvider.getStatus(pos) ?: return
|
||||
if (status is StatusViewData.Concrete) {
|
||||
if (status.spoilerText.isNotEmpty()) {
|
||||
if (status.status.spoilerText.isNotEmpty()) {
|
||||
info.addAction(if (status.isExpanded) collapseCwAction else expandCwAction)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
package com.keylesspalace.tusky.util
|
||||
|
||||
import android.icu.text.BreakIterator
|
||||
import android.text.InputFilter
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
|
|
@ -72,20 +73,10 @@ object SmartLengthInputFilter : InputFilter {
|
|||
if (source[keep].isLetterOrDigit()) {
|
||||
var boundary: Int
|
||||
|
||||
// Android N+ offer a clone of the ICU APIs in Java for better internationalization and
|
||||
// unicode support. Using the ICU version of BreakIterator grants better support for
|
||||
// those without having to add the ICU4J library at a minimum Api trade-off.
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
val iterator = android.icu.text.BreakIterator.getWordInstance()
|
||||
iterator.setText(source.toString())
|
||||
boundary = iterator.following(keep)
|
||||
if (keep - boundary > RUNWAY) boundary = iterator.preceding(keep)
|
||||
} else {
|
||||
val iterator = java.text.BreakIterator.getWordInstance()
|
||||
iterator.setText(source.toString())
|
||||
boundary = iterator.following(keep)
|
||||
if (keep - boundary > RUNWAY) boundary = iterator.preceding(keep)
|
||||
}
|
||||
val iterator = BreakIterator.getWordInstance()
|
||||
iterator.setText(source.toString())
|
||||
boundary = iterator.following(keep)
|
||||
if (keep - boundary > RUNWAY) boundary = iterator.preceding(keep)
|
||||
|
||||
keep = boundary
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package com.keylesspalace.tusky.util
|
||||
|
||||
import android.text.Html.TagHandler
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import androidx.core.text.parseAsHtml
|
||||
|
||||
|
|
@ -36,31 +35,3 @@ fun String.parseAsMastodonHtml(tagHandler: TagHandler? = null): Spanned {
|
|||
* most status contents do, so it should be trimmed. */
|
||||
.trimTrailingWhitespace()
|
||||
}
|
||||
|
||||
fun replaceCrashingCharacters(content: Spanned): Spanned {
|
||||
return replaceCrashingCharacters(content as CharSequence) as Spanned
|
||||
}
|
||||
|
||||
fun replaceCrashingCharacters(content: CharSequence): CharSequence? {
|
||||
var replacing = false
|
||||
var builder: SpannableStringBuilder? = null
|
||||
val length = content.length
|
||||
for (index in 0 until length) {
|
||||
val character = content[index]
|
||||
|
||||
// If there are more than one or two, switch to a map
|
||||
if (character == SOFT_HYPHEN) {
|
||||
if (!replacing) {
|
||||
replacing = true
|
||||
builder = SpannableStringBuilder(content, 0, index)
|
||||
}
|
||||
builder!!.append(ASCII_HYPHEN)
|
||||
} else if (replacing) {
|
||||
builder!!.append(character)
|
||||
}
|
||||
}
|
||||
return if (replacing) builder else content
|
||||
}
|
||||
|
||||
private const val SOFT_HYPHEN = '\u00ad'
|
||||
private const val ASCII_HYPHEN = '-'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue