aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-16 21:51:01 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-16 21:51:01 +0100
commit86bd13da678b8fa6e6b10cd43c18256cd2fdac19 (patch)
tree0580296f9d29870dad2686fd44a62e0c6ee3ec8f /src/main/java/de
parent0aa694b7a2c070d3b93c8c934b96967071ff68b1 (diff)
Styler: do not style across multiple messages
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/utils/ImStyleParser.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/StylingHelper.java15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/ImStyleParser.java b/src/main/java/de/pixart/messenger/utils/ImStyleParser.java
index 6f65b1552..46f8cec10 100644
--- a/src/main/java/de/pixart/messenger/utils/ImStyleParser.java
+++ b/src/main/java/de/pixart/messenger/utils/ImStyleParser.java
@@ -43,7 +43,7 @@ public class ImStyleParser {
return parse(text, 0, text.length() - 1);
}
- private static List<Style> parse(CharSequence text, int start, int end) {
+ public static List<Style> parse(CharSequence text, int start, int end) {
List<Style> styles = new ArrayList<>();
for (int i = start; i <= end; ++i) {
char c = text.charAt(i);
diff --git a/src/main/java/de/pixart/messenger/utils/StylingHelper.java b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
index b04a1f8a2..1f553b827 100644
--- a/src/main/java/de/pixart/messenger/utils/StylingHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
@@ -45,6 +45,7 @@ import android.widget.EditText;
import java.util.Arrays;
import java.util.List;
+import de.pixart.messenger.entities.Message;
import de.pixart.messenger.ui.text.QuoteSpan;
public class StylingHelper {
@@ -65,8 +66,8 @@ public class StylingHelper {
}
}
- public static void format(final Editable editable, @ColorInt int textColor) {
- for (ImStyleParser.Style style : ImStyleParser.parse(editable)) {
+ public static void format(final Editable editable, int start, int end, @ColorInt int textColor) {
+ for (ImStyleParser.Style style : ImStyleParser.parse(editable, start, end)) {
final int keywordLength = style.getKeyword().length();
editable.setSpan(createSpanForStyle(style), style.getStart() + keywordLength, style.getEnd() - keywordLength + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
makeKeywordOpaque(editable, style.getStart(), style.getStart() + keywordLength, textColor);
@@ -74,6 +75,16 @@ public class StylingHelper {
}
}
+ public static void format(final Editable editable, @ColorInt int textColor) {
+ int end = 0;
+ Message.MergeSeparator[] spans = editable.getSpans(0, editable.length() - 1, Message.MergeSeparator.class);
+ for (Message.MergeSeparator span : spans) {
+ format(editable, end, editable.getSpanStart(span), textColor);
+ end = editable.getSpanEnd(span);
+ }
+ format(editable, end, editable.length() - 1, textColor);
+ }
+
private static ParcelableSpan createSpanForStyle(ImStyleParser.Style style) {
switch (style.getKeyword()) {
case "*":