|
|
@ -19,6 +19,8 @@ package eu.faircode.email;
|
|
|
|
Copyright 2018-2024 by Marcel Bokhorst (M66B)
|
|
|
|
Copyright 2018-2024 by Marcel Bokhorst (M66B)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.ClipData;
|
|
|
|
|
|
|
|
import android.content.ClipboardManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
@ -27,6 +29,7 @@ import android.graphics.Bitmap;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Build;
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Pair;
|
|
|
|
import android.util.Pair;
|
|
|
|
import android.view.InputDevice;
|
|
|
|
import android.view.InputDevice;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.KeyEvent;
|
|
|
@ -37,6 +40,7 @@ import android.webkit.RenderProcessGoneDetail;
|
|
|
|
import android.webkit.WebSettings;
|
|
|
|
import android.webkit.WebSettings;
|
|
|
|
import android.webkit.WebView;
|
|
|
|
import android.webkit.WebView;
|
|
|
|
import android.webkit.WebViewClient;
|
|
|
|
import android.webkit.WebViewClient;
|
|
|
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
@ -294,19 +298,50 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View view) {
|
|
|
|
public boolean onLongClick(View view) {
|
|
|
|
WebView.HitTestResult result = ((WebView) view).getHitTestResult();
|
|
|
|
try {
|
|
|
|
if (result.getType() == WebView.HitTestResult.IMAGE_TYPE ||
|
|
|
|
final Context context = view.getContext();
|
|
|
|
result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
|
|
|
WebView.HitTestResult result = ((WebView) view).getHitTestResult();
|
|
|
|
Log.i("Long press url=" + result.getExtra());
|
|
|
|
int type = result.getType();
|
|
|
|
|
|
|
|
String extra = result.getExtra();
|
|
|
|
|
|
|
|
Log.i("WebView long click type=" + type + " extra=" + extra);
|
|
|
|
|
|
|
|
|
|
|
|
Uri uri = Uri.parse(result.getExtra());
|
|
|
|
if (TextUtils.isEmpty(extra))
|
|
|
|
if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme()))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
Helper.view(view.getContext(), uri, true);
|
|
|
|
if (type == HitTestResult.PHONE_TYPE ||
|
|
|
|
|
|
|
|
type == HitTestResult.GEO_TYPE ||
|
|
|
|
|
|
|
|
type == HitTestResult.EMAIL_TYPE ||
|
|
|
|
|
|
|
|
type == HitTestResult.SRC_ANCHOR_TYPE ||
|
|
|
|
|
|
|
|
type == HitTestResult.EDIT_TEXT_TYPE) {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
if (type == WebView.HitTestResult.IMAGE_TYPE ||
|
|
|
|
|
|
|
|
type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
|
|
|
|
|
|
|
Uri uri = Uri.parse(extra);
|
|
|
|
|
|
|
|
if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme()))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Helper.view(context, uri, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|