Enabled LanguageTool for Play store

pull/207/head
M66B 3 years ago
parent ddc516bf35
commit 0770952e91

@ -158,7 +158,6 @@ android {
buildConfigField "String", "CHANGELOG", "\"https://github.com/M66B/FairEmail/releases/\""
buildConfigField "String", "GITHUB_LATEST_API", "\"https://api.github.com/repos/M66B/FairEmail/releases/latest\""
buildConfigField "String", "GITHUB_LATEST_URI", "\"https://github.com/M66B/FairEmail/releases\""
buildConfigField "String", "LT_URI", "\"https://api.languagetool.org/v2/\""
buildConfigField "String", "TX_URI", localProperties.getProperty("paypal.uri", "\"\"")
buildConfigField "String", "GPA_URI", localProperties.getProperty("gpa.uri", "\"\"")
buildConfigField "String", "INFO_URI", localProperties.getProperty("info.uri", "\"\"")
@ -175,7 +174,6 @@ android {
buildConfigField "String", "CHANGELOG", "\"https://github.com/M66B/FairEmail/releases/\""
buildConfigField "String", "GITHUB_LATEST_API", "\"https://api.github.com/repos/M66B/FairEmail/releases/latest\""
buildConfigField "String", "GITHUB_LATEST_URI", "\"https://github.com/M66B/FairEmail/releases\""
buildConfigField "String", "LT_URI", "\"https://api.languagetool.org/v2/\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""
@ -193,7 +191,6 @@ android {
buildConfigField "String", "CHANGELOG", "\"\""
buildConfigField "String", "GITHUB_LATEST_API", "\"\""
buildConfigField "String", "GITHUB_LATEST_URI", "\"\""
buildConfigField "String", "LT_URI", "\"\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""
@ -211,7 +208,6 @@ android {
buildConfigField "String", "CHANGELOG", "\"\""
buildConfigField "String", "GITHUB_LATEST_API", "\"\""
buildConfigField "String", "GITHUB_LATEST_URI", "\"\""
buildConfigField "String", "LT_URI", "\"\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""

@ -2422,7 +2422,7 @@ public class FragmentCompose extends FragmentBase {
Bundle args = new Bundle();
args.putCharSequence("text", etBody.getText());
new SimpleTask<List<LT.Suggestion>>() {
new SimpleTask<List<LanguageTool.Suggestion>>() {
private Toast toast = null;
@Override
@ -2440,13 +2440,13 @@ public class FragmentCompose extends FragmentBase {
}
@Override
protected List<LT.Suggestion> onExecute(Context context, Bundle args) throws Throwable {
protected List<LanguageTool.Suggestion> onExecute(Context context, Bundle args) throws Throwable {
CharSequence text = args.getCharSequence("text").toString();
return LT.getSuggestions(context, text);
return LanguageTool.getSuggestions(context, text);
}
@Override
protected void onExecuted(Bundle args, List<LT.Suggestion> suggestions) {
protected void onExecuted(Bundle args, List<LanguageTool.Suggestion> suggestions) {
if (suggestions == null || suggestions.size() == 0) {
ToastEx.makeText(getContext(), R.string.title_suggestions_none, Toast.LENGTH_LONG).show();
return;
@ -2462,7 +2462,7 @@ public class FragmentCompose extends FragmentBase {
edit.removeSpan(span);
}
for (LT.Suggestion suggestion : suggestions) {
for (LanguageTool.Suggestion suggestion : suggestions) {
Log.i("LT adding=" + suggestion);
SuggestionSpan span = new SuggestionSpanEx(getContext(),
suggestion.replacements.toArray(new String[0]),

@ -37,7 +37,8 @@ import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
public class LT {
public class LanguageTool {
private static final String LT_URI = "https://api.languagetool.org/v2/";
private static final int LT_TIMEOUT = 20; // seconds
static List<Suggestion> getSuggestions(Context context, CharSequence text) throws IOException, JSONException {
@ -68,7 +69,7 @@ public class LT {
Log.i("LT locale=" + locale + " request=" + request);
URL url = new URL(BuildConfig.LT_URI + "check");
URL url = new URL(LT_URI + "check");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
Loading…
Cancel
Save