(View view)
| 318 | } |
| 319 | |
| 320 | @Override |
| 321 | public boolean onLongClick(View view) { |
| 322 | try { |
| 323 | final Context context = view.getContext(); |
| 324 | |
| 325 | WebView.HitTestResult result = ((WebView) view).getHitTestResult(); |
| 326 | int type = result.getType(); |
| 327 | String extra = result.getExtra(); |
| 328 | Log.i("WebView long click type=" + type + " extra=" + extra); |
| 329 | |
| 330 | if (TextUtils.isEmpty(extra)) |
| 331 | return false; |
| 332 | |
| 333 | if (type == HitTestResult.PHONE_TYPE || |
| 334 | type == HitTestResult.GEO_TYPE || |
| 335 | type == HitTestResult.EMAIL_TYPE || |
| 336 | type == HitTestResult.SRC_ANCHOR_TYPE || |
| 337 | type == HitTestResult.EDIT_TEXT_TYPE) { |
| 338 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 339 | boolean confirm_links = prefs.getBoolean("confirm_links", true); |
| 340 | if (confirm_links) { |
| 341 | ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class); |
| 342 | if (clipboard == null) |
| 343 | return false; |
| 344 | |
| 345 | String title = context.getString(R.string.app_name); |
| 346 | |
| 347 | ClipData clip = ClipData.newPlainText(title, extra); |
| 348 | clipboard.setPrimaryClip(clip); |
| 349 | |
| 350 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) |
| 351 | ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); |
| 352 | |
| 353 | return true; |
| 354 | } else |
| 355 | return intf.onOpenLink(extra, true); |
| 356 | } |
| 357 | |
| 358 | if (type == WebView.HitTestResult.IMAGE_TYPE || |
| 359 | type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { |
| 360 | Uri uri = Uri.parse(extra); |
| 361 | if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme())) |
| 362 | return false; |
| 363 | |
| 364 | Helper.view(context, uri, true); |
| 365 | |
| 366 | return true; |
| 367 | } |
| 368 | } catch (Throwable ex) { |
| 369 | Log.e(ex); |
| 370 | } |
| 371 | |
| 372 | return false; |
| 373 | } |
| 374 | |
| 375 | @Override |
| 376 | public boolean onGenericMotionEvent(MotionEvent event) { |
nothing calls this directly
no test coverage detected