From 7cddab41d98dd98d32979d0b9eb7b7bf719a1739 Mon Sep 17 00:00:00 2001 From: HellPie Date: Wed, 5 Sep 2018 23:59:13 +0200 Subject: [PATCH] Fix spannable losing spans when collapsed and restore length to 500 characters --- .../keylesspalace/tusky/util/SmartLengthInputFilter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.java b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.java index 3f92c2309..7fa6821b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.java @@ -17,6 +17,7 @@ package com.keylesspalace.tusky.util; import android.text.InputFilter; +import android.text.SpannableStringBuilder; import android.text.Spanned; import java.text.BreakIterator; @@ -40,7 +41,7 @@ public class SmartLengthInputFilter implements InputFilter { * Default for maximum status length on Mastodon and default collapsing * length on Pleroma. */ - public static final int LENGTH_DEFAULT = 50; + public static final int LENGTH_DEFAULT = 500; private final int max; private final boolean allowRunway; @@ -135,6 +136,10 @@ public class SmartLengthInputFilter implements InputFilter { if(keep == start) return ""; } - return source.subSequence(start, keep) + "…"; + if(source instanceof Spanned) { + return new SpannableStringBuilder(source, start, keep).append("…"); + } else { + return source.subSequence(start, keep) + "…"; + } } }