1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 10:17:18 +00:00

Use link dialog on long press only when not confirming links

This commit is contained in:
M66B 2024-02-17 17:40:12 +01:00
parent f896be9835
commit e19d3f4a22
2 changed files with 24 additions and 3 deletions

View file

@ -626,7 +626,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public void onLongPress(@NonNull MotionEvent event) {
onClick(event, true);
boolean confirm_links = prefs.getBoolean("confirm_links", true);
if (!confirm_links)
onClick(event, true);
}
private boolean onClick(MotionEvent event, boolean longClick) {

View file

@ -300,6 +300,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
public boolean onLongClick(View view) {
try {
final Context context = view.getContext();
WebView.HitTestResult result = ((WebView) view).getHitTestResult();
int type = result.getType();
String extra = result.getExtra();
@ -312,8 +313,26 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
type == HitTestResult.GEO_TYPE ||
type == HitTestResult.EMAIL_TYPE ||
type == HitTestResult.SRC_ANCHOR_TYPE ||
type == HitTestResult.EDIT_TEXT_TYPE)
return intf.onOpenLink(extra, true);
type == HitTestResult.EDIT_TEXT_TYPE) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean confirm_links = prefs.getBoolean("confirm_links", true);
if (confirm_links) {
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
if (clipboard == null)
return false;
String title = context.getString(R.string.app_name);
ClipData clip = ClipData.newPlainText(title, extra);
clipboard.setPrimaryClip(clip);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU)
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
return true;
} else
return intf.onOpenLink(extra, true);
}
if (type == WebView.HitTestResult.IMAGE_TYPE ||
type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {