(Context context, String subject, String text)
| 2640 | } |
| 2641 | |
| 2642 | static String getLanguage(Context context, String subject, String text) { |
| 2643 | try { |
| 2644 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 2645 | boolean language_detection = prefs.getBoolean("language_detection", false); |
| 2646 | if (!language_detection) |
| 2647 | return null; |
| 2648 | |
| 2649 | StringBuilder sb = new StringBuilder(); |
| 2650 | if (!TextUtils.isEmpty(subject)) |
| 2651 | sb.append(subject).append('\n'); |
| 2652 | if (!TextUtils.isEmpty(text)) |
| 2653 | sb.append(text); |
| 2654 | if (sb.length() == 0) |
| 2655 | return null; |
| 2656 | |
| 2657 | Locale locale = TextHelper.detectLanguage(context, sb.toString()); |
| 2658 | return (locale == null ? null : locale.getLanguage()); |
| 2659 | } catch (Throwable ex) { |
| 2660 | Log.e(ex); |
| 2661 | return null; |
| 2662 | } |
| 2663 | } |
| 2664 | |
| 2665 | static String getPreview(String text) { |
| 2666 | if (text == null) |
no test coverage detected