From e6c965448654e678f000cb2e52fce086afd9d022 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 28 Jul 2026 15:10:25 +0200 Subject: [PATCH] Refactoring --- .../eu/faircode/email/AdapterMessage.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 2d6d333f83..427b60e355 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -646,22 +646,18 @@ public class AdapterMessage extends RecyclerView.Adapter 0) { - String url = link[0].getURL(); - - ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class); - cbm.setPrimaryClip(ClipData.newPlainText(context.getString(R.string.app_name), url)); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) - ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); - } + Spannable buffer = (Spannable) tvBody.getText(); + int off = Helper.getOffset(tvBody, buffer, event); + URLSpan[] link = buffer.getSpans(off, off, URLSpan.class); + if (link.length > 0) { + ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class); + cbm.setPrimaryClip(ClipData.newPlainText(context.getString(R.string.app_name), link[0].getURL())); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) + ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); + } - } else + boolean confirm_links = prefs.getBoolean("confirm_links", true); + if (!confirm_links) onClick(event, true); }