mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Trim leading and trailing whitespace when displaying messages
Closes #326
This commit is contained in:
@@ -163,7 +163,8 @@ class ConversationAdapter extends RecyclerView.Adapter {
|
|||||||
if (item.getBody() == null) {
|
if (item.getBody() == null) {
|
||||||
ui.body.setText("\u2026");
|
ui.body.setText("\u2026");
|
||||||
} else if (header.getContentType().equals("text/plain")) {
|
} else if (header.getContentType().equals("text/plain")) {
|
||||||
ui.body.setText(StringUtils.fromUtf8(item.getBody()));
|
ui.body.setText(
|
||||||
|
StringUtils.trim(StringUtils.fromUtf8(item.getBody())));
|
||||||
} else {
|
} else {
|
||||||
// TODO support other content types
|
// TODO support other content types
|
||||||
}
|
}
|
||||||
@@ -182,7 +183,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
|
|||||||
ui.messageLayout.setVisibility(View.GONE);
|
ui.messageLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ui.messageLayout.setVisibility(View.VISIBLE);
|
ui.messageLayout.setVisibility(View.VISIBLE);
|
||||||
ui.message.body.setText(message);
|
ui.message.body.setText(StringUtils.trim(message));
|
||||||
ui.message.date.setText(
|
ui.message.date.setText(
|
||||||
DateUtils.getRelativeTimeSpanString(ctx, item.getTime()));
|
DateUtils.getRelativeTimeSpanString(ctx, item.getTime()));
|
||||||
}
|
}
|
||||||
@@ -286,7 +287,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
|
|||||||
ui.messageLayout.setVisibility(View.GONE);
|
ui.messageLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ui.messageLayout.setVisibility(View.VISIBLE);
|
ui.messageLayout.setVisibility(View.VISIBLE);
|
||||||
ui.message.body.setText(message);
|
ui.message.body.setText(StringUtils.trim(message));
|
||||||
ui.message.date.setText(
|
ui.message.date.setText(
|
||||||
DateUtils.getRelativeTimeSpanString(ctx, item.getTime()));
|
DateUtils.getRelativeTimeSpanString(ctx, item.getTime()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
data.setRead(true);
|
data.setRead(true);
|
||||||
forumController.entryRead(data);
|
forumController.entryRead(data);
|
||||||
}
|
}
|
||||||
ui.textView.setText(data.getText());
|
ui.textView.setText(StringUtils.trim(data.getText()));
|
||||||
|
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
ui.topDivider.setVisibility(View.INVISIBLE);
|
ui.topDivider.setVisibility(View.INVISIBLE);
|
||||||
|
|||||||
@@ -82,4 +82,8 @@ public class StringUtils {
|
|||||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||||
throw new IllegalArgumentException("Not a hex digit: " + c);
|
throw new IllegalArgumentException("Not a hex digit: " + c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String trim(String s) {
|
||||||
|
return s.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user