From aaf5233efe39e8473c4e616ac256004f627816c8 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 28 May 2016 23:48:39 +0200 Subject: limit text size in message adapter to 2k and also limit text size in conversations adapter --- src/main/java/eu/siacs/conversations/Config.java | 2 +- src/main/java/eu/siacs/conversations/utils/UIHelper.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index c4fe28d98..1d2c727d1 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -76,7 +76,7 @@ public final class Config { public static final int REFRESH_UI_INTERVAL = 500; - public static final int MAX_DISPLAY_MESSAGE_CHARS = 5 * 1024; + public static final int MAX_DISPLAY_MESSAGE_CHARS = 2 * 1024; public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb public static final boolean DISABLE_HTTP_UPLOAD = false; 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); } } } -- cgit v1.2.3