mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix search result styling for formatting and query highlighting.
This commit is contained in:
@@ -321,7 +321,7 @@ public class SearchRepository {
|
||||
BodyRangeList.Builder builder = BodyRangeList.newBuilder();
|
||||
for (BodyRangeList.BodyRange range : bodyRanges.getRangesList()) {
|
||||
int adjustedStart = range.getStart() - startIndex + startOffset;
|
||||
if (adjustedStart >= 0 && adjustedStart + range.getLength() <= cleanSnippet.length()) {
|
||||
if (adjustedStart >= 0 && adjustedStart + range.getLength() <= bodySnippet.length()) {
|
||||
builder.addRanges(range.toBuilder().setStart(adjustedStart).build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ public class SearchUtil {
|
||||
throw new InvalidParameterException("match mode must be STRICT or MATCH_ALL: " + matchMode);
|
||||
}
|
||||
|
||||
CharacterStyle[] styles = styleFactory.createStyles();
|
||||
for (Pair<Integer, Integer> range : ranges) {
|
||||
CharacterStyle[] styles = styleFactory.createStyles();
|
||||
for (CharacterStyle style : styles) {
|
||||
List<Annotation> annotations = SpoilerAnnotation.getSpoilerAnnotations(spanned, range.first(), range.second());
|
||||
if (annotations.isEmpty()) {
|
||||
spanned.setSpan(style, range.first(), range.second(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
spanned.setSpan(style, range.first(), range.second(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user