MCPcopy Create free account
hub / github.com/M66B/FairEmail / getLanguage

Method getLanguage

app/src/main/java/eu/faircode/email/HtmlHelper.java:2642–2663  ·  view source on GitHub ↗
(Context context, String subject, String text)

Source from the content-addressed store, hash-verified

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)

Callers 15

onSendMethod · 0.95
onExecuteMethod · 0.95
onExecuteMethod · 0.95
decodeMessageMethod · 0.95
onExecuteMethod · 0.95
answerMethod · 0.95
onBodyMethod · 0.95
onSynchronizeMessagesMethod · 0.95
synchronizeMessageMethod · 0.95
downloadMessageMethod · 0.95
onReplyDirectMethod · 0.95
templateMethod · 0.95

Calls 7

detectLanguageMethod · 0.95
eMethod · 0.95
getBooleanMethod · 0.80
isEmptyMethod · 0.45
appendMethod · 0.45
lengthMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected