diff options
Diffstat (limited to 'src/main/java/eu')
3 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 4ad16559f..dcfe57e63 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -88,6 +88,8 @@ public final class Config { public static final int REFRESH_UI_INTERVAL = 500; + public static final int MAX_DISPLAY_MESSAGE_CHARS = 4096; + public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb public static final boolean DISABLE_HTTP_UPLOAD = false; public static final boolean DISABLE_STRING_PREP = false; // setting to true might increase startup performance diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index a22a4bb7f..f2f68a321 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -43,6 +43,7 @@ import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; +import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession; import eu.siacs.conversations.entities.Account; @@ -318,6 +319,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { } catch (ArrayIndexOutOfBoundsException e) { body = message.getMergedBody(); } + if (body.length() > Config.MAX_DISPLAY_MESSAGE_CHARS) { + body = body.substring(0, Config.MAX_DISPLAY_MESSAGE_CHARS)+"\u2026"; + } final SpannableString formattedBody = new SpannableString(body); int i = body.indexOf(Message.MERGE_SEPARATOR); while(i >= 0) { diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 6ca5370a3..4ab748188 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -184,8 +184,12 @@ public class UIHelper { return new Pair<>(getFileDescriptionString(context,message),true); } } else { - if (message.getBody().startsWith(Message.ME_COMMAND)) { - return new Pair<>(message.getBody().replaceAll("^" + Message.ME_COMMAND, + String body = message.getBody(); + if (body.length() > 256) { + body = body.substring(0,256); + } + if (body.startsWith(Message.ME_COMMAND)) { + return new Pair<>(body.replaceAll("^" + Message.ME_COMMAND, UIHelper.getMessageDisplayName(message) + " "), false); } else if (GeoHelper.isGeoUri(message.getBody())) { if (message.getStatus() == Message.STATUS_RECEIVED) { @@ -197,7 +201,7 @@ public class UIHelper { return new Pair<>(context.getString(R.string.x_file_offered_for_download, getFileDescriptionString(context,message)),true); } else{ - return new Pair<>(message.getBody().trim(), false); + return new Pair<>(body.trim(), false); } } } |