aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorscria1000 <91804886+scria1000@users.noreply.github.com>2021-11-10 06:34:26 +0000
committerGitHub <noreply@github.com>2021-11-10 06:34:26 +0000
commit91c457bfe327f5e9cf41b1ab43846814aed692b2 (patch)
tree2e61ae419fb28c1bf1847fd7f48ad689d9d9c343 /app/src/main/java/ml/docilealligator/infinityforreddit
parentb8e2d44638b0ecb213fb0fa74c17da0060f4fd31 (diff)
parent973c468a7c9fdeb29f40e055b6ce792a8f358c4e (diff)
downloadinfinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar.gz
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar.bz2
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar.lz
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar.xz
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.tar.zst
infinity-for-reddit-91c457bfe327f5e9cf41b1ab43846814aed692b2.zip
Merge branch 'Docile-Alligator:master' into gallery-captions-feature
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java10
6 files changed, 45 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index dca5b75b..60406d70 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -33,6 +33,7 @@ import org.commonmark.ext.gfm.tables.TableBlock;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
+import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -136,10 +137,14 @@ public class FullMarkdownActivity extends BaseActivity {
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -148,7 +153,7 @@ public class FullMarkdownActivity extends BaseActivity {
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index c5e9d35c..63b147fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -37,6 +37,7 @@ import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
+import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -161,10 +162,14 @@ public class WikiActivity extends BaseActivity {
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -173,7 +178,7 @@ public class WikiActivity extends BaseActivity {
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index 4174b714..e3a1d53a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -30,6 +30,7 @@ import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
+import java.util.ArrayList;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -121,10 +122,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -133,7 +138,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 6147f3df..2dad51f9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -166,10 +166,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -177,7 +181,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public void afterSetText(@NonNull TextView textView) {
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
index 3925d59c..440544dc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
@@ -105,10 +105,14 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -117,7 +121,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 3d481524..9857e421 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -232,10 +232,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@Override
public String processMarkdown(@NonNull String markdown) {
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
+ ArrayList<Integer> matched = new ArrayList<>();
while (matcher.find()) {
- markdownStringBuilder.replace(matcher.start(), matcher.start() + 1, "&gt;");
+ matched.add(matcher.start());
+ }
+ for (int i = matched.size() - 1; i >= 0; i--) {
+ markdownStringBuilder.replace(matched.get(i), matched.get(i) + 1, "&gt;");
}
return super.processMarkdown(markdownStringBuilder.toString());
}
@@ -244,7 +248,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public void afterSetText(@NonNull TextView textView) {
textView.setHighlightColor(Color.TRANSPARENT);
SpannableStringBuilder markdownStringBuilder = new SpannableStringBuilder(textView.getText().toString());
- Pattern spoilerPattern = Pattern.compile(">![\\S\\s]*?!<");
+ Pattern spoilerPattern = Pattern.compile(">![\\S\\s]+?!<");
Matcher matcher = spoilerPattern.matcher(markdownStringBuilder);
int start = 0;
boolean find = false;