Added long press / copy url

master
M66B 7 days ago
parent 60999623c3
commit 0d98b4d843

@ -647,7 +647,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public void onLongPress(@NonNull MotionEvent event) {
boolean confirm_links = prefs.getBoolean("confirm_links", true);
if (!confirm_links)
if (confirm_links) {
Spannable buffer = (Spannable) tvBody.getText();
int off = Helper.getOffset(tvBody, buffer, event);
URLSpan[] link = buffer.getSpans(off, off, URLSpan.class);
if (link.length > 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();
}
} else
onClick(event, true);
}

Loading…
Cancel
Save