mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added LT plus URI
This commit is contained in:
parent
5729d39bc2
commit
7ff386078e
1 changed files with 5 additions and 3 deletions
|
@ -50,6 +50,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
|
||||
public class LanguageTool {
|
||||
static final String LT_URI = "https://api.languagetool.org/v2/";
|
||||
static final String LT_URI_PLUS = "https://api.languagetoolplus.com/v2/";
|
||||
private static final int LT_TIMEOUT = 20; // seconds
|
||||
|
||||
static boolean isEnabled(Context context) {
|
||||
|
@ -70,9 +71,10 @@ public class LanguageTool {
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean lt_picky = prefs.getBoolean("lt_picky", false);
|
||||
String lt_uri = prefs.getString("lt_uri", LT_URI);
|
||||
String lt_user = prefs.getString("lt_user", null);
|
||||
String lt_key = prefs.getString("lt_key", null);
|
||||
boolean isPlus = (!TextUtils.isEmpty(lt_user) && !TextUtils.isEmpty(lt_key));
|
||||
String lt_uri = prefs.getString("lt_uri", isPlus ? LT_URI_PLUS : LT_URI);
|
||||
|
||||
// https://languagetool.org/http-api/swagger-ui/#!/default/post_check
|
||||
Uri.Builder builder = new Uri.Builder()
|
||||
|
@ -103,10 +105,10 @@ public class LanguageTool {
|
|||
if (lt_picky)
|
||||
builder.appendQueryParameter("level", "picky");
|
||||
|
||||
if (!TextUtils.isEmpty(lt_user))
|
||||
if (isPlus) {
|
||||
builder.appendQueryParameter("username", lt_user);
|
||||
if (!TextUtils.isEmpty(lt_key))
|
||||
builder.appendQueryParameter("apiKey", lt_key);
|
||||
}
|
||||
|
||||
Uri uri = Uri.parse(lt_uri).buildUpon().appendPath("check").build();
|
||||
String request = builder.build().toString().substring(1);
|
||||
|
|
Loading…
Reference in a new issue