Fix some crashes
This commit is contained in:
parent
b8d9a771f2
commit
07ee07b6fa
|
@ -42,6 +42,7 @@ import android.text.style.ClickableSpan;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
import android.text.style.QuoteSpan;
|
import android.text.style.QuoteSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
@ -629,10 +630,12 @@ public class Status implements Parcelable {
|
||||||
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
||||||
if (invidious) {
|
if (invidious) {
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
final String youtubeId = matcher.group(4);
|
final String youtubeId = matcher.group(3);
|
||||||
|
Log.v(Helper.TAG,"youtubeId: " + youtubeId);
|
||||||
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||||
content = content.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
Log.v(Helper.TAG,"quote: " + "https://"+Pattern.quote(matcher.group()));
|
||||||
content = content.replaceAll(">"+Pattern.quote(matcher.group()), Matcher.quoteReplacement(">"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
content = content.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+invidiousHost + "/"+youtubeId+"&local=true"));
|
||||||
|
content = content.replaceAll(">"+Pattern.quote(matcher.group()), Matcher.quoteReplacement(">"+invidiousHost + "/" + youtubeId+"&local=true"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2583,12 +2583,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
||||||
if (invidious) {
|
if (invidious) {
|
||||||
Matcher matcher = Helper.youtubeOembedPattern.matcher(url);
|
Matcher matcher = Helper.youtubePattern.matcher(url);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
final String youtubeId = matcher.group(2);
|
final String youtubeId = matcher.group(3);
|
||||||
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||||
url = url.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(invidiousHost + "/embed/" + youtubeId + "?feature=oembed&local=true"));
|
url = url.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+invidiousHost + "/"+youtubeId+"&local=true"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,9 +528,8 @@ public class Helper {
|
||||||
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
||||||
public static final Pattern groupPattern = Pattern.compile("(\\![\\w_]+(\\s|$))");
|
public static final Pattern groupPattern = Pattern.compile("(\\![\\w_]+(\\s|$))");
|
||||||
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
||||||
public static final Pattern youtubePattern = Pattern.compile("(m\\.|www\\.)?youtu(\\.be/|be\\.com/watch\\?((?!v=).)*v=)([\\w-]+)");
|
public static final Pattern youtubePattern = Pattern.compile("(\"|'|>)(www\\.|m\\.)?(youtube\\.com|youtu\\.be|youtube-nocookie\\.com)/(.*)(\"|'|<)");
|
||||||
public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)");
|
public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)");
|
||||||
public static final Pattern youtubeOembedPattern = Pattern.compile("(www\\.)?youtube\\.com\\/embed\\/(\\w+)\\?feature=oembed");
|
|
||||||
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
||||||
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
||||||
private static final Pattern mentionSearchPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+|@[\\w_-]+)");
|
private static final Pattern mentionSearchPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+|@[\\w_-]+)");
|
||||||
|
|
Loading…
Reference in New Issue