mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 03:46:00 +01:00
Added option to auto check with LanguageTool
This commit is contained in:
@@ -54,6 +54,13 @@ public class LanguageTool {
|
||||
return prefs.getBoolean("lt_enabled", false);
|
||||
}
|
||||
|
||||
static boolean isAuto(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean lt_enabled = prefs.getBoolean("lt_enabled", false);
|
||||
boolean lt_auto = prefs.getBoolean("lt_auto", false);
|
||||
return (lt_enabled && lt_auto);
|
||||
}
|
||||
|
||||
static List<Suggestion> getSuggestions(Context context, CharSequence text) throws IOException, JSONException {
|
||||
// https://languagetool.org/http-api/swagger-ui/#!/default/post_check
|
||||
String request =
|
||||
@@ -155,6 +162,8 @@ public class LanguageTool {
|
||||
Editable edit = etBody.getText();
|
||||
if (edit == null)
|
||||
return;
|
||||
if (suggestions == null)
|
||||
return;
|
||||
|
||||
// https://developer.android.com/reference/android/text/style/SuggestionSpan
|
||||
for (SuggestionSpanEx span : edit.getSpans(0, edit.length(), SuggestionSpanEx.class)) {
|
||||
|
||||
Reference in New Issue
Block a user