aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java4
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java16
3 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 98a847b09..05d0292a3 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -810,11 +810,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return null;
}
- public boolean setNextMessage(String message) {
+ public boolean setNextMessage(final String input) {
+ final String message = input == null || input.trim().isEmpty() ? null : input;
boolean changed = !getNextMessage().equals(message);
this.setAttribute(ATTRIBUTE_NEXT_MESSAGE, message);
if (changed) {
- this.setAttribute(ATTRIBUTE_NEXT_MESSAGE_TIMESTAMP, TextUtils.isEmpty(message) ? 0 : System.currentTimeMillis());
+ this.setAttribute(ATTRIBUTE_NEXT_MESSAGE_TIMESTAMP, message == null ? 0 : System.currentTimeMillis());
}
return changed;
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index d47f8cb72..be6660f53 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -2724,7 +2724,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return;
}
String previous = this.binding.textinput.getText().toString();
- if (previous.length() != 0 && !previous.endsWith(" ")) {
+ if (UIHelper.isLastLineQuote(previous)) {
+ text = '\n' + text;
+ } else if (previous.length() != 0 && !Character.isWhitespace(previous.charAt(previous.length() - 1))) {
text = " " + text;
}
this.binding.textinput.append(text);
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index e03f84189..f5730e981 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -327,6 +327,22 @@ public class UIHelper {
}
}
+ public static boolean isLastLineQuote(String body) {
+ if (body.endsWith("\n")) {
+ return false;
+ }
+ String[] lines = body.split("\n");
+ if (lines.length == 0) {
+ return false;
+ }
+ String line = lines[lines.length - 1];
+ if (line.isEmpty()) {
+ return false;
+ }
+ char first = line.charAt(0);
+ return first == '>' && isPositionFollowedByQuoteableCharacter(line, 0) || first == '\u00bb';
+ }
+
public static CharSequence shorten(CharSequence input) {
return input.length() > 256 ? StylingHelper.subSequence(input, 0, 256) : input;
}