summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/app/fedilab/android/helper
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/app/fedilab/android/helper')
-rw-r--r--app/src/main/java/app/fedilab/android/helper/CustomEmoji.java7
-rw-r--r--app/src/main/java/app/fedilab/android/helper/Helper.java87
-rw-r--r--app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java116
-rw-r--r--app/src/main/java/app/fedilab/android/helper/SpannableHelper.java61
-rw-r--r--app/src/main/java/app/fedilab/android/helper/TimelineHelper.java1
-rw-r--r--app/src/main/java/app/fedilab/android/helper/itemtouchhelper/SimpleItemTouchHelperCallback.java2
6 files changed, 193 insertions, 81 deletions
diff --git a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java
index 51ce2fc87..108351115 100644
--- a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java
+++ b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java
@@ -52,12 +52,11 @@ public class CustomEmoji extends ReplacementSpan {
if (imageDrawable != null) {
canvas.save();
int emojiSize = (int) (paint.getTextSize() * scale);
- Drawable drawable = imageDrawable;
- drawable.setBounds(0, 0, emojiSize, emojiSize);
- int transY = bottom - drawable.getBounds().bottom;
+ imageDrawable.setBounds(0, 0, emojiSize, emojiSize);
+ int transY = bottom - imageDrawable.getBounds().bottom;
transY -= paint.getFontMetrics().descent / 2;
canvas.translate(x, (float) transY);
- drawable.draw(canvas);
+ imageDrawable.draw(canvas);
canvas.restore();
}
}
diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java
index cd295eb4a..0c816eeb6 100644
--- a/app/src/main/java/app/fedilab/android/helper/Helper.java
+++ b/app/src/main/java/app/fedilab/android/helper/Helper.java
@@ -238,6 +238,9 @@ public class Helper {
public static final String ARG_STATUS_REPLY_ID = "ARG_STATUS_REPLY_ID";
public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
public static final String ARG_ACCOUNT_ID = "ARG_ACCOUNT_ID";
+ public static final String ARG_ADMIN_DOMAINBLOCK = "ARG_ADMIN_DOMAINBLOCK";
+ public static final String ARG_ADMIN_DOMAINBLOCK_DELETE = "ARG_ADMIN_DOMAINBLOCK_DELETE";
+
public static final String ARG_REPORT = "ARG_REPORT";
public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION";
public static final String ARG_MINIFIED = "ARG_MINIFIED";
@@ -302,12 +305,14 @@ public class Helper {
public static final String PREF_IS_MODERATOR = "PREF_IS_MODERATOR";
public static final String PREF_IS_ADMINISTRATOR = "PREF_IS_ADMINISTRATOR";
public static final String PREF_KEY_ID = "PREF_KEY_ID";
+ public static final String PREF_MESSAGE_URL = "PREF_MESSAGE_URL";
public static final String PREF_INSTANCE = "PREF_INSTANCE";
public static final String SET_SECURITY_PROVIDER = "SET_SECURITY_PROVIDER";
public static final int NOTIFICATION_INTENT = 1;
public static final int OPEN_NOTIFICATION = 2;
+ public static final int OPEN_WITH_ANOTHER_ACCOUNT = 3;
public static final String INTENT_TARGETED_ACCOUNT = "INTENT_TARGETED_ACCOUNT";
public static final String INTENT_SEND_MODIFIED_IMAGE = "INTENT_SEND_MODIFIED_IMAGE";
public static final String INTENT_COMPOSE_ERROR_MESSAGE = "INTENT_COMPOSE_ERROR_MESSAGE";
@@ -334,6 +339,8 @@ public class Helper {
public static final Pattern bibliogramPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(/p/[\\w-/]+)");
public static final Pattern libredditPattern = Pattern.compile("(www\\.|m\\.)?(reddit\\.com|preview\\.redd\\.it|i\\.redd\\.it|redd\\.it)/(((?!([\"'<])).)*)");
public static final Pattern ouichesPattern = Pattern.compile("https?://ouich\\.es/tag/(\\w+)");
+
+ public static final Pattern geminiPattern = Pattern.compile("(gemini://.*)\\b");
public static final Pattern xmppPattern = Pattern.compile("xmpp:[-a-zA-Z0-9+$&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
public static final Pattern peertubePattern = Pattern.compile("(https?://([\\da-z.-]+\\.[a-z.]{2,10}))/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
public static final Pattern mediumPattern = Pattern.compile("([\\w@-]*)?\\.?medium.com/@?([/\\w-]+)");
@@ -745,39 +752,56 @@ public class Helper {
*/
public static String transformURL(Context context, String url) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
- Matcher matcher = Helper.nitterPattern.matcher(url);
+ Matcher matcher;
boolean nitter = Helper.getSharedValue(context, context.getString(R.string.SET_NITTER));
if (nitter) {
+ matcher = Helper.nitterPattern.matcher(url);
if (matcher.find()) {
final String nitter_directory = matcher.group(2);
String nitterHost = sharedpreferences.getString(context.getString(R.string.SET_NITTER_HOST), context.getString(R.string.DEFAULT_NITTER_HOST)).toLowerCase();
+ if (nitterHost.trim().isEmpty()) {
+ nitterHost = context.getString(R.string.DEFAULT_NITTER_HOST);
+ }
return "https://" + nitterHost + nitter_directory;
}
}
- matcher = Helper.bibliogramPattern.matcher(url);
+
boolean bibliogram = Helper.getSharedValue(context, context.getString(R.string.SET_BIBLIOGRAM));
+
if (bibliogram) {
+ matcher = Helper.bibliogramPattern.matcher(url);
if (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(context.getString(R.string.SET_BIBLIOGRAM_HOST), context.getString(R.string.DEFAULT_BIBLIOGRAM_HOST)).toLowerCase();
+ if (bibliogramHost.trim().isEmpty()) {
+ bibliogramHost = context.getString(R.string.DEFAULT_BIBLIOGRAM_HOST);
+ }
return "https://" + bibliogramHost + bibliogram_directory;
}
}
- matcher = Helper.libredditPattern.matcher(url);
+
boolean libreddit = Helper.getSharedValue(context, context.getString(R.string.SET_LIBREDDIT));
if (libreddit) {
+ matcher = Helper.libredditPattern.matcher(url);
if (matcher.find()) {
final String libreddit_directory = matcher.group(3);
String libreddit_host = sharedpreferences.getString(context.getString(R.string.SET_LIBREDDIT_HOST), context.getString(R.string.DEFAULT_LIBREDDIT_HOST)).toLowerCase();
+ if (libreddit_host.trim().isEmpty()) {
+ libreddit_host = context.getString(R.string.DEFAULT_LIBREDDIT_HOST);
+ }
return "https://" + libreddit_host + "/" + libreddit_directory;
}
}
- matcher = Helper.youtubePattern.matcher(url);
+
boolean invidious = Helper.getSharedValue(context, context.getString(R.string.SET_INVIDIOUS));
if (invidious) {
+ matcher = Helper.youtubePattern.matcher(url);
if (matcher.find()) {
final String youtubeId = matcher.group(3);
String invidiousHost = sharedpreferences.getString(context.getString(R.string.SET_INVIDIOUS_HOST), context.getString(R.string.DEFAULT_INVIDIOUS_HOST)).toLowerCase();
+ if (invidiousHost.trim().isEmpty()) {
+ invidiousHost = context.getString(R.string.DEFAULT_INVIDIOUS_HOST);
+ }
if (matcher.group(2) != null && Objects.equals(matcher.group(2), "youtu.be")) {
return "https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
} else {
@@ -785,9 +809,10 @@ public class Helper {
}
}
}
- matcher = Helper.mediumPattern.matcher(url);
+
boolean medium = Helper.getSharedValue(context, context.getString(R.string.REPLACE_MEDIUM));
if (medium) {
+ matcher = Helper.mediumPattern.matcher(url);
if (matcher.find()) {
String path = matcher.group(2);
String user = matcher.group(1);
@@ -795,12 +820,16 @@ public class Helper {
path = user + "/" + path;
}
String mediumReplaceHost = sharedpreferences.getString(context.getString(R.string.REPLACE_MEDIUM_HOST), context.getString(R.string.DEFAULT_REPLACE_MEDIUM_HOST)).toLowerCase();
+ if (mediumReplaceHost.trim().isEmpty()) {
+ mediumReplaceHost = context.getString(R.string.DEFAULT_REPLACE_MEDIUM_HOST);
+ }
return "https://" + mediumReplaceHost + "/" + path;
}
}
- matcher = Helper.wikipediaPattern.matcher(url);
+
boolean wikipedia = Helper.getSharedValue(context, context.getString(R.string.REPLACE_WIKIPEDIA));
if (wikipedia) {
+ matcher = Helper.wikipediaPattern.matcher(url);
if (matcher.find()) {
String subdomain = matcher.group(1);
String path = matcher.group(2);
@@ -810,6 +839,9 @@ public class Helper {
lang = (path.contains("?")) ? TextUtils.htmlEncode("&") : "?";
lang = lang + "lang=" + subdomain;
}
+ if (wikipediaReplaceHost.trim().isEmpty()) {
+ wikipediaReplaceHost = context.getString(R.string.DEFAULT_REPLACE_WIKIPEDIA_HOST);
+ }
return "https://" + wikipediaReplaceHost + "/" + path + lang;
}
}
@@ -1105,8 +1137,8 @@ public class Helper {
* @param view ImageView - the view where the image will be loaded
* @param account - {@link Account}
*/
- public static void loadPP(ImageView view, BaseAccount account) {
- loadPP(view, account, false);
+ public static void loadPP(Activity activity, ImageView view, BaseAccount account) {
+ loadPP(activity, view, account, false);
}
/**
@@ -1115,15 +1147,14 @@ public class Helper {
* @param view ImageView - the view where the image will be loaded
* @param account - {@link Account}
*/
- public static void loadPP(ImageView view, BaseAccount account, boolean crop) {
- Context context = view.getContext();
- SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
- boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false);
+ public static void loadPP(Activity activity, ImageView view, BaseAccount account, boolean crop) {
+ SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
+ boolean disableGif = sharedpreferences.getBoolean(activity.getString(R.string.SET_DISABLE_GIF), false);
String targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar;
- if (targetedUrl != null && Helper.isValidContextForGlide(context)) {
+ if (targetedUrl != null && Helper.isValidContextForGlide(activity)) {
if (disableGif || (!targetedUrl.endsWith(".gif"))) {
try {
- RequestBuilder<Drawable> requestBuilder = Glide.with(context)
+ RequestBuilder<Drawable> requestBuilder = Glide.with(activity)
.asDrawable()
.load(targetedUrl)
.thumbnail(0.1f);
@@ -1134,7 +1165,7 @@ public class Helper {
} catch (Exception ignored) {
}
} else {
- RequestBuilder<GifDrawable> requestBuilder = Glide.with(context)
+ RequestBuilder<GifDrawable> requestBuilder = Glide.with(activity)
.asGif()
.load(targetedUrl)
.thumbnail(0.1f);
@@ -1143,8 +1174,8 @@ public class Helper {
}
requestBuilder.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))).into(view);
}
- } else if (Helper.isValidContextForGlide(context)) {
- Glide.with(context)
+ } else if (Helper.isValidContextForGlide(activity)) {
+ Glide.with(activity)
.asDrawable()
.load(R.drawable.ic_person)
.thumbnail(0.1f)
@@ -1165,7 +1196,7 @@ public class Helper {
return null;
}
Proxy proxy = new Proxy(type == 0 ? Proxy.Type.HTTP : Proxy.Type.SOCKS,
- new InetSocketAddress(hostVal, portVal));
+ InetSocketAddress.createUnresolved(hostVal, portVal));
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
@@ -1502,6 +1533,18 @@ public class Helper {
channelId = "channel_status";
channelTitle = context.getString(R.string.channel_notif_status);
break;
+ case UPDATE:
+ channelId = "channel_update";
+ channelTitle = context.getString(R.string.channel_notif_update);
+ break;
+ case SIGN_UP:
+ channelId = "channel_signup";
+ channelTitle = context.getString(R.string.channel_notif_signup);
+ break;
+ case REPORT:
+ channelId = "channel_report";
+ channelTitle = context.getString(R.string.channel_notif_report);
+ break;
default:
channelId = "channel_boost";
channelTitle = context.getString(R.string.channel_notif_boost);
@@ -1584,8 +1627,11 @@ public class Helper {
.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance)
.setGroupSummary(true)
.build();
+
notificationManager.notify(notificationId++, notificationBuilder.build());
- notificationManager.notify(0, summaryNotification);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
+ notificationManager.notify(0, summaryNotification);
+ }
}
public static void transfertIfExist(Context context) {
@@ -1960,6 +2006,9 @@ public class Helper {
BOOST,
FAV,
POLL,
+ UPDATE,
+ SIGN_UP,
+ REPORT,
STATUS,
BACKUP,
STORE,
diff --git a/app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java b/app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java
index 57675c2a7..18a81cfbd 100644
--- a/app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java
+++ b/app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java
@@ -158,6 +158,9 @@ public class NotificationsHelper {
boolean notif_poll = prefs.getBoolean(context.getString(R.string.SET_NOTIF_POLL), true);
boolean notif_fav = prefs.getBoolean(context.getString(R.string.SET_NOTIF_FAVOURITE), true);
boolean notif_status = prefs.getBoolean(context.getString(R.string.SET_NOTIF_STATUS), true);
+ boolean notif_update = prefs.getBoolean(context.getString(R.string.SET_NOTIF_UPDATE), true);
+ boolean notif_signup = prefs.getBoolean(context.getString(R.string.SET_NOTIF_ADMIN_SIGNUP), true);
+ boolean notif_report = prefs.getBoolean(context.getString(R.string.SET_NOTIF_ADMIN_REPORT), true);
final String max_id = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + key, null);
@@ -232,18 +235,18 @@ public class NotificationsHelper {
title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_reblog));
else
title = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_reblog));
- }
- if (notification.status != null) {
- if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ if (notification.status != null) {
+ if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ }
}
}
break;
@@ -254,18 +257,18 @@ public class NotificationsHelper {
title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_favourite));
else
title = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_favourite));
- }
- if (notification.status != null) {
- if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ if (notification.status != null) {
+ if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ }
}
}
break;
@@ -298,21 +301,62 @@ public class NotificationsHelper {
title = context.getString(R.string.notif_poll_self);
else
title = context.getString(R.string.notif_poll);
+ if (notification.status != null) {
+ if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ }
+ }
}
- if (notification.status != null) {
- if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
- else
- message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ break;
+ case "update":
+ notifType = Helper.NotifType.UPDATE;
+ if (notif_update) {
+ title = context.getString(R.string.notif_update_push);
+ if (notification.status != null) {
+ if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
+ else
+ message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
+ }
}
}
break;
+ case "admin.sign_up":
+ notifType = Helper.NotifType.SIGN_UP;
+ if (notif_signup) {
+ title = context.getString(R.string.notif_sign_up);
+ if (notification.account.display_name != null && notification.account.display_name.length() > 0)
+ message = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_signed_up));
+ else
+ message = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_signed_up));
+ targeted_account = notification.account.id;
+ }
+ break;
+ case "admin.report":
+ notifType = Helper.NotifType.REPORT;
+ if (notif_report) {
+ title = context.getString(R.string.notif_report);
+ if (notification.account.display_name != null && notification.account.display_name.length() > 0)
+ message = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_reported));
+ else
+ message = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_reported));
+ targeted_account = notification.account.id;
+ }
+ break;
default:
}
if (message != null) {
@@ -321,7 +365,7 @@ public class NotificationsHelper {
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
intent.putExtra(Helper.PREF_KEY_ID, account.user_id);
- if (targeted_account != null && notifType == Helper.NotifType.FOLLLOW)
+ if (targeted_account != null)
intent.putExtra(Helper.INTENT_TARGETED_ACCOUNT, targeted_account);
intent.putExtra(Helper.PREF_INSTANCE, account.instance);
notificationUrl = notification.account.avatar;
diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
index df8c628af..3da822cd1 100644
--- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
+++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
@@ -147,6 +147,7 @@ public class SpannableHelper {
linkify(context, content, urlDetails);
linkifyURL(context, content, urlDetails);
emails(context, content);
+ gemini(context, content);
replaceQuoteSpans(context, content);
} else {
content = new SpannableStringBuilder(text);
@@ -249,11 +250,17 @@ public class SpannableHelper {
dialogBuilder.setView(popupLinksBinding.getRoot());
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
- String finalURl = url;
- String uniqueUrl = url.endsWith("…") ? url : url + "…";
+ String finalURl = newURL;
+ String uniqueUrl = newURL.endsWith("…") ? newURL : newURL + "…";
if (urlDetails.containsValue(uniqueUrl)) {
finalURl = Helper.getKeyByValue(urlDetails, uniqueUrl);
}
+ if (finalURl == null) {
+ return;
+ }
+ if (finalURl.startsWith("http://")) {
+ finalURl = finalURl.replace("http://", "https://");
+ }
String finalURl1 = finalURl;
popupLinksBinding.displayFullLink.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext, Helper.dialogStyle());
@@ -668,6 +675,38 @@ public class SpannableHelper {
}
}
+ private static void gemini(Context context, Spannable content) {
+ // --- For all patterns defined in Helper class ---
+ Pattern pattern = Helper.geminiPattern;
+ Matcher matcher = pattern.matcher(content);
+ while (matcher.find()) {
+ int matchStart = matcher.start();
+ int matchEnd = matcher.end();
+ String geminiLink = content.toString().substring(matchStart, matchEnd);
+ if (matchStart >= 0 && matchEnd <= content.toString().length() && matchEnd >= matchStart) {
+ ClickableSpan[] clickableSpans = content.getSpans(matchStart, matchEnd, ClickableSpan.class);
+ if (clickableSpans != null) {
+ for (ClickableSpan clickableSpan : clickableSpans) {
+ content.removeSpan(clickableSpan);
+ }
+ }
+ content.removeSpan(clickableSpans);
+ content.setSpan(new ClickableSpan() {
+ @Override
+ public void onClick(@NonNull View textView) {
+ Helper.openBrowser(context, geminiLink);
+ }
+
+ @Override
+ public void updateDrawState(@NonNull TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setUnderlineText(false);
+ ds.setColor(linkColor);
+ }
+ }, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ }
+ }
+ }
private static void emails(Context context, Spannable content) {
// --- For all patterns defined in Helper class ---
@@ -872,24 +911,6 @@ public class SpannableHelper {
}
}
- /**
- * Convert HTML content to text. Also, it handles click on link
- * This needs to be run asynchronously
- *
- * @param text String - text to convert, it can be content, spoiler, poll items, etc.
- * @return Spannable string
- */
- public static Spannable convertNitter(String text) {
- SpannableString initialContent;
- if (text == null) {
- return null;
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- initialContent = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
- else
- initialContent = new SpannableString(Html.fromHtml(text));
- return initialContent;
- }
/**
diff --git a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
index 3dd0704ea..02ce2b2fa 100644
--- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
+++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
@@ -177,7 +177,6 @@ public class TimelineHelper {
public static List<Notification> filterNotification(Context context, List<Notification> notifications) {
//A security to make sure filters have been fetched before displaying messages
List<Notification> notificationToRemove = new ArrayList<>();
-
if (!BaseMainActivity.filterFetched) {
try {
FiltersVM filtersVM = new ViewModelProvider((ViewModelStoreOwner) context).get(FiltersVM.class);
diff --git a/app/src/main/java/app/fedilab/android/helper/itemtouchhelper/SimpleItemTouchHelperCallback.java b/app/src/main/java/app/fedilab/android/helper/itemtouchhelper/SimpleItemTouchHelperCallback.java
index f929d9d02..3c42ab280 100644
--- a/app/src/main/java/app/fedilab/android/helper/itemtouchhelper/SimpleItemTouchHelperCallback.java
+++ b/app/src/main/java/app/fedilab/android/helper/itemtouchhelper/SimpleItemTouchHelperCallback.java
@@ -64,7 +64,7 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
return makeMovementFlags(dragFlags, swipeFlags);
} else {
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
- final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
+ final int swipeFlags = 0;
return makeMovementFlags(dragFlags, swipeFlags);
}
}