Quoting quotes, limited by nesting depth.
This commit is contained in:
parent
74d60d0131
commit
e850900b40
|
@ -202,6 +202,8 @@ public final class Config {
|
||||||
public final static int LOCATION_FIX_SIGNIFICANT_TIME_DELTA = 1000 * 60 * 2; // ms
|
public final static int LOCATION_FIX_SIGNIFICANT_TIME_DELTA = 1000 * 60 * 2; // ms
|
||||||
}
|
}
|
||||||
|
|
||||||
// How deep nested quotes should become. '2' means one quote nested in another.
|
// How deep nested quotes should be displayed. '2' means one quote nested in another.
|
||||||
public static final int QUOTE_MAX_DEPTH = 3;
|
public static final int QUOTE_MAX_DEPTH = 3;
|
||||||
|
// How deep nested quotes should be created on quoting a message.
|
||||||
|
public static final int QUOTING_MAX_DEPTH = QUOTE_MAX_DEPTH - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.ui.util;
|
package eu.siacs.conversations.ui.util;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
|
|
||||||
public class QuoteHelper {
|
public class QuoteHelper {
|
||||||
|
@ -32,20 +33,19 @@ public class QuoteHelper {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*public static int getQuoteColors(XmppActivity activity, boolean darkBackground, int quoteDepth){
|
|
||||||
int[] colorsLight = R.style.ConversationsTheme_Dark;
|
|
||||||
int[] colorsDark = Config.QUOTE_COLOR_ARRAY_DARK;
|
|
||||||
|
|
||||||
Collections.rotate(Collections.singletonList(colorsLight), quoteDepth);
|
public static boolean isNestedTooDeeply (CharSequence line){
|
||||||
Collections.rotate(Collections.singletonList(colorsDark), quoteDepth);
|
if (isPositionQuoteCharacter(line, 0)) {
|
||||||
|
int nestingDepth = 1;
|
||||||
Arrays.stream(colorsLight).toArray();
|
for (int i = 1; i < line.length(); i++) {
|
||||||
|
if (isPositionQuoteCharacter(line, i)) {
|
||||||
int quoteColors = darkBackground ? ContextCompat.getColor(activity, colorsLight[quoteDepth-1])
|
nestingDepth++;
|
||||||
: ContextCompat.getColor(activity, colorsDark[quoteDepth-1]);
|
}
|
||||||
|
if (nestingDepth > (Config.QUOTING_MAX_DEPTH)) {
|
||||||
Collections.rotate
|
return true;
|
||||||
|
}
|
||||||
return quoteColors;
|
}
|
||||||
};*/
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class EditMessage extends EmojiWrapperEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAsQuote(String text) {
|
public void insertAsQuote(String text) {
|
||||||
text = text.replaceAll("(\n *){2,}", "\n").replaceAll("(^|\n)", "$1> ").replaceAll("\n$", "");
|
text = text.replaceAll("(\n *){2,}", "\n").replaceAll("(^|\n)>", "$1>>").replaceAll("(^|\n)([^>])", "$1> $2").replaceAll("\n$", "");
|
||||||
Editable editable = getEditableText();
|
Editable editable = getEditableText();
|
||||||
int position = getSelectionEnd();
|
int position = getSelectionEnd();
|
||||||
if (position == -1) position = editable.length();
|
if (position == -1) position = editable.length();
|
||||||
|
|
|
@ -39,6 +39,7 @@ import eu.siacs.conversations.entities.Conversational;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.http.AesGcmURL;
|
import eu.siacs.conversations.http.AesGcmURL;
|
||||||
import eu.siacs.conversations.http.URL;
|
import eu.siacs.conversations.http.URL;
|
||||||
|
import eu.siacs.conversations.ui.util.QuoteHelper;
|
||||||
|
|
||||||
public class MessageUtils {
|
public class MessageUtils {
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ public class MessageUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final char c = line.charAt(0);
|
final char c = line.charAt(0);
|
||||||
if (c == '>' && UIHelper.isPositionFollowedByQuoteableCharacter(line, 0)
|
if (QuoteHelper.isNestedTooDeeply(line)
|
||||||
|| (c == '\u00bb' && !UIHelper.isPositionFollowedByQuote(line, 0))) {
|
|| (c == '\u00bb' && !UIHelper.isPositionFollowedByQuote(line, 0))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue