mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 16:19:33 +01:00
Add text formatting send and receive support for conversations.
This commit is contained in:
committed by
Greyson Parrelli
parent
aa2075c78f
commit
cc490f4b73
@@ -104,6 +104,7 @@ public final class FeatureFlags {
|
||||
private static final String CHAT_FILTERS = "android.chat.filters.3";
|
||||
private static final String PAYPAL_ONE_TIME_DONATIONS = "android.oneTimePayPalDonations.2";
|
||||
private static final String PAYPAL_RECURRING_DONATIONS = "android.recurringPayPalDonations.2";
|
||||
private static final String TEXT_FORMATTING = "android.textFormatting";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
@@ -158,7 +159,8 @@ public final class FeatureFlags {
|
||||
CDS_HARD_LIMIT,
|
||||
CHAT_FILTERS,
|
||||
PAYPAL_ONE_TIME_DONATIONS,
|
||||
PAYPAL_RECURRING_DONATIONS
|
||||
PAYPAL_RECURRING_DONATIONS,
|
||||
TEXT_FORMATTING
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -220,7 +222,8 @@ public final class FeatureFlags {
|
||||
RECIPIENT_MERGE_V2,
|
||||
CREDIT_CARD_PAYMENTS,
|
||||
PAYMENTS_REQUEST_ACTIVATE_FLOW,
|
||||
CDS_HARD_LIMIT
|
||||
CDS_HARD_LIMIT,
|
||||
TEXT_FORMATTING
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -564,6 +567,13 @@ public final class FeatureFlags {
|
||||
return getBoolean(PAYPAL_RECURRING_DONATIONS, Environment.IS_STAGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not we should show text formatting options.
|
||||
*/
|
||||
public static boolean textFormatting() {
|
||||
return getBoolean(TEXT_FORMATTING, false);
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
return new TreeMap<>(REMOTE_VALUES);
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.StringUtil;
|
||||
import org.signal.libsignal.protocol.util.Pair;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
@@ -25,7 +26,7 @@ public class SearchUtil {
|
||||
|
||||
public static Spannable getHighlightedSpan(@NonNull Locale locale,
|
||||
@NonNull StyleFactory styleFactory,
|
||||
@Nullable String text,
|
||||
@Nullable CharSequence text,
|
||||
@Nullable String highlight,
|
||||
int matchMode)
|
||||
{
|
||||
@@ -33,9 +34,9 @@ public class SearchUtil {
|
||||
return new SpannableString("");
|
||||
}
|
||||
|
||||
text = text.replaceAll("\n", " ");
|
||||
text = StringUtil.replace(text, '\n', " ");
|
||||
|
||||
return getHighlightedSpan(locale, styleFactory, new SpannableString(text), highlight, matchMode);
|
||||
return getHighlightedSpan(locale, styleFactory, SpannableString.valueOf(text), highlight, matchMode);
|
||||
}
|
||||
|
||||
public static Spannable getHighlightedSpan(@NonNull Locale locale,
|
||||
@@ -53,7 +54,7 @@ public class SearchUtil {
|
||||
return text;
|
||||
}
|
||||
|
||||
SpannableString spanned = new SpannableString(text);
|
||||
SpannableString spanned = SpannableString.valueOf(text);
|
||||
List<Pair<Integer, Integer>> ranges;
|
||||
|
||||
switch (matchMode) {
|
||||
@@ -67,8 +68,11 @@ 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) {
|
||||
spanned.setSpan(styleFactory.create(), range.first(), range.second(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
for (CharacterStyle style : styles) {
|
||||
spanned.setSpan(style, range.first(), range.second(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
return spanned;
|
||||
@@ -148,6 +152,6 @@ public class SearchUtil {
|
||||
}
|
||||
|
||||
public interface StyleFactory {
|
||||
CharacterStyle create();
|
||||
CharacterStyle[] createStyles();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user