mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
This commit is contained in:
parent
70cbadfb3b
commit
973c468a7c
@ -33,6 +33,7 @@ import org.commonmark.ext.gfm.tables.TableBlock;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -136,10 +137,14 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -148,7 +153,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
textView.setHighlightColor(Color.TRANSPARENT);
|
textView.setHighlightColor(Color.TRANSPARENT);
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
@ -37,6 +37,7 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -161,10 +162,14 @@ public class WikiActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -173,7 +178,7 @@ public class WikiActivity extends BaseActivity {
|
|||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
textView.setHighlightColor(Color.TRANSPARENT);
|
textView.setHighlightColor(Color.TRANSPARENT);
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
@ -30,6 +30,7 @@ import androidx.recyclerview.widget.DiffUtil;
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -121,10 +122,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -133,7 +138,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
textView.setHighlightColor(Color.TRANSPARENT);
|
textView.setHighlightColor(Color.TRANSPARENT);
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
@ -166,10 +166,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -177,7 +181,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
@Override
|
@Override
|
||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
@ -105,10 +105,14 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -117,7 +121,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
textView.setHighlightColor(Color.TRANSPARENT);
|
textView.setHighlightColor(Color.TRANSPARENT);
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
@ -232,10 +232,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
@Override
|
@Override
|
||||||
public String processMarkdown(@NonNull String markdown) {
|
public String processMarkdown(@NonNull String markdown) {
|
||||||
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
|
ArrayList<Integer> matched = new ArrayList<>();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, ">");
|
matched.add(matcher.start());
|
||||||
|
}
|
||||||
|
for (int i = matched.size() - 1; i >= 0; i--) {
|
||||||
|
markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, ">");
|
||||||
}
|
}
|
||||||
return super.processMarkdown(markdownStringBuilder.toString());
|
return super.processMarkdown(markdownStringBuilder.toString());
|
||||||
}
|
}
|
||||||
@ -244,7 +248,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
public void afterSetText(@NonNull TextView textView) {
|
public void afterSetText(@NonNull TextView textView) {
|
||||||
textView.setHighlightColor(Color.TRANSPARENT);
|
textView.setHighlightColor(Color.TRANSPARENT);
|
||||||
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
|
||||||
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
|
Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
|
||||||
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
|
||||||
int start = 0;
|
int start = 0;
|
||||||
boolean find = false;
|
boolean find = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user