Fix spannable losing spans when collapsed and restore length to 500 characters

This commit is contained in:
HellPie 2018-09-05 23:59:13 +02:00 committed by HellPie
parent ba7ccf97de
commit 7cddab41d9
1 changed files with 7 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package com.keylesspalace.tusky.util; package com.keylesspalace.tusky.util;
import android.text.InputFilter; import android.text.InputFilter;
import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import java.text.BreakIterator; import java.text.BreakIterator;
@ -40,7 +41,7 @@ public class SmartLengthInputFilter implements InputFilter {
* Default for maximum status length on Mastodon and default collapsing * Default for maximum status length on Mastodon and default collapsing
* length on Pleroma. * length on Pleroma.
*/ */
public static final int LENGTH_DEFAULT = 50; public static final int LENGTH_DEFAULT = 500;
private final int max; private final int max;
private final boolean allowRunway; private final boolean allowRunway;
@ -135,6 +136,10 @@ public class SmartLengthInputFilter implements InputFilter {
if(keep == start) return ""; if(keep == start) return "";
} }
if(source instanceof Spanned) {
return new SpannableStringBuilder(source, start, keep).append("");
} else {
return source.subSequence(start, keep) + ""; return source.subSequence(start, keep) + "";
} }
} }
}